summaryrefslogtreecommitdiffstats
path: root/clang/unittests/AST/StructuralEquivalenceTest.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [AST] AST structural equivalence to work internally with pairs.Balazs Keri2019-09-021-0/+122
| | | | | | | | | | | | | | | | | | | | | Summary: The structural equivalence check stores now pairs of nodes in the 'from' and 'to' context instead of only the node in 'from' context and a corresponding one in 'to' context. This is needed to handle cases when a Decl in the 'from' context is to be compared with multiple Decls in the 'to' context. Reviewers: martong, a_sidorin Reviewed By: martong, a_sidorin Subscribers: rnkovacs, dkrupp, Szelethus, gamesh411, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D66538 llvm-svn: 370639
* [ASTImporter] Fix inequivalence of ClassTemplateInstantiationsGabor Marton2019-07-231-0/+192
| | | | | | | | | | | | | | | | | | Summary: We falsely state inequivalence if the template parameter is a qualified/nonquialified template in the first/second instantiation. Also, different kinds of TemplateName should be equal if the template decl (if available) is equal (even if the name kind is different). Reviewers: a_sidorin, a.sidorin Subscribers: rnkovacs, dkrupp, Szelethus, gamesh411, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D64241 llvm-svn: 366818
* [ASTImporter] Fix structural eq of lambdasGabor Marton2019-07-171-0/+52
| | | | | | | | | | | | | | | | | | 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
* [ASTImporter] Structural eq: handle DependentScopeDeclRefExprGabor Marton2019-07-021-0/+138
| | | | | | | | | | | | | | | | Summary: Structural equivalence did not handle dependent template args properly when the arg contained a DependentScopeDeclRefExpr. Reviewers: a_sidorin, a.sidorin Subscribers: rnkovacs, dkrupp, Szelethus, gamesh411, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D62329 llvm-svn: 364889
* [ASTImporter] Enable disabled but passing testsGabor Marton2019-05-201-2/+1
| | | | | | | | | | | | Reviewers: a_sidorin, a.sidorin, shafik Subscribers: rnkovacs, dkrupp, Szelethus, gamesh411, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D62066 llvm-svn: 361139
* [c++20] Add support for explicit(bool), as described in P0892R2.Richard Smith2019-05-091-0/+40
| | | | | | | | Patch by Tyker! Differential Revision: https://reviews.llvm.org/D60934 llvm-svn: 360311
* Revert r359949 "[clang] adding explicit(bool) from c++2a"Hans Wennborg2019-05-061-40/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This caused Clang to start erroring on the following: struct S {   template <typename = int> explicit S(); }; struct T : S {}; struct U : T {   U(); }; U::U() {} $ clang -c /tmp/x.cc /tmp/x.cc:10:4: error: call to implicitly-deleted default constructor of 'T' U::U() {}    ^ /tmp/x.cc:5:12: note: default constructor of 'T' is implicitly deleted because base class 'S' has no default constructor struct T : S {};            ^ 1 error generated. See discussion on the cfe-commits email thread. This also reverts the follow-ups r359966 and r359968. > this patch adds support for the explicit bool specifier. > > Changes: > - The parsing for the explicit(bool) specifier was added in ParseDecl.cpp. > - The storage of the explicit specifier was changed. the explicit specifier was stored as a boolean value in the FunctionDeclBitfields and in the DeclSpec class. now it is stored as a PointerIntPair<Expr*, 2> with a flag and a potential expression in CXXConstructorDecl, CXXDeductionGuideDecl, CXXConversionDecl and in the DeclSpec class. > - Following the AST change, Serialization, ASTMatchers, ASTComparator and ASTPrinter were adapted. > - Template instantiation was adapted to instantiate the potential expressions of the explicit(bool) specifier When instantiating their associated declaration. > - The Add*Candidate functions were adapted, they now take a Boolean indicating if the context allowing explicit constructor or conversion function and this boolean is used to remove invalid overloads that required template instantiation to be detected. > - Test for Semantic and Serialization were added. > > This patch is not yet complete. I still need to check that interaction with CTAD and deduction guides is correct. and add more tests for AST operations. But I wanted first feedback. > Perhaps this patch should be spited in smaller patches, but making each patch testable as a standalone may be tricky. > > Patch by Tyker > > Differential Revision: https://reviews.llvm.org/D60934 llvm-svn: 360024
* [clang] adding explicit(bool) from c++2aNicolas Lesser2019-05-041-0/+40
| | | | | | | | | | | | | | | | | | | | | this patch adds support for the explicit bool specifier. Changes: - The parsing for the explicit(bool) specifier was added in ParseDecl.cpp. - The storage of the explicit specifier was changed. the explicit specifier was stored as a boolean value in the FunctionDeclBitfields and in the DeclSpec class. now it is stored as a PointerIntPair<Expr*, 2> with a flag and a potential expression in CXXConstructorDecl, CXXDeductionGuideDecl, CXXConversionDecl and in the DeclSpec class. - Following the AST change, Serialization, ASTMatchers, ASTComparator and ASTPrinter were adapted. - Template instantiation was adapted to instantiate the potential expressions of the explicit(bool) specifier When instantiating their associated declaration. - The Add*Candidate functions were adapted, they now take a Boolean indicating if the context allowing explicit constructor or conversion function and this boolean is used to remove invalid overloads that required template instantiation to be detected. - Test for Semantic and Serialization were added. This patch is not yet complete. I still need to check that interaction with CTAD and deduction guides is correct. and add more tests for AST operations. But I wanted first feedback. Perhaps this patch should be spited in smaller patches, but making each patch testable as a standalone may be tricky. Patch by Tyker Differential Revision: https://reviews.llvm.org/D60934 llvm-svn: 359949
* [AST] Fix structural inequivalence of operatorsGabor Marton2019-02-081-0/+27
| | | | | | | | | | | | | | Summary: Operators kind was not checked, so we reported e.g. op- to be equal with op+ Reviewers: shafik, a_sidorin, aaron.ballman Subscribers: rnkovacs, dkrupp, Szelethus, gamesh411, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D57902 llvm-svn: 353504
* [ASTImporter] Fix up test that only works on X86.David Green2019-02-021-3/+7
| | | | | | | | The test will fail if the default target triple is not X86, even if the host platform is. So move the check into the test at runtime. llvm-svn: 352956
* [AST] Add structural eq tests for template argsGabor Marton2019-01-281-0/+19
| | | | | | | | | | | | | | Summary: New tests added to verify equivalency of templates when their parameters are different. Reviewers: a_sidorin, shafik Subscribers: rnkovacs, dkrupp, Szelethus, gamesh411, cfe-commits Differential Revision: https://reviews.llvm.org/D57235 llvm-svn: 352345
* Fix failing buildbotsGabor Marton2019-01-241-2/+2
| | | | | | | | | Fix remaining unittest errors caused by __attribute__((no_caller_saved_registers)) Related commit which caused the buildbots to fail: rL352050 llvm-svn: 352060
* Fix failing buildbotsGabor Marton2019-01-241-1/+4
| | | | | | | Related commit which caused the buildbots to fail: rL352050 llvm-svn: 352055
* [ASTImporter] Fix inequality of functions with different attributesGabor Marton2019-01-241-0/+25
| | | | | | | | | | | | | | | | Summary: FunctionType::ExtInfo holds such properties of a function which are needed mostly for code gen. We should not compare these bits when checking for structural equivalency. Checking ExtInfo caused false ODR errors during CTU analysis (of tmux). Reviewers: a_sidorin, a.sidorin, shafik Subscribers: rnkovacs, dkrupp, Szelethus, cfe-commits Differential Revision: https://reviews.llvm.org/D53699 llvm-svn: 352050
* [ASTImporter] Fix redecl chain of classes and class templatesGabor Marton2018-12-171-0/+71
| | | | | | | | | | | | | | | | | | | | | | | | Summary: The crux of the issue that is being fixed is that lookup could not find previous decls of a friend class. The solution involves making the friend declarations visible in their decl context (i.e. adding them to the lookup table). Also, we simplify `VisitRecordDecl` greatly. This fix involves two other repairs (without these the unittests fail): (1) We could not handle the addition of injected class types properly when a redecl chain was involved, now this is fixed. (2) DeclContext::removeDecl failed if the lookup table in Vector form did not contain the to be removed element. This caused troubles in ASTImporter::ImportDeclContext. This is also fixed. Reviewers: a_sidorin, balazske, a.sidorin Subscribers: rnkovacs, dkrupp, Szelethus, cfe-commits Differential Revision: https://reviews.llvm.org/D53655 llvm-svn: 349349
* Fix structural inequivalency of forward EnumDeclGabor Marton2018-08-091-0/+54
| | | | | | | | | | | | | | Summary: Currently we consider one forward declared RecordDecl and another with a definition equal. We have to do the same in case of enums. Reviewers: a_sidorin, r.stahl, xazax.hun Subscribers: rnkovacs, dkrupp, cfe-commits Differential Revision: https://reviews.llvm.org/D50444 llvm-svn: 339336
* [AST] Check described template at structural equivalence check.Balazs Keri2018-08-081-5/+28
| | | | | | | | | | | | | | | | | | | | Summary: When checking a class or function the described class or function template is checked too. Split StructuralEquivalenceContext::Finish into multiple functions. Improved test with symmetric check, added new tests. Reviewers: martong, a.sidorin, a_sidorin, bruno Reviewed By: martong, a.sidorin Subscribers: rnkovacs, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D49223 llvm-svn: 339256
* [ASTImporter] Fix poisonous structural equivalence cacheGabor Marton2018-07-171-1/+1
| | | | | | | | | | | | | | | | | | | | | Summary: Implementation functions call into the member functions of ASTStructuralEquivalence, thus they can falsely alter the DeclsToCheck state (they add decls). This results that some leaf declarations can be stated as inequivalent as a side effect of one inequivalent element in the DeclsToCheck list. And since we store the non-equivalencies, any (otherwise independent) decls will be rendered as non-equivalent. Solution: I tried to clearly separate the implementation functions (the static ones) and the public interface. From now on, the implementation functions do not call any public member functions, only other implementation functions. Reviewers: a.sidorin, a_sidorin, r.stahl Subscribers: rnkovacs, dkrupp, cfe-commits Differential Revision: https://reviews.llvm.org/D49300 llvm-svn: 337275
* [ASTImporter] Fix import of unnamed structsGabor Marton2018-07-171-2/+86
| | | | | | | | | | | | | | | Summary: D48773 simplified ASTImporter nicely, but it introduced a new error: Unnamed structs are not imported correctly, if they appear in a recursive context. This patch provides a fix for structural equivalency. Reviewers: a.sidorin, a_sidorin, balazske, gerazo Subscribers: rnkovacs, dkrupp, cfe-commits Differential Revision: https://reviews.llvm.org/D49296 llvm-svn: 337267
* [ASTImporter] Refactor Decl creationGabor Marton2018-07-121-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Generalize the creation of Decl nodes during Import. With this patch we do the same things after and before a new AST node is created (::Create) The import logic should be really simple, we create the node, then we mark that as imported, then we recursively import the parts for that node and then set them on that node. However, the AST is actually a graph, so we have to handle circles. If we mark something as imported (`MapImported()`) then we return with the corresponding `To` decl whenever we want to import that node again, this way circles are handled. In order to make this algorithm work we must ensure things, which are handled in the generic CreateDecl<> template: * There are no `Import()` calls in between any node creation (::Create) and the `MapImported()` call. * Before actually creating an AST node (::Create), we must check if the Node had been imported already, if yes then return with that one. One very important case for this is connected to templates: we may start an import both from the templated decl of a template and from the template itself. Now, the virtual `Imported` function is called in `ASTImporter::Impor(Decl *)`, but only once, when the `Decl` is imported. One point of this refactor is to separate responsibilities. The original `Imported()` had 3 responsibilities: - notify subclasses when an import happened - register the decl into `ImportedDecls` - initialise the Decl (set attributes, etc) Now all of these are in separate functions: - `Imported` - `MapImported` - `InitializeImportedDecl` I tried to check all the clients, I executed tests for `ExternalASTMerger.cpp` and some unittests for lldb. Reviewers: a.sidorin, balazske, xazax.hun, r.stahl Subscribers: rnkovacs, dkrupp, cfe-commits Differential Revision: https://reviews.llvm.org/D47632 llvm-svn: 336896
* [AST] Fix for structural equivalence tests in rL336776.Balazs Keri2018-07-111-5/+6
| | | | llvm-svn: 336817
* [AST] Structural equivalence of methodsBalazs Keri2018-07-111-55/+393
| | | | | | | | | | | | | | | | | Summary: Added structural equivalence check for C++ methods. Improved structural equivalence tests. Added related ASTImporter tests. Reviewers: a.sidorin, szepet, xazax.hun, martong, a_sidorin Reviewed By: martong, a_sidorin Subscribers: a_sidorin, rnkovacs, cfe-commits Differential Revision: https://reviews.llvm.org/D48628 llvm-svn: 336776
* [ASTImporter] Add unit tests for structural equivalenceGabor Marton2018-05-241-0/+207
Summary: This patch add new tests for structural equivalence. For that a new common header is created which holds the test related language specific types and functions. Reviewers: a.sidorin, xazax.hun, szepet Subscribers: rnkovacs, dkrupp, cfe-commits Differential Revision: https://reviews.llvm.org/D46867 llvm-svn: 333166
OpenPOWER on IntegriCloud