diff options
author | Richard Smith <richard@metafoo.co.uk> | 2019-12-09 12:08:59 -0800 |
---|---|---|
committer | Richard Smith <richard@metafoo.co.uk> | 2019-12-09 12:18:33 -0800 |
commit | 56bba012d9729af8ff4252dc860f1f7696942f1a (patch) | |
tree | 6f28d32f8fb26d651ff5016a98bd2f6ad4dbfedf /clang/lib/AST | |
parent | d694594d7650571dec40cc0ef9db6087963d62a0 (diff) | |
download | bcm5719-llvm-56bba012d9729af8ff4252dc860f1f7696942f1a.tar.gz bcm5719-llvm-56bba012d9729af8ff4252dc860f1f7696942f1a.zip |
[c++20] Fix incorrect assumptions in checks for comparison category types.
In the presence of modules, we can have multiple lookup results for the
same entity, and we need to re-check for completeness each time we
consider a type.
Diffstat (limited to 'clang/lib/AST')
-rw-r--r-- | clang/lib/AST/ComparisonCategories.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/clang/lib/AST/ComparisonCategories.cpp b/clang/lib/AST/ComparisonCategories.cpp index 8999913b728..3fb500c580e 100644 --- a/clang/lib/AST/ComparisonCategories.cpp +++ b/clang/lib/AST/ComparisonCategories.cpp @@ -59,7 +59,7 @@ ComparisonCategoryInfo::ValueInfo *ComparisonCategoryInfo::lookupValueInfo( // a new entry representing it. DeclContextLookupResult Lookup = Record->getCanonicalDecl()->lookup( &Ctx.Idents.get(ComparisonCategories::getResultString(ValueKind))); - if (Lookup.size() != 1 || !isa<VarDecl>(Lookup.front())) + if (Lookup.empty() || !isa<VarDecl>(Lookup.front())) return nullptr; Objects.emplace_back(ValueKind, cast<VarDecl>(Lookup.front())); return &Objects.back(); @@ -70,7 +70,7 @@ static const NamespaceDecl *lookupStdNamespace(const ASTContext &Ctx, if (!StdNS) { DeclContextLookupResult Lookup = Ctx.getTranslationUnitDecl()->lookup(&Ctx.Idents.get("std")); - if (Lookup.size() == 1) + if (!Lookup.empty()) StdNS = dyn_cast<NamespaceDecl>(Lookup.front()); } return StdNS; @@ -81,7 +81,7 @@ static CXXRecordDecl *lookupCXXRecordDecl(const ASTContext &Ctx, ComparisonCategoryType Kind) { StringRef Name = ComparisonCategories::getCategoryString(Kind); DeclContextLookupResult Lookup = StdNS->lookup(&Ctx.Idents.get(Name)); - if (Lookup.size() == 1) + if (!Lookup.empty()) if (CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(Lookup.front())) return RD; return nullptr; |