diff options
| author | Richard Smith <richard-llvm@metafoo.co.uk> | 2018-08-02 20:30:52 +0000 |
|---|---|---|
| committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2018-08-02 20:30:52 +0000 |
| commit | 2425338bacc233566363ae37f97551e31f34ca3f (patch) | |
| tree | f9fa467c4871c0a2ce7627f977a7d0e723e96998 /clang/lib | |
| parent | db89ec1185c35c91b2b9fc58698e199e27458054 (diff) | |
| download | bcm5719-llvm-2425338bacc233566363ae37f97551e31f34ca3f.tar.gz bcm5719-llvm-2425338bacc233566363ae37f97551e31f34ca3f.zip | |
Fix assertion failure when emitting code for a merged lambda.
llvm-svn: 338766
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/AST/DeclCXX.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/clang/lib/AST/DeclCXX.cpp b/clang/lib/AST/DeclCXX.cpp index c43bdfb58f4..8582b543dfb 100644 --- a/clang/lib/AST/DeclCXX.cpp +++ b/clang/lib/AST/DeclCXX.cpp @@ -1327,6 +1327,15 @@ bool CXXRecordDecl::isGenericLambda() const { return getLambdaData().IsGenericLambda; } +#ifndef NDEBUG +static bool allLookupResultsAreTheSame(const DeclContext::lookup_result &R) { + for (auto *D : R) + if (!declaresSameEntity(D, R.front())) + return false; + return true; +} +#endif + CXXMethodDecl* CXXRecordDecl::getLambdaCallOperator() const { if (!isLambda()) return nullptr; DeclarationName Name = @@ -1334,7 +1343,8 @@ CXXMethodDecl* CXXRecordDecl::getLambdaCallOperator() const { DeclContext::lookup_result Calls = lookup(Name); assert(!Calls.empty() && "Missing lambda call operator!"); - assert(Calls.size() == 1 && "More than one lambda call operator!"); + assert(allLookupResultsAreTheSame(Calls) && + "More than one lambda call operator!"); NamedDecl *CallOp = Calls.front(); if (const auto *CallOpTmpl = dyn_cast<FunctionTemplateDecl>(CallOp)) @@ -1349,7 +1359,8 @@ CXXMethodDecl* CXXRecordDecl::getLambdaStaticInvoker() const { &getASTContext().Idents.get(getLambdaStaticInvokerName()); DeclContext::lookup_result Invoker = lookup(Name); if (Invoker.empty()) return nullptr; - assert(Invoker.size() == 1 && "More than one static invoker operator!"); + assert(allLookupResultsAreTheSame(Invoker) && + "More than one static invoker operator!"); NamedDecl *InvokerFun = Invoker.front(); if (const auto *InvokerTemplate = dyn_cast<FunctionTemplateDecl>(InvokerFun)) return cast<CXXMethodDecl>(InvokerTemplate->getTemplatedDecl()); |

