summaryrefslogtreecommitdiffstats
path: root/clang/unittests/AST/ASTImporterTest.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Fix duplicate class template definitions problemGabor Marton2018-05-231-2/+128
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: We fail to import a `ClassTemplateDecl` if the "To" context already contains a definition and then a forward decl. This is because `localUncachedLookup` does not find the definition. This is not a lookup error, the parser behaves differently than assumed in the importer code. A `DeclContext` contains one DenseMap (`LookupPtr`) which maps names to lists. The list is a special list `StoredDeclsList` which is optimized to have one element. During building the initial AST, the parser first adds the definition to the `DeclContext`. Then during parsing the second declaration (the forward decl) the parser again calls `DeclContext::addDecl` but that will not add a new element to the `StoredDeclsList` rarther it simply overwrites the old element with the most recent one. This patch fixes the error by finding the definition in the redecl chain. Added tests for the same issue with `CXXRecordDecl` and with `ClassTemplateSpecializationDecl`. These tests pass and they pass because in `VisitRecordDecl` and in `VisitClassTemplateSpecializationDecl` we already use `D->getDefinition()` after the lookup. Reviewers: a.sidorin, xazax.hun, szepet Subscribers: rnkovacs, dkrupp, cfe-commits Differential Revision: https://reviews.llvm.org/D46950 llvm-svn: 333082
* [ASTImporter] Enable disabled but passing testGabor Marton2018-05-181-1/+1
| | | | | | | | | | | | | | Summary: There is a test which passes since D32947, but it was forgotten to be enabled. This patch enables that disabled test. Reviewers: a.sidorin, r.stahl, xazax.hun Subscribers: rnkovacs, dkrupp, cfe-commits Differential Revision: https://reviews.llvm.org/D47069 llvm-svn: 332728
* Do not try to remove invisible Decls from DeclContextGabor Marton2018-05-181-0/+33
| | | | llvm-svn: 332699
* [ASTImporter] Fix missing implict CXXRecordDeclGabor Marton2018-05-171-1/+1
| | | | | | | | | | | | | | Summary: Implicit CXXRecordDecl is not added to its DeclContext during import, but in the original AST it is. This patch fixes this. Reviewers: xazax.hun, a.sidorin, szepet Subscribers: rnkovacs, dkrupp, cfe-commits Differential Revision: https://reviews.llvm.org/D46958 llvm-svn: 332588
* [ASTImporter] Extend lookup logic in class templatesAleksei Sidorin2018-05-151-0/+33
| | | | | | | | | | | | | | During import of a class template, lookup may find a forward declaration and structural match falsely reports equivalency between a forward decl and a definition. The result is that some definitions are not imported if we had imported a forward decl previously. This patch gives a fix. Patch by Gabor Marton! Differential Revision: https://reviews.llvm.org/D46353 llvm-svn: 332338
* [ASTImporter] Turn StringRefs back to std::strings to avoid use-after-freeAleksei Sidorin2018-05-141-2/+2
| | | | | | | | | This is a workaround for the issue in buildASTFromCodeWithArgs() where a local buffer can be used to store the program text referred by SourceManager. FIXME: Fix the root issue in buildASTFromCodeWithArgs(). llvm-svn: 332256
* [ASTImporter] Support importing UnresolvedMemberExpr, DependentNameType, ↵Peter Szecsi2018-05-071-0/+55
| | | | | | | | | | DependentScopeDeclRefExpr The visit callback implementations for the 3 C++ AST Node added to the ASTImporter. Differential Revision: https://reviews.llvm.org/D38845 llvm-svn: 331630
* [ASTImporter] Allow testing of import sequences; fix import of typedefs for ↵Aleksei Sidorin2018-04-241-45/+251
| | | | | | | | | | | | | | | | | | | | | | | | | | anonymous decls This patch introduces the ability to test an arbitrary sequence of imports between a given set of virtual source files. This should finally allow us to write simple tests and fix annoying issues inside ASTImporter that cause failures in CSA CTU. This is done by refactoring ASTImporterTest functions and introducing `testImportSequence` facility. As a side effect, `testImport` facility was generalized a bit more. It should now allow import of non-decl AST nodes; however, there is still no test using this ability. As a "test for test", there is also a fix for import anonymous TagDecls referred by typedef. Before this patch, the setting of typedef for anonymous structure was delayed; however, this approach misses the corner case if an enum constant is imported directly. In this patch, typedefs for anonymous declarations are imported right after the anonymous declaration is imported, without any delay. Thanks to Adam Balogh for suggestions included into this patch. Differential Revision: https://reviews.llvm.org/D44079 llvm-svn: 330704
* [ASTImporter] Add test helper FixturePeter Szecsi2018-03-301-6/+693
| | | | | | | | | | | | | | | | | | Add a helper test Fixture, so we can add tests which can check internal attributes of AST nodes like getPreviousDecl(), isVirtual(), etc. This enables us to check if a redeclaration chain is correctly built during import, if the virtual flag is preserved during import, etc. We cannot check such attributes with the existing testImport. Also, this fixture makes it possible to import from several "From" contexts. We also added several test cases here, some of them are disabled. We plan to pass the disabled tests in other patches. Patch by Gabor Marton! Differential Revision: https://reviews.llvm.org/D43967 llvm-svn: 328906
* [ASTImporter] Fix lexical DC for templated decls; support ↵Aleksei Sidorin2018-02-141-14/+26
| | | | | | | | | | VarTemplatePartialSpecDecl Also minor refactoring in related functions was done. Differential Revision: https://reviews.llvm.org/D43012 llvm-svn: 325116
* Attempt to make the PS4 build bot happy.Gabor Horvath2018-01-271-2/+2
| | | | llvm-svn: 323590
* [ASTImporter] Add support to import some AST nodes:Gabor Horvath2018-01-271-0/+92
| | | | | | | | | | | | | | | | * CXXOperatorCallExpr * SizeOfPackExpr * DependentTemplateSpecializationType * DependentSizedArray * CXXTypeidExpr * Fix importing CXXTemporaryObjectExpr Some of the changes are based on https://github.com/haoNoQ/clang/blob/summary-ipa-draft/lib/AST/ASTImporter.cpp Differential Revision: https://reviews.llvm.org/D42335 llvm-svn: 323589
* [ASTImporter] Support LambdaExprs and improve template supportAleksei Sidorin2018-01-261-7/+28
| | | | | | | | | | | | | | Also, a number of style and bug fixes was done: * ASTImporterTest: added sanity check for source node * ExternalASTMerger: better lookup for template specializations * ASTImporter: don't add templated declarations into DeclContext * ASTImporter: introduce a helper, ImportTemplateArgumentListInfo getting SourceLocations * ASTImporter: proper set ParmVarDecls for imported FunctionProtoTypeLoc Differential Revision: https://reviews.llvm.org/D42301 llvm-svn: 323519
* [ASTImporter] Support importing CXXUnresolvedConstructExpr and ↵Aleksei Sidorin2018-01-091-0/+35
| | | | | | | | | | | | | UnresolvedLookupExpr * Note: This solution is based on https://github.com/haoNoQ/clang/blob/summary-ipa-draft/lib/AST/ASTImporter.cpp#L7605. Patch by Peter Szecsi! Differential Revision: https://reviews.llvm.org/D38694 llvm-svn: 322091
* [ASTImporter] Support importing FunctionTemplateDecl and ↵Aleksei Sidorin2017-12-271-0/+30
| | | | | | | | | | | | | | | CXXDependentScopeMemberExpr * Also introduces ImportTemplateArgumentListInfo facility (A. Sidorin) This re-commits r320942 after fixing the behaviour on '-fdelayed-template-parsing' option and adding additional checks. Patch by Peter Szecsi! Differential Revision: https://reviews.llvm.org/D38692 llvm-svn: 321492
* [ASTImporterTest] Add mandatory testing with '-fdelayed-template-parsing'Aleksei Sidorin2017-12-211-384/+386
| | | | | | | | | | | | | | | | * While running ASTImporterTests, we often forget about Windows MSVC buildbots which enable '-fdelayed-template-parsing' by default. This leads to AST import errors because templates are not parsed and corresponding parts of AST are not built so importer cannot import them. It takes both reviewing time to find such issues and post-commit time to fix unexpected buildbot failures. To solve this issue, we enable testing with '-fdelayed-template-parsing' option enabled by default in addition to testing with default compiler options. This allows us to catch the problem during development. Differential Revision: https://reviews.llvm.org/D41444 llvm-svn: 321285
* Revert r320942, "[ASTImporter] Support importing FunctionTemplateDecl and ↵Peter Collingbourne2017-12-201-29/+0
| | | | | | | | | | | | | | | | | CXXDependentScopeMemberExpr" Caused a test failure on Windows: [ RUN ] ImportExpr.ImportCXXDependentScopeMemberExpr C:\b\rr\tmppzcp4w\w\src\third_party\llvm\tools\clang\unittests\AST\ASTImporterTest.cpp(526): error: Value of: testImport("template <typename T> class C { T t; };" "template <typename T> void declToImport() {" " C<T> d;" " d.t;" "}", Lang_CXX, "", Lang_CXX, Verifier, functionTemplateDecl(has(functionDecl(has(compoundStmt( has(cxxDependentScopeMemberExpr()))))))) Actual: false (Could not find match) Expected: true C:\b\rr\tmppzcp4w\w\src\third_party\llvm\tools\clang\unittests\AST\ASTImporterTest.cpp(534): error: Value of: testImport("template <typename T> class C { T t; };" "template <typename T> void declToImport() {" " C<T> d;" " (&d)->t;" "}", Lang_CXX, "", Lang_CXX, Verifier, functionTemplateDecl(has(functionDecl(has(compoundStmt( has(cxxDependentScopeMemberExpr()))))))) Actual: false (Could not find match) Expected: true [ FAILED ] ImportExpr.ImportCXXDependentScopeMemberExpr (37 ms) llvm-svn: 321139
* [ASTImporter] Support importing FunctionTemplateDecl and ↵Aleksei Sidorin2017-12-171-0/+29
| | | | | | | | | | | | CXXDependentScopeMemberExpr * Also introduces ImportTemplateArgumentListInfo facility (A. Sidorin) Patch by Peter Szecsi! Differential Revision: https://reviews.llvm.org/D38692 llvm-svn: 320942
* [ASTImporter] Add unit tests for UsingDecl and UsingShadowDeclAleksei Sidorin2017-12-031-0/+41
| | | | | | | | Patch by Kareem Khazem! Differential Revision: https://reviews.llvm.org/D27181 llvm-svn: 319632
* [ASTImporter] Support importing CXXPseudoDestructorExprAleksei Sidorin2017-11-271-0/+16
| | | | | | | | Patch by Peter Szecsi! Differential Revision: https://reviews.llvm.org/D38843 llvm-svn: 319015
* [ASTImporter] Support TypeTraitExprAleksei Sidorin2017-11-261-0/+41
| | | | | | | | Patch by Takafumi Kubota! Differential Revision: https://reviews.llvm.org/D39722 llvm-svn: 318998
* [ASTImporter] TypeAliasTemplate and PackExpansion importing capabilityGabor Horvath2017-11-141-0/+40
| | | | | | | | Patch by: Zoltan Gera! Differential Revision: https://reviews.llvm.org/D39247 llvm-svn: 318147
* [ASTImporter] Import SubStmt of CaseStmtGabor Horvath2017-10-181-0/+13
| | | | | | | | Patch by: Rafael Stahl! Differential Revision: https://reviews.llvm.org/D38943 llvm-svn: 316069
* Unify and simplify the behavior of the hasDeclaration matcher.Manuel Klimek2017-08-021-29/+13
| | | | | | | | | | | | | | | | | | | | | | | | | Originally, we weren't able to match on Type nodes themselves (only QualType), so the hasDeclaration matcher was initially written to give what we thought are reasonable results for QualType matches. When we chagned the matchers to allow matching on Type nodes, it turned out that the hasDeclaration matcher was by chance written templated enough to now allow hasDeclaration to also match on (some) Type nodes. This patch change the hasDeclaration matcher to: a) work the same on Type and QualType nodes, b) be completely explicit about what nodes we can match instead of just allowing anything with a getDecl() to match, c) explicitly control desugaring only one level in very specific instances. d) adds hasSpecializedTemplate and tagType matchers to allow migrating existing use cases that now need more explicit matchers Note: This patch breaks clang-tools-extra. The corresponding patch there is approved and will land in a subsequent patch. Differential Revision: https://reviews.llvm.org/D27104 llvm-svn: 309809
* [ASTImporter] Added ability to import AtomicType nodesGabor Horvath2016-11-231-0/+15
| | | | | | | | Patch by: Kareem Khazem Differential Revision: https://reviews.llvm.org/D26328 llvm-svn: 287763
* Fix Clang-tidy readability-redundant-string-cstr warningsMalcolm Parsons2016-11-021-2/+1
| | | | | | | | | | Reviewers: aaron.ballman, mehdi_amini, dblaikie Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D26206 llvm-svn: 285799
* [ASTImporter] Implement some expression-related AST node import (part 2)Aleksei Sidorin2016-09-281-0/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Some code cleanup * Add tests not present in http://reviews.llvm.org/D14286 * Integrate a test suite from Serge Pavlov (http://reviews.llvm.org/D14224) * ArrayTypeTraitExpr: serialize sub-expression to avoid keeping it undefined * Implement import of some nodes: - ArrayTypeTraitExpr - ExpressionTraitExpr - OpaqueValueExpr - ArraySubscriptExpr - ExplicitCastExpr - ImplicitValueInitExpr - OffsetOfExpr - CXXThisExpr - CXXThrowExpr - CXXNoexceptExpr - CXXDefaultArgExpr - CXXScalarValueInitExpr - CXXBindTemporaryExpr - CXXTemporaryObjectExpr - MaterializeTemporaryExpr - ExprWithCleanups - StaticAssertDecl - FriendDecl - DecayedType Differential Revision: https://reviews.llvm.org/D14326 llvm-svn: 282572
* Prune away some unused using decls. NFC.Benjamin Kramer2016-06-081-4/+0
| | | | | | Found by clang's misc-unused-using-decls. llvm-svn: 272156
* [ASTMatchers] Breaking change of `has` matcherPiotr Padlewski2016-05-311-14/+8
| | | | | | | | has matcher can now match to implicit and paren casts http://reviews.llvm.org/D20801 llvm-svn: 271288
* [ASTImporter] Implement some expression-related AST node import.Artem Dergachev2016-04-141-0/+470
Introduce ASTImporter unit test framework. Fix a memory leak introduced in cf8ccff5: an array is allocated in ImportArray and never freed. Support new node kinds: - GCCAsmStmt - AddrLabelExpr - AtomicExpr - CompoundLiteralExpr - CXXBoolLiteralExpr - CXXNullPtrLiteralExpr - CXXThisExpr - DesignatedInitExpr - GNUNullExpr - ImplicitValueInitExpr - InitListExpr - OpaqueValueExpr - PredefinedExpr - ParenListExpr - StmtExpr - VAArgExpr - BinaryConditionalOperator - ConditionalOperator - FloatingLiteral - StringLiteral - InjectedClassNameType - TemplateTypeParmType - LabelDecl Patch by Aleksei Sidorin! Differential Revision: http://reviews.llvm.org/D14286 llvm-svn: 266292
OpenPOWER on IntegriCloud