diff options
| author | Gabor Marton <gabor.marton@ericsson.com> | 2019-07-17 14:40:09 +0000 |
|---|---|---|
| committer | Gabor Marton <gabor.marton@ericsson.com> | 2019-07-17 14:40:09 +0000 |
| commit | ae512b83d5fc79fb96844ce7cfe4c6a4fee96c9a (patch) | |
| tree | de5d9f1e9394279ff59a3e2013f3199284599710 /clang/lib/AST | |
| parent | 80de11ed0216a232e224f4b01ab4eb818401f829 (diff) | |
| download | bcm5719-llvm-ae512b83d5fc79fb96844ce7cfe4c6a4fee96c9a.tar.gz bcm5719-llvm-ae512b83d5fc79fb96844ce7cfe4c6a4fee96c9a.zip | |
[ASTImporter] Fix structural eq of lambdas
Summary:
The structural equivalence check reported false eq between lambda classes
with different parameters in their call signature.
The solution is to check the methods for equality too in case of lambda
classes.
Reviewers: a_sidorin, a.sidorin
Subscribers: rnkovacs, dkrupp, Szelethus, gamesh411, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64075
llvm-svn: 366332
Diffstat (limited to 'clang/lib/AST')
| -rw-r--r-- | clang/lib/AST/ASTStructuralEquivalence.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/clang/lib/AST/ASTStructuralEquivalence.cpp b/clang/lib/AST/ASTStructuralEquivalence.cpp index bb2e353eeef..912db3c130c 100644 --- a/clang/lib/AST/ASTStructuralEquivalence.cpp +++ b/clang/lib/AST/ASTStructuralEquivalence.cpp @@ -1085,6 +1085,19 @@ static bool IsStructurallyEquivalent(StructuralEquivalenceContext &Context, return true; } +/// Determine structural equivalence of two lambda classes. +static bool +IsStructurallyEquivalentLambdas(StructuralEquivalenceContext &Context, + CXXRecordDecl *D1, CXXRecordDecl *D2) { + assert(D1->isLambda() && D2->isLambda() && + "Must be called on lambda classes"); + if (!IsStructurallyEquivalent(Context, D1->getLambdaCallOperator(), + D2->getLambdaCallOperator())) + return false; + + return true; +} + /// Determine structural equivalence of two records. static bool IsStructurallyEquivalent(StructuralEquivalenceContext &Context, RecordDecl *D1, RecordDecl *D2) { @@ -1166,6 +1179,13 @@ static bool IsStructurallyEquivalent(StructuralEquivalenceContext &Context, D1CXX->getASTContext().getExternalSource()->CompleteType(D1CXX); } + if (D1CXX->isLambda() != D2CXX->isLambda()) + return false; + if (D1CXX->isLambda()) { + if (!IsStructurallyEquivalentLambdas(Context, D1CXX, D2CXX)) + return false; + } + if (D1CXX->getNumBases() != D2CXX->getNumBases()) { if (Context.Complain) { Context.Diag2(D2->getLocation(), |

