summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST
diff options
context:
space:
mode:
authorRichard Smith <richard@metafoo.co.uk>2019-12-09 12:08:59 -0800
committerRichard Smith <richard@metafoo.co.uk>2019-12-09 12:18:33 -0800
commit56bba012d9729af8ff4252dc860f1f7696942f1a (patch)
tree6f28d32f8fb26d651ff5016a98bd2f6ad4dbfedf /clang/lib/AST
parentd694594d7650571dec40cc0ef9db6087963d62a0 (diff)
downloadbcm5719-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.cpp6
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;
OpenPOWER on IntegriCloud