Author: Vlad Serebrennikov Date: 2025-04-28T08:42:02+03:00 New Revision: ee29afe1e56d911f2fde54f5de141f4c4a0a1feb
URL: https://github.com/llvm/llvm-project/commit/ee29afe1e56d911f2fde54f5de141f4c4a0a1feb DIFF: https://github.com/llvm/llvm-project/commit/ee29afe1e56d911f2fde54f5de141f4c4a0a1feb.diff LOG: [clang][NFC] Convert LookupResultKind to scoped enum Added: Modified: clang/include/clang/Sema/Lookup.h clang/lib/Sema/SemaDecl.cpp clang/lib/Sema/SemaDeclCXX.cpp clang/lib/Sema/SemaExprCXX.cpp clang/lib/Sema/SemaExprObjC.cpp clang/lib/Sema/SemaLookup.cpp clang/lib/Sema/SemaTemplate.cpp clang/lib/Sema/SemaTemplateVariadic.cpp clang/lib/Sema/TreeTransform.h clang/utils/ClangVisualizers/clang.natvis Removed: ################################################################################ diff --git a/clang/include/clang/Sema/Lookup.h b/clang/include/clang/Sema/Lookup.h index 41a206b7f52b3..5478b96d535bd 100644 --- a/clang/include/clang/Sema/Lookup.h +++ b/clang/include/clang/Sema/Lookup.h @@ -36,6 +36,34 @@ namespace clang { class CXXBasePaths; +enum class LookupResultKind { + /// No entity found met the criteria. + NotFound = 0, + + /// No entity found met the criteria within the current + /// instantiation,, but there were dependent base classes of the + /// current instantiation that could not be searched. + NotFoundInCurrentInstantiation, + + /// Name lookup found a single declaration that met the + /// criteria. getFoundDecl() will return this declaration. + Found, + + /// Name lookup found a set of overloaded functions that + /// met the criteria. + FoundOverloaded, + + /// Name lookup found an unresolvable value declaration + /// and cannot yet complete. This only happens in C++ dependent + /// contexts with dependent using declarations. + FoundUnresolvedValue, + + /// Name lookup results in an ambiguity; use + /// getAmbiguityKind to figure out what kind of ambiguity + /// we have. + Ambiguous +}; + enum class LookupAmbiguityKind { /// Name lookup results in an ambiguity because multiple /// entities that meet the lookup criteria were found in @@ -118,34 +146,6 @@ enum class LookupAmbiguityKind { /// results occurred for a given lookup. class LookupResult { public: - enum LookupResultKind { - /// No entity found met the criteria. - NotFound = 0, - - /// No entity found met the criteria within the current - /// instantiation,, but there were dependent base classes of the - /// current instantiation that could not be searched. - NotFoundInCurrentInstantiation, - - /// Name lookup found a single declaration that met the - /// criteria. getFoundDecl() will return this declaration. - Found, - - /// Name lookup found a set of overloaded functions that - /// met the criteria. - FoundOverloaded, - - /// Name lookup found an unresolvable value declaration - /// and cannot yet complete. This only happens in C++ dependent - /// contexts with dependent using declarations. - FoundUnresolvedValue, - - /// Name lookup results in an ambiguity; use - /// getAmbiguityKind to figure out what kind of ambiguity - /// we have. - Ambiguous - }; - /// A little identifier for flagging temporary lookup results. enum TemporaryToken { Temporary @@ -322,23 +322,23 @@ class LookupResult { bool isTemplateNameLookup() const { return TemplateNameLookup; } bool isAmbiguous() const { - return getResultKind() == Ambiguous; + return getResultKind() == LookupResultKind::Ambiguous; } /// Determines if this names a single result which is not an /// unresolved value using decl. If so, it is safe to call /// getFoundDecl(). bool isSingleResult() const { - return getResultKind() == Found; + return getResultKind() == LookupResultKind::Found; } /// Determines if the results are overloaded. bool isOverloadedResult() const { - return getResultKind() == FoundOverloaded; + return getResultKind() == LookupResultKind::FoundOverloaded; } bool isUnresolvableResult() const { - return getResultKind() == FoundUnresolvedValue; + return getResultKind() == LookupResultKind::FoundUnresolvedValue; } LookupResultKind getResultKind() const { @@ -480,29 +480,29 @@ class LookupResult { /// Does not test the acceptance criteria. void addDecl(NamedDecl *D, AccessSpecifier AS) { Decls.addDecl(D, AS); - ResultKind = Found; + ResultKind = LookupResultKind::Found; } /// Add all the declarations from another set of lookup /// results. void addAllDecls(const LookupResult &Other) { Decls.append(Other.Decls.begin(), Other.Decls.end()); - ResultKind = Found; + ResultKind = LookupResultKind::Found; } /// Determine whether no result was found because we could not /// search into dependent base classes of the current instantiation. bool wasNotFoundInCurrentInstantiation() const { - return ResultKind == NotFoundInCurrentInstantiation; + return ResultKind == LookupResultKind::NotFoundInCurrentInstantiation; } /// Note that while no result was found in the current instantiation, /// there were dependent base classes that could not be searched. void setNotFoundInCurrentInstantiation() { - assert((ResultKind == NotFound || - ResultKind == NotFoundInCurrentInstantiation) && + assert((ResultKind == LookupResultKind::NotFound || + ResultKind == LookupResultKind::NotFoundInCurrentInstantiation) && Decls.empty()); - ResultKind = NotFoundInCurrentInstantiation; + ResultKind = LookupResultKind::NotFoundInCurrentInstantiation; } /// Determine whether the lookup result was shadowed by some other @@ -524,8 +524,8 @@ class LookupResult { /// removals has been performed. void resolveKindAfterFilter() { if (Decls.empty()) { - if (ResultKind != NotFoundInCurrentInstantiation) - ResultKind = NotFound; + if (ResultKind != LookupResultKind::NotFoundInCurrentInstantiation) + ResultKind = LookupResultKind::NotFound; if (Paths) { deletePaths(Paths); @@ -534,16 +534,16 @@ class LookupResult { } else { std::optional<LookupAmbiguityKind> SavedAK; bool WasAmbiguous = false; - if (ResultKind == Ambiguous) { + if (ResultKind == LookupResultKind::Ambiguous) { SavedAK = Ambiguity; WasAmbiguous = true; } - ResultKind = Found; + ResultKind = LookupResultKind::Found; resolveKind(); // If we didn't make the lookup unambiguous, restore the old // ambiguity kind. - if (ResultKind == Ambiguous) { + if (ResultKind == LookupResultKind::Ambiguous) { (void)WasAmbiguous; assert(WasAmbiguous); Ambiguity = *SavedAK; @@ -556,7 +556,8 @@ class LookupResult { template <class DeclClass> DeclClass *getAsSingle() const { - if (getResultKind() != Found) return nullptr; + if (getResultKind() != LookupResultKind::Found) + return nullptr; return dyn_cast<DeclClass>(getFoundDecl()); } @@ -566,8 +567,8 @@ class LookupResult { /// This is intended for users who have examined the result kind /// and are certain that there is only one result. NamedDecl *getFoundDecl() const { - assert(getResultKind() == Found - && "getFoundDecl called on non-unique result"); + assert(getResultKind() == LookupResultKind::Found && + "getFoundDecl called on non-unique result"); return (*begin())->getUnderlyingDecl(); } @@ -579,7 +580,8 @@ class LookupResult { /// Asks if the result is a single tag decl. bool isSingleTagDecl() const { - return getResultKind() == Found && isa<TagDecl>(getFoundDecl()); + return getResultKind() == LookupResultKind::Found && + isa<TagDecl>(getFoundDecl()); } /// Make these results show that the name was found in @@ -603,7 +605,7 @@ class LookupResult { /// Clears out any current state. LLVM_ATTRIBUTE_REINITIALIZES void clear() { - ResultKind = NotFound; + ResultKind = LookupResultKind::NotFound; Decls.clear(); if (Paths) deletePaths(Paths); Paths = nullptr; @@ -770,7 +772,7 @@ class LookupResult { } void setAmbiguous(LookupAmbiguityKind AK) { - ResultKind = Ambiguous; + ResultKind = LookupResultKind::Ambiguous; Ambiguity = AK; } @@ -789,7 +791,7 @@ class LookupResult { static void deletePaths(CXXBasePaths *); // Results. - LookupResultKind ResultKind = NotFound; + LookupResultKind ResultKind = LookupResultKind::NotFound; // ill-defined unless ambiguous. Still need to be initialized it will be // copied/moved. LookupAmbiguityKind Ambiguity = {}; diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index b0ebf3e5f47c3..fd587c86de84d 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -418,7 +418,7 @@ ParsedType Sema::getTypeName(const IdentifierInfo &II, SourceLocation NameLoc, NamedDecl *IIDecl = nullptr; UsingShadowDecl *FoundUsingShadow = nullptr; switch (Result.getResultKind()) { - case LookupResult::NotFound: + case LookupResultKind::NotFound: if (CorrectedII) { TypeNameValidatorCCC CCC(/*AllowInvalid=*/true, isClassName, AllowDeducedTemplate); @@ -460,7 +460,7 @@ ParsedType Sema::getTypeName(const IdentifierInfo &II, SourceLocation NameLoc, } Result.suppressDiagnostics(); return nullptr; - case LookupResult::NotFoundInCurrentInstantiation: + case LookupResultKind::NotFoundInCurrentInstantiation: if (AllowImplicitTypename == ImplicitTypenameContext::Yes) { QualType T = Context.getDependentNameType(ElaboratedTypeKeyword::None, SS->getScopeRep(), &II); @@ -472,12 +472,12 @@ ParsedType Sema::getTypeName(const IdentifierInfo &II, SourceLocation NameLoc, return CreateParsedType(T, TLB.getTypeSourceInfo(Context, T)); } [[fallthrough]]; - case LookupResult::FoundOverloaded: - case LookupResult::FoundUnresolvedValue: + case LookupResultKind::FoundOverloaded: + case LookupResultKind::FoundUnresolvedValue: Result.suppressDiagnostics(); return nullptr; - case LookupResult::Ambiguous: + case LookupResultKind::Ambiguous: // Recover from type-hiding ambiguities by hiding the type. We'll // do the lookup again when looking for an object, and we can // diagnose the error then. If we don't do this, then the error @@ -521,7 +521,7 @@ ParsedType Sema::getTypeName(const IdentifierInfo &II, SourceLocation NameLoc, // perform the name lookup again. break; - case LookupResult::Found: + case LookupResultKind::Found: IIDecl = Result.getFoundDecl(); FoundUsingShadow = dyn_cast<UsingShadowDecl>(*Result.begin()); break; @@ -657,7 +657,7 @@ DeclSpec::TST Sema::isTagName(IdentifierInfo &II, Scope *S) { LookupResult R(*this, &II, SourceLocation(), LookupTagName); LookupName(R, S, false); R.suppressDiagnostics(); - if (R.getResultKind() == LookupResult::Found) + if (R.getResultKind() == LookupResultKind::Found) if (const TagDecl *TD = R.getAsSingle<TagDecl>()) { switch (TD->getTagKind()) { case TagTypeKind::Struct: @@ -926,7 +926,7 @@ Sema::NameClassification Sema::ClassifyName(Scope *S, CXXScopeSpec &SS, Corrected: switch (Result.getResultKind()) { - case LookupResult::NotFound: + case LookupResultKind::NotFound: // If an unqualified-id is followed by a '(', then we have a function // call. if (SS.isEmpty() && NextToken.is(tok::l_paren)) { @@ -1043,7 +1043,7 @@ Sema::NameClassification Sema::ClassifyName(Scope *S, CXXScopeSpec &SS, Result.suppressDiagnostics(); return NameClassification::Unknown(); - case LookupResult::NotFoundInCurrentInstantiation: { + case LookupResultKind::NotFoundInCurrentInstantiation: { // We performed name lookup into the current instantiation, and there were // dependent bases, so we treat this result the same way as any other // dependent nested-name-specifier. @@ -1061,12 +1061,12 @@ Sema::NameClassification Sema::ClassifyName(Scope *S, CXXScopeSpec &SS, return NameClassification::DependentNonType(); } - case LookupResult::Found: - case LookupResult::FoundOverloaded: - case LookupResult::FoundUnresolvedValue: + case LookupResultKind::Found: + case LookupResultKind::FoundOverloaded: + case LookupResultKind::FoundUnresolvedValue: break; - case LookupResult::Ambiguous: + case LookupResultKind::Ambiguous: if (getLangOpts().CPlusPlus && NextToken.is(tok::less) && hasAnyAcceptableTemplateNames(Result, /*AllowFunctionTemplates=*/true, /*AllowDependent=*/false)) { @@ -1498,11 +1498,11 @@ static bool AllowOverloadingOfFunction(const LookupResult &Previous, // to check at least two; hence the 'any_of' check below. Note that // the overloadable attribute is implicitly added to declarations // that were required to have it but did not. - if (Previous.getResultKind() == LookupResult::FoundOverloaded) { + if (Previous.getResultKind() == LookupResultKind::FoundOverloaded) { return llvm::any_of(Previous, [](const NamedDecl *ND) { return ND->hasAttr<OverloadableAttr>(); }); - } else if (Previous.getResultKind() == LookupResult::Found) + } else if (Previous.getResultKind() == LookupResultKind::Found) return Previous.getFoundDecl()->hasAttr<OverloadableAttr>(); return false; @@ -8290,7 +8290,7 @@ static SourceLocation getCaptureLocation(const LambdaScopeInfo *LSI, static bool shouldWarnIfShadowedDecl(const DiagnosticsEngine &Diags, const LookupResult &R) { // Only diagnose if we're shadowing an unambiguous field or variable. - if (R.getResultKind() != LookupResult::Found) + if (R.getResultKind() != LookupResultKind::Found) return false; // Return false if warning is ignored. @@ -10504,7 +10504,7 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC, // Recover gracefully from an invalid redeclaration. D.setRedeclaration(true); assert((NewFD->isInvalidDecl() || !D.isRedeclaration() || - Previous.getResultKind() != LookupResult::FoundOverloaded) && + Previous.getResultKind() != LookupResultKind::FoundOverloaded) && "previous declaration set still overloaded"); // Diagnose no-prototype function declarations with calling conventions that @@ -10671,7 +10671,7 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC, assert((NewFD->isInvalidDecl() || NewFD->isMultiVersion() || !D.isRedeclaration() || - Previous.getResultKind() != LookupResult::FoundOverloaded) && + Previous.getResultKind() != LookupResultKind::FoundOverloaded) && "previous declaration set still overloaded"); NamedDecl *PrincipalDecl = (FunctionTemplate @@ -18679,19 +18679,19 @@ FieldDecl *Sema::HandleField(Scope *S, RecordDecl *Record, RedeclarationKind::ForVisibleRedeclaration); LookupName(Previous, S); switch (Previous.getResultKind()) { - case LookupResult::Found: - case LookupResult::FoundUnresolvedValue: - PrevDecl = Previous.getAsSingle<NamedDecl>(); - break; + case LookupResultKind::Found: + case LookupResultKind::FoundUnresolvedValue: + PrevDecl = Previous.getAsSingle<NamedDecl>(); + break; - case LookupResult::FoundOverloaded: - PrevDecl = Previous.getRepresentativeDecl(); - break; + case LookupResultKind::FoundOverloaded: + PrevDecl = Previous.getRepresentativeDecl(); + break; - case LookupResult::NotFound: - case LookupResult::NotFoundInCurrentInstantiation: - case LookupResult::Ambiguous: - break; + case LookupResultKind::NotFound: + case LookupResultKind::NotFoundInCurrentInstantiation: + case LookupResultKind::Ambiguous: + break; } Previous.suppressDiagnostics(); diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp index d4e48a14d13c2..6bf2dea3c75df 100644 --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -19569,18 +19569,18 @@ MSPropertyDecl *Sema::HandleMSProperty(Scope *S, RecordDecl *Record, RedeclarationKind::ForVisibleRedeclaration); LookupName(Previous, S); switch (Previous.getResultKind()) { - case LookupResult::Found: - case LookupResult::FoundUnresolvedValue: + case LookupResultKind::Found: + case LookupResultKind::FoundUnresolvedValue: PrevDecl = Previous.getAsSingle<NamedDecl>(); break; - case LookupResult::FoundOverloaded: + case LookupResultKind::FoundOverloaded: PrevDecl = Previous.getRepresentativeDecl(); break; - case LookupResult::NotFound: - case LookupResult::NotFoundInCurrentInstantiation: - case LookupResult::Ambiguous: + case LookupResultKind::NotFound: + case LookupResultKind::NotFoundInCurrentInstantiation: + case LookupResultKind::Ambiguous: break; } diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp index 72edb72ceb600..e6c6f57e6648b 100644 --- a/clang/lib/Sema/SemaExprCXX.cpp +++ b/clang/lib/Sema/SemaExprCXX.cpp @@ -9682,16 +9682,16 @@ Sema::CheckMicrosoftIfExistsSymbol(Scope *S, R.suppressDiagnostics(); switch (R.getResultKind()) { - case LookupResult::Found: - case LookupResult::FoundOverloaded: - case LookupResult::FoundUnresolvedValue: - case LookupResult::Ambiguous: + case LookupResultKind::Found: + case LookupResultKind::FoundOverloaded: + case LookupResultKind::FoundUnresolvedValue: + case LookupResultKind::Ambiguous: return IER_Exists; - case LookupResult::NotFound: + case LookupResultKind::NotFound: return IER_DoesNotExist; - case LookupResult::NotFoundInCurrentInstantiation: + case LookupResultKind::NotFoundInCurrentInstantiation: return IER_Dependent; } diff --git a/clang/lib/Sema/SemaExprObjC.cpp b/clang/lib/Sema/SemaExprObjC.cpp index 18d9d38eee92f..f731f9c198535 100644 --- a/clang/lib/Sema/SemaExprObjC.cpp +++ b/clang/lib/Sema/SemaExprObjC.cpp @@ -2297,7 +2297,7 @@ SemaObjC::getObjCMessageKind(Scope *S, IdentifierInfo *Name, SemaRef.LookupName(Result, S); switch (Result.getResultKind()) { - case LookupResult::NotFound: + case LookupResultKind::NotFound: // Normal name lookup didn't find anything. If we're in an // Objective-C method, look for ivars. If we find one, we're done! // FIXME: This is a hack. Ivar lookup should be part of normal @@ -2317,14 +2317,14 @@ SemaObjC::getObjCMessageKind(Scope *S, IdentifierInfo *Name, // Break out; we'll perform typo correction below. break; - case LookupResult::NotFoundInCurrentInstantiation: - case LookupResult::FoundOverloaded: - case LookupResult::FoundUnresolvedValue: - case LookupResult::Ambiguous: + case LookupResultKind::NotFoundInCurrentInstantiation: + case LookupResultKind::FoundOverloaded: + case LookupResultKind::FoundUnresolvedValue: + case LookupResultKind::Ambiguous: Result.suppressDiagnostics(); return ObjCInstanceMessage; - case LookupResult::Found: { + case LookupResultKind::Found: { // If the identifier is a class or not, and there is a trailing dot, // it's an instance message. if (HasTrailingDot) diff --git a/clang/lib/Sema/SemaLookup.cpp b/clang/lib/Sema/SemaLookup.cpp index 2e072320e45cc..80edc3c1bf3ce 100644 --- a/clang/lib/Sema/SemaLookup.cpp +++ b/clang/lib/Sema/SemaLookup.cpp @@ -330,18 +330,19 @@ void LookupResult::configure() { bool LookupResult::checkDebugAssumptions() const { // This function is never called by NDEBUG builds. - assert(ResultKind != NotFound || Decls.size() == 0); - assert(ResultKind != Found || Decls.size() == 1); - assert(ResultKind != FoundOverloaded || Decls.size() > 1 || + assert(ResultKind != LookupResultKind::NotFound || Decls.size() == 0); + assert(ResultKind != LookupResultKind::Found || Decls.size() == 1); + assert(ResultKind != LookupResultKind::FoundOverloaded || Decls.size() > 1 || (Decls.size() == 1 && isa<FunctionTemplateDecl>((*begin())->getUnderlyingDecl()))); - assert(ResultKind != FoundUnresolvedValue || checkUnresolved()); - assert(ResultKind != Ambiguous || Decls.size() > 1 || + assert(ResultKind != LookupResultKind::FoundUnresolvedValue || + checkUnresolved()); + assert(ResultKind != LookupResultKind::Ambiguous || Decls.size() > 1 || (Decls.size() == 1 && (Ambiguity == LookupAmbiguityKind::AmbiguousBaseSubobjects || Ambiguity == LookupAmbiguityKind::AmbiguousBaseSubobjectTypes))); assert((Paths != nullptr) == - (ResultKind == Ambiguous && + (ResultKind == LookupResultKind::Ambiguous && (Ambiguity == LookupAmbiguityKind::AmbiguousBaseSubobjectTypes || Ambiguity == LookupAmbiguityKind::AmbiguousBaseSubobjects))); return true; @@ -488,8 +489,8 @@ void LookupResult::resolveKind() { // Fast case: no possible ambiguity. if (N == 0) { - assert(ResultKind == NotFound || - ResultKind == NotFoundInCurrentInstantiation); + assert(ResultKind == LookupResultKind::NotFound || + ResultKind == LookupResultKind::NotFoundInCurrentInstantiation); return; } @@ -498,14 +499,15 @@ void LookupResult::resolveKind() { if (N == 1) { const NamedDecl *D = (*Decls.begin())->getUnderlyingDecl(); if (isa<FunctionTemplateDecl>(D)) - ResultKind = FoundOverloaded; + ResultKind = LookupResultKind::FoundOverloaded; else if (isa<UnresolvedUsingValueDecl>(D)) - ResultKind = FoundUnresolvedValue; + ResultKind = LookupResultKind::FoundUnresolvedValue; return; } // Don't do any extra resolution if we've already resolved as ambiguous. - if (ResultKind == Ambiguous) return; + if (ResultKind == LookupResultKind::Ambiguous) + return; llvm::SmallDenseMap<const NamedDecl *, unsigned, 16> Unique; llvm::SmallDenseMap<QualType, unsigned, 16> UniqueTypes; @@ -647,11 +649,11 @@ void LookupResult::resolveKind() { else if (Ambiguous) setAmbiguous(LookupAmbiguityKind::AmbiguousReference); else if (HasUnresolved) - ResultKind = LookupResult::FoundUnresolvedValue; + ResultKind = LookupResultKind::FoundUnresolvedValue; else if (N > 1 || HasFunctionTemplate) - ResultKind = LookupResult::FoundOverloaded; + ResultKind = LookupResultKind::FoundOverloaded; else - ResultKind = LookupResult::Found; + ResultKind = LookupResultKind::Found; } void LookupResult::addDeclsFromBasePaths(const CXXBasePaths &P) { @@ -983,7 +985,7 @@ static void LookupPredefedObjCSuperType(Sema &Sema, Scope *S) { LookupResult Result(Sema, &Context.Idents.get("objc_super"), SourceLocation(), Sema::LookupTagName); Sema.LookupName(Result, S); - if (Result.getResultKind() == LookupResult::Found) + if (Result.getResultKind() == LookupResultKind::Found) if (const TagDecl *TD = Result.getAsSingle<TagDecl>()) Context.setObjCSuperType(Context.getTagDeclType(TD)); } @@ -3655,7 +3657,7 @@ Sema::LookupLiteralOperator(Scope *S, LookupResult &R, bool AllowTemplate, bool AllowStringTemplatePack, bool DiagnoseMissing, StringLiteral *StringLit) { LookupName(R, S); - assert(R.getResultKind() != LookupResult::Ambiguous && + assert(R.getResultKind() != LookupResultKind::Ambiguous && "literal operator lookup can't be ambiguous"); // Filter the lookup results appropriately. @@ -4732,9 +4734,9 @@ bool TypoCorrectionConsumer::resolveCorrection(TypoCorrection &Candidate) { CorrectionValidator->IsObjCIvarLookup, Name == Typo && !Candidate.WillReplaceSpecifier()); switch (Result.getResultKind()) { - case LookupResult::NotFound: - case LookupResult::NotFoundInCurrentInstantiation: - case LookupResult::FoundUnresolvedValue: + case LookupResultKind::NotFound: + case LookupResultKind::NotFoundInCurrentInstantiation: + case LookupResultKind::FoundUnresolvedValue: if (TempSS) { // Immediately retry the lookup without the given CXXScopeSpec TempSS = nullptr; @@ -4751,12 +4753,12 @@ bool TypoCorrectionConsumer::resolveCorrection(TypoCorrection &Candidate) { QualifiedResults.push_back(Candidate); break; - case LookupResult::Ambiguous: + case LookupResultKind::Ambiguous: // We don't deal with ambiguities. break; - case LookupResult::Found: - case LookupResult::FoundOverloaded: + case LookupResultKind::Found: + case LookupResultKind::FoundOverloaded: // Store all of the Decls for overloaded symbols for (auto *TRD : Result) Candidate.addCorrectionDecl(TRD); @@ -4811,8 +4813,8 @@ void TypoCorrectionConsumer::performQualifiedLookups() { // Any corrections added below will be validated in subsequent // iterations of the main while() loop over the Consumer's contents. switch (Result.getResultKind()) { - case LookupResult::Found: - case LookupResult::FoundOverloaded: { + case LookupResultKind::Found: + case LookupResultKind::FoundOverloaded: { if (SS && SS->isValid()) { std::string NewQualified = TC.getAsString(SemaRef.getLangOpts()); std::string OldQualified; @@ -4839,10 +4841,10 @@ void TypoCorrectionConsumer::performQualifiedLookups() { } break; } - case LookupResult::NotFound: - case LookupResult::NotFoundInCurrentInstantiation: - case LookupResult::Ambiguous: - case LookupResult::FoundUnresolvedValue: + case LookupResultKind::NotFound: + case LookupResultKind::NotFoundInCurrentInstantiation: + case LookupResultKind::Ambiguous: + case LookupResultKind::FoundUnresolvedValue: break; } } diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp index 894f072d84989..b1490f9311723 100644 --- a/clang/lib/Sema/SemaTemplate.cpp +++ b/clang/lib/Sema/SemaTemplate.cpp @@ -10889,7 +10889,7 @@ Sema::CheckTypenameType(ElaboratedTypeKeyword Keyword, unsigned DiagID = 0; Decl *Referenced = nullptr; switch (Result.getResultKind()) { - case LookupResult::NotFound: { + case LookupResultKind::NotFound: { // If we're looking up 'type' within a template named 'enable_if', produce // a more specific diagnostic. SourceRange CondRange; @@ -10921,7 +10921,7 @@ Sema::CheckTypenameType(ElaboratedTypeKeyword Keyword, break; } - case LookupResult::FoundUnresolvedValue: { + case LookupResultKind::FoundUnresolvedValue: { // We found a using declaration that is a value. Most likely, the using // declaration itself is meant to have the 'typename' keyword. SourceRange FullRange(KeywordLoc.isValid() ? KeywordLoc : SS.getBeginLoc(), @@ -10935,17 +10935,17 @@ Sema::CheckTypenameType(ElaboratedTypeKeyword Keyword, << FixItHint::CreateInsertion(Loc, "typename "); } } - // Fall through to create a dependent typename type, from which we can recover - // better. - [[fallthrough]]; + // Fall through to create a dependent typename type, from which we can + // recover better. + [[fallthrough]]; - case LookupResult::NotFoundInCurrentInstantiation: + case LookupResultKind::NotFoundInCurrentInstantiation: // Okay, it's a member of an unknown instantiation. return Context.getDependentNameType(Keyword, QualifierLoc.getNestedNameSpecifier(), &II); - case LookupResult::Found: + case LookupResultKind::Found: if (TypeDecl *Type = dyn_cast<TypeDecl>(Result.getFoundDecl())) { // C++ [class.qual]p2: // In a lookup in which function names are not ignored and the @@ -11003,13 +11003,13 @@ Sema::CheckTypenameType(ElaboratedTypeKeyword Keyword, Referenced = Result.getFoundDecl(); break; - case LookupResult::FoundOverloaded: + case LookupResultKind::FoundOverloaded: DiagID = Ctx ? diag::err_typename_nested_not_type : diag::err_typename_not_type; Referenced = *Result.begin(); break; - case LookupResult::Ambiguous: + case LookupResultKind::Ambiguous: return QualType(); } diff --git a/clang/lib/Sema/SemaTemplateVariadic.cpp b/clang/lib/Sema/SemaTemplateVariadic.cpp index 34fec069d6df6..cfa8d4d6a2fb4 100644 --- a/clang/lib/Sema/SemaTemplateVariadic.cpp +++ b/clang/lib/Sema/SemaTemplateVariadic.cpp @@ -1149,12 +1149,12 @@ ExprResult Sema::ActOnSizeofParameterPackExpr(Scope *S, NamedDecl *ParameterPack = nullptr; switch (R.getResultKind()) { - case LookupResult::Found: + case LookupResultKind::Found: ParameterPack = R.getFoundDecl(); break; - case LookupResult::NotFound: - case LookupResult::NotFoundInCurrentInstantiation: { + case LookupResultKind::NotFound: + case LookupResultKind::NotFoundInCurrentInstantiation: { ParameterPackValidatorCCC CCC{}; if (TypoCorrection Corrected = CorrectTypo(R.getLookupNameInfo(), R.getLookupKind(), S, nullptr, @@ -1166,11 +1166,11 @@ ExprResult Sema::ActOnSizeofParameterPackExpr(Scope *S, } break; } - case LookupResult::FoundOverloaded: - case LookupResult::FoundUnresolvedValue: + case LookupResultKind::FoundOverloaded: + case LookupResultKind::FoundUnresolvedValue: break; - case LookupResult::Ambiguous: + case LookupResultKind::Ambiguous: DiagnoseAmbiguousLookup(R); return ExprError(); } diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h index 5e83f83603335..b6af919463124 100644 --- a/clang/lib/Sema/TreeTransform.h +++ b/clang/lib/Sema/TreeTransform.h @@ -1194,21 +1194,21 @@ class TreeTransform { TagDecl *Tag = nullptr; SemaRef.LookupQualifiedName(Result, DC); switch (Result.getResultKind()) { - case LookupResult::NotFound: - case LookupResult::NotFoundInCurrentInstantiation: - break; + case LookupResultKind::NotFound: + case LookupResultKind::NotFoundInCurrentInstantiation: + break; - case LookupResult::Found: - Tag = Result.getAsSingle<TagDecl>(); - break; + case LookupResultKind::Found: + Tag = Result.getAsSingle<TagDecl>(); + break; - case LookupResult::FoundOverloaded: - case LookupResult::FoundUnresolvedValue: - llvm_unreachable("Tag lookup cannot find non-tags"); + case LookupResultKind::FoundOverloaded: + case LookupResultKind::FoundUnresolvedValue: + llvm_unreachable("Tag lookup cannot find non-tags"); - case LookupResult::Ambiguous: - // Let the LookupResult structure handle ambiguities. - return QualType(); + case LookupResultKind::Ambiguous: + // Let the LookupResult structure handle ambiguities. + return QualType(); } if (!Tag) { @@ -1217,16 +1217,16 @@ class TreeTransform { LookupResult Result(SemaRef, Id, IdLoc, Sema::LookupTagName); SemaRef.LookupQualifiedName(Result, DC); switch (Result.getResultKind()) { - case LookupResult::Found: - case LookupResult::FoundOverloaded: - case LookupResult::FoundUnresolvedValue: { - NamedDecl *SomeDecl = Result.getRepresentativeDecl(); - Sema::NonTagKind NTK = SemaRef.getNonTagTypeDeclKind(SomeDecl, Kind); - SemaRef.Diag(IdLoc, diag::err_tag_reference_non_tag) - << SomeDecl << NTK << llvm::to_underlying(Kind); - SemaRef.Diag(SomeDecl->getLocation(), diag::note_declared_at); - break; - } + case LookupResultKind::Found: + case LookupResultKind::FoundOverloaded: + case LookupResultKind::FoundUnresolvedValue: { + NamedDecl *SomeDecl = Result.getRepresentativeDecl(); + Sema::NonTagKind NTK = SemaRef.getNonTagTypeDeclKind(SomeDecl, Kind); + SemaRef.Diag(IdLoc, diag::err_tag_reference_non_tag) + << SomeDecl << NTK << llvm::to_underlying(Kind); + SemaRef.Diag(SomeDecl->getLocation(), diag::note_declared_at); + break; + } default: SemaRef.Diag(IdLoc, diag::err_not_tag_in_scope) << llvm::to_underlying(Kind) << Id << DC diff --git a/clang/utils/ClangVisualizers/clang.natvis b/clang/utils/ClangVisualizers/clang.natvis index a7c70186bc46d..3ecd93902d1bb 100644 --- a/clang/utils/ClangVisualizers/clang.natvis +++ b/clang/utils/ClangVisualizers/clang.natvis @@ -1069,7 +1069,7 @@ For later versions of Visual Studio, no setup is required--> </Expand> </Type> <Type Name="clang::LookupResult"> - <DisplayString Condition="ResultKind == clang::LookupResult::Ambiguous">{Ambiguity,en}: {Decls}</DisplayString> + <DisplayString Condition="ResultKind == clang::LookupResultKind::Ambiguous">{Ambiguity,en}: {Decls}</DisplayString> <DisplayString>{ResultKind,en}: {Decls}</DisplayString> </Type> <Type Name="clang::ActionResult<*, 0>"> _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits