From 1a89ecba69cdf7ce22b7135d539725696c775726 Mon Sep 17 00:00:00 2001 From: EdwardWang Date: Thu, 31 Aug 2023 11:12:06 +0800 Subject: [PATCH] [fixes]: use the right enum for comparison --- clang/lib/Sema/SemaBSCTrait.cpp | 23 ++++++++++++----------- clang/lib/Sema/SemaStmt.cpp | 4 ++-- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/clang/lib/Sema/SemaBSCTrait.cpp b/clang/lib/Sema/SemaBSCTrait.cpp index dfd08633e44d..8370c4f5b2d9 100644 --- a/clang/lib/Sema/SemaBSCTrait.cpp +++ b/clang/lib/Sema/SemaBSCTrait.cpp @@ -41,14 +41,17 @@ RecordDecl *Sema::ActOnDesugarVtableRecord(SourceLocation StartLoc, return Result; } -// when we saw a trait like: -// ` trait I {int g(This *this);}; -// we should generate two struct in ast: +// When we see a trait like: +// trait I { +// int g(This *this); +// }; +// +// We generate two structs in ast: // |--RecordDecl struct Trait_I_Vtable -// |----FieldDecl g 'int (*)(void *this)' +// `---FieldDecl g 'int (*)(void *this)' // |--RecordDecl struct Trait_I -// |----FieldDecl data (*)(void) -// |----FieldDecl vtable struct (*)Trait_I_Vtable +// `---FieldDecl data (*)(void) +// `---FieldDecl vtable struct (*)Trait_I_Vtable void Sema::ActOnDesugarTraitVtable(TraitDecl *Find, RecordDecl *TraitVtableRD, SourceLocation StartLoc, SourceLocation NameLoc, IdentifierInfo *Name, @@ -156,7 +159,6 @@ ImplTraitDecl *Sema::BuildImplTraitDecl(Scope *S, Declarator &D, DeclarationName Name = GetNameForDeclarator(D).getName(); IdentifierInfo *II = Name.getAsIdentifierInfo(); - // We should move this piece of code. ImplTraitDecl *ITD = nullptr; ITD = ImplTraitDecl::Create(Context, DC, D.getBeginLoc(), D.getIdentifierLoc(), @@ -250,10 +252,9 @@ VarDecl *Sema::DesugarImplTrait(ImplTraitDecl *ITD, Declarator &D) { QualType QT = TraitRecord->getTypeForDecl()->getCanonicalTypeInternal(); TypeSourceInfo *TInfo = GetTypeForDeclarator(D, S); QualType T = TInfo->getType().getCanonicalType(); - VarDecl *LookUpVar = TD->getTypeImpledVarDecl( - T); // If we have the same ImplTraitDecl before, return nullptr - if (LookUpVar) - return nullptr; + VarDecl *LookUpVar = TD->getTypeImpledVarDecl(T); + // If we have the same ImplTraitDecl before, return nullptr + if (LookUpVar) return nullptr; PrintingPolicy PrintPolicy = LangOptions(); SplitQualType T_split = T.split(); std::string Ty = T.getAsString(T_split, PrintPolicy); diff --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp index b3fb666b4e6a..fddfe84b6ab4 100644 --- a/clang/lib/Sema/SemaStmt.cpp +++ b/clang/lib/Sema/SemaStmt.cpp @@ -463,9 +463,9 @@ void Sema::ActOnPragmaSafe(PragmaSafeStatus St) { void Sema::ActOnPragmaPreferInline(PragmaPreferInlineStatus St) { PreferInlineScopeSpecifier spec = PI_None; - if (St == PSS_On) { + if (St == PPI_On) { spec = PI_PreferInline; - } else if (St == PSS_Off) { + } else if (St == PPI_Off) { spec = PI_PreferNoInline; } SetPragmaPreferInlineInfo(spec); -- Gitee