summaryrefslogtreecommitdiffstats
path: root/clang/unittests/ASTMatchers
Commit message (Collapse)AuthorAgeFilesLines
...
* Add support for a few Objective-C matchers.Manuel Klimek2015-03-122-2/+65
| | | | | | | | | | | Add some matchers for Objective-C selectors and messages to ASTMatchers.h. Minor mods to ASTMatchersTest.h to allow test files with ".m" extension in addition to ".cpp". New tests added to ASTMatchersTest.c. Patch by Dean Sutherland. llvm-svn: 232051
* Reverting r232034, as it broke one of the bots with link errors. Details at: ↵Aaron Ballman2015-03-122-65/+2
| | | | | | http://bb.pgr.jp/builders/ninja-clang-x64-mingw64-RA/builds/6352/steps/build/logs/stdio llvm-svn: 232038
* Added some matchers for objective c selectors and messages to ASTMatchers.h. ↵Aaron Ballman2015-03-122-2/+65
| | | | | | | | Minor mods to ASTMatchersTest.h to allow test files with ".m" extension in addition to ".cpp". New tests added to ASTMatchersTest.c. Patch by Dean Sutherland, reviewed by Manuel Klimek. From http://reviews.llvm.org/D7710 llvm-svn: 232034
* ASTMatchers: Make AST_POLYMORPHIC_SUPPORTED_TYPES a variadic macroBenjamin Kramer2015-03-071-4/+3
| | | | | | C++11 finally allows us to use this C99 feature. llvm-svn: 231575
* Fix isOverride() for the case of a dependent typed base class.Samuel Benzaquen2015-03-061-0/+3
| | | | | | | | The method decl is not marked as overriding any other method decls until the template is instantiated. Use the override attribute as another signal. llvm-svn: 231487
* Add -frtti and -fexceptions to tests that assume these are on.Filipe Cabecinhas2015-03-021-1/+5
| | | | | | | | | | | | | | | Summary: We now have targets that don't enable rtti/exceptions by default, and the ASTMatchers tests are assuming that these features are on (e.g: They use dynamic_cast or try). Reviewers: klimek, thakis, djasper Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D7892 llvm-svn: 230984
* Revert "Wrap clang module files in a Mach-O, ELF, or COFF container."Adrian Prantl2015-02-252-9/+7
| | | | llvm-svn: 230454
* Wrap clang module files in a Mach-O, ELF, or COFF container.Adrian Prantl2015-02-252-7/+9
| | | | | | | | | | | | | | | | | This is a necessary prerequisite for debugging with modules. The .pcm files become containers that hold the serialized AST which allows us to store debug information in the module file that can be shared by all object files that were built importing the module. This reapplies r230044 with a fixed configure+make build and updated dependencies and testcase requirements. Over the last iteration this version adds - missing target requirements for testcases that specify an x86 triple, - a missing clangCodeGen.a dependency to libClang.a in the make build. rdar://problem/19104245 llvm-svn: 230423
* Revert "Wrap clang module files in a Mach-O, ELF, or COFF container."Adrian Prantl2015-02-242-9/+7
| | | | | | | This reverts commit r230305. Off to fix another round of missing dependencies on various platforms. llvm-svn: 230309
* Wrap clang module files in a Mach-O, ELF, or COFF container.Adrian Prantl2015-02-242-7/+9
| | | | | | | | | | | | | | This is a necessary prerequisite for debugging with modules. The .pcm files become containers that hold the serialized AST which allows us to store debug information in the module file that can be shared by all object files that were built importing the module. rdar://problem/19104245 This reapplies r230044 with a fixed configure+make build and updated dependencies. Take 3. llvm-svn: 230305
* Revert "Wrap clang module files in a Mach-O, ELF, or COFF container."Adrian Prantl2015-02-212-9/+7
| | | | | | | | This reverts commit 230099. The Linux configure+make build variant still needs some work. llvm-svn: 230103
* Wrap clang module files in a Mach-O, ELF, or COFF container.Adrian Prantl2015-02-202-7/+9
| | | | | | | | | | | | | | This is a necessary prerequisite for debugging with modules. The .pcm files become containers that hold the serialized AST which allows us to store debug information in the module file that can be shared by all object files that were built importing the module. rdar://problem/19104245 This reapplies r230044 with a fixed configure+make build and updated dependencies. Take 2. llvm-svn: 230089
* Revert "Wrap clang module files in a Mach-O, ELF, or COFF container."Adrian Prantl2015-02-202-9/+7
| | | | | | | | This reverts commit r230067. Investigating another batch of problems found by the bots. llvm-svn: 230073
* Wrap clang module files in a Mach-O, ELF, or COFF container.Adrian Prantl2015-02-202-7/+9
| | | | | | | | | | | | | | This is a necessary prerequisite for debugging with modules. The .pcm files become containers that hold the serialized AST which allows us to store debug information in the module file that can be shared by all object files that were built importing the module. rdar://problem/19104245 This reapplies r230044 with a fixed configure+make build and updated dependencies. llvm-svn: 230067
* Add translationUnitDecl matcher.Samuel Benzaquen2015-02-101-0/+15
| | | | | | | | | | | | Summary: Add translationUnitDecl matcher. Reviewers: alexfh Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D7512 llvm-svn: 228694
* Rewrite r228138 to be somewhat saner.Daniel Jasper2015-02-041-0/+2
| | | | | | | | | | While probably technically correct, the solution r228138 was quite hard to read/understand. This should be simpler. Also added a test to ensure that we are still visiting the syntactic form as well. llvm-svn: 228144
* Let RecursiveASTVisitor walk both syntactic and semantic form of InitListExprs.Daniel Jasper2015-02-041-0/+4
| | | | | | | | | | | | | | Otherwise, this can lead to unexpected results when AST matching as some nodes are only present in the semantic form. For example, only looking at the syntactic form does not find the DeclRefExpr to f() in: struct S { S(void (*a)()); }; void f(); S s[1] = {&f}; llvm-svn: 228138
* Add some overloads so that floating point literals can be AST matched properly.Daniel Jasper2015-02-031-0/+8
| | | | | | | | | | I am not entirely sure whether the implemented sematics are ideal. In particular, should floatLiteral(equals(0.5)) match "0.5f" and should floatLiteral(equals(0.5f)) match "0.5". With the overloads in this patch, the answer to both questions is yes, but I am happy to change that. llvm-svn: 227956
* Revert "Add some overloads so that floating point literals can be AST ↵Daniel Jasper2015-02-021-8/+0
| | | | | | | | | | matched properly." Apparently the build bots get angry for some reason. Can't reproduce that in a local cmake/ninja build. Will look closer. Rolling back for now. llvm-svn: 227895
* Add some overloads so that floating point literals can be AST matched properly.Daniel Jasper2015-02-021-0/+8
| | | | | | | | | | I am not entirely sure whether the implemented sematics are ideal. In particular, should floatLiteral(equals(0.5)) match "0.5f" and should floatLiteral(equals(0.5f)) match "0.5". With the overloads in this patch, the answer to both questions is yes, but I am happy to change that. llvm-svn: 227892
* Add voidType() matcher.Samuel Benzaquen2014-12-151-0/+5
| | | | | | | | | | | | Summary: Add voidType() matcher. Reviewers: klimek Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D6656 llvm-svn: 224250
* Re-apply r222646 (was reverted in r222667). Adding 4 ASTMatchers: ↵Manuel Klimek2014-11-252-5/+60
| | | | | | | | | | | | | | | | | | | | | | | typedefDecl, isInMainFile, isInSystemFile, isInFileMatchingName Change to original: ifndef out tests in Windows due to /-separated paths. Summary: Often one is only interested in matches within the main-file or matches that are not within a system-header, for which this patch adds isInMainFile and isInSystemFile. They take no arguments and narrow down the matches. The isInFileMatchingName is mainly thought for interactive clang-query-sessions, to make a matcher more specific without restarting the session with the files you are interested in for that moment. It takes a string that will be used as regular-expression to match the filename of where the matched node is expanded. Patch by Hendrik von Prince. llvm-svn: 222765
* Reverting r222646; the tests do not pass on Windows. Also reverts r222664, ↵Aaron Ballman2014-11-242-55/+5
| | | | | | which was required for r222646 to compile with Visual Studio 2012. llvm-svn: 222667
* Unbreaking the MSVC 2012 build; however, these tests still fail on Windows.Aaron Ballman2014-11-241-5/+12
| | | | llvm-svn: 222664
* Adding 4 ASTMatchers: typedefDecl, isInMainFile, isInSystemFile, ↵Manuel Klimek2014-11-242-5/+48
| | | | | | | | | | | | | | | | | | | | isInFileMatchingName Summary: Often one is only interested in matches within the main-file or matches that are not within a system-header, for which this patch adds isInMainFile and isInSystemFile. They take no arguments and narrow down the matches. The isInFileMatchingName is mainly thought for interactive clang-query-sessions, to make a matcher more specific without restarting the session with the files you are interested in for that moment. It takes a string that will be used as regular-expression to match the filename of where the matched node is expanded. Patch by Hendrik von Prince. llvm-svn: 222646
* Add valueDecl() matcher.Samuel Benzaquen2014-10-281-0/+7
| | | | | | | | | | | | Summary: Add valueDecl() matcher. Reviewers: klimek Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D6005 llvm-svn: 220776
* Fix segfault in hasDeclContext for nodes that have no decl context.Samuel Benzaquen2014-10-271-0/+2
| | | | | | | | | | | | | | Summary: Some declarations do not have a declaration context, like TranslationUnitDecl. Fix hasDeclContext() to not segfault on these nodes. Reviewers: klimek Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D6003 llvm-svn: 220719
* Add support for profiling the matchers used.Samuel Benzaquen2014-10-221-0/+19
| | | | | | | | | | | | | | | Summary: Add support for profiling the matchers used. This will be connected with clang-tidy to generate a report to determine and debug slow checks. Reviewers: alexfh Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D5911 llvm-svn: 220418
* Fix bug in DynTypedMatcher::constructVariadic() that would cause false ↵Samuel Benzaquen2014-10-132-0/+12
| | | | | | | | | | | | | | | | | | | negatives. Summary: Change r219118 fixed the bug for anyOf and eachOf, but it is still present for unless. The variadic wrapper doesn't have enough information to know how to restrict the type. Different operators handle restrict failures in different ways. Reviewers: klimek Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D5731 llvm-svn: 219622
* Fix completion logic to allow for heterogeneous argument types in matcher ↵Samuel Benzaquen2014-10-091-0/+14
| | | | | | | | | | | | | | | | | | | | overloads. Summary: There was an assumption that there were no matchers that were overloaded on matchers and other types of arguments. This assumption was broken recently with the addition of new matcher overloads. Fixes http://llvm.org/PR21226 Reviewers: pcc Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D5711 llvm-svn: 219450
* Special case 0 and 1 matcher in makeAllOfComposite().Samuel Benzaquen2014-10-091-1/+4
| | | | | | | | | | | | | | | | | Summary: Remove unnecessary wrapping for the 0 and 1 matcher cases of makeAllOfComposite(). We don't need a variadic wrapper for those cases. Refactor TrueMatcher to take advandage of the new conversions between DynTypedMatcher and Matcher<T>. Also, make it a singleton. This change improves our clang-tidy related benchmarks by ~12%. Reviewers: klimek Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D5675 llvm-svn: 219431
* Implement various matchers around template argument handling.Manuel Klimek2014-10-091-0/+58
| | | | llvm-svn: 219408
* Fix bug in DynTypedMatcher::constructVariadic() that would cause false ↵Samuel Benzaquen2014-10-062-1/+6
| | | | | | | | | | | | | | | | | | | negatives. Summary: DynTypedMatcher::constructVariadic() where the restrict kind of the different matchers are not related causes the matcher to have a "None" restrict kind. This causes false negatives for anyOf and eachOf. Change the logic to get a common ancestor if there is one. Also added regression tests that fail without the fix. Reviewers: klimek Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D5580 llvm-svn: 219118
* Adds 'override' to overriding methods. NFC.Fariborz Jahanian2014-10-012-3/+3
| | | | | | These were uncoveredby my yet undelivered patch. llvm-svn: 218774
* Refactor Matcher<T> and DynTypedMatcher to reduce overhead of casts.Samuel Benzaquen2014-10-012-4/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This change introduces DynMatcherInterface and changes the internal representation of DynTypedMatcher and Matcher<T> to use a generic interface instead. It removes unnecessary indirections and virtual function calls when converting matchers by implicit and dynamic casts. DynTypedMatcher now remembers the stricter type in the chain of casts and checks it before calling into DynMatcherInterface. This change improves our clang-tidy related benchmark by ~14%. Also, it opens the door for more optimizations of this kind that are coming in future changes. As a side effect of removing these template instantiations, it also speeds up compilation of Dynamic/Registry.cpp by ~17% and reduces the number of symbols generated by ~30%. Reviewers: klimek Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D5542 llvm-svn: 218769
* Revert r218616, "Refactor Matcher<T> and DynTypedMatcher to reduce overhead ↵NAKAMURA Takumi2014-09-292-22/+4
| | | | | | | | | | | | of casts." MSC17, aka VS2012, cannot compile it. clang/include/clang/ASTMatchers/ASTMatchersInternal.h(387) : error C4519: default template arguments are only allowed on a class template clang/include/clang/ASTMatchers/ASTMatchersInternal.h(443) : see reference to class template instantiation 'clang::ast_matchers::internal::Matcher<T>' being compiled llvm-svn: 218648
* Refactor Matcher<T> and DynTypedMatcher to reduce overhead of casts.Samuel Benzaquen2014-09-292-4/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This change introduces DynMatcherInterface and changes the internal representation of DynTypedMatcher and Matcher<T> to use a generic interface instead. It removes unnecessary indirections and virtual function calls when converting matchers by implicit and dynamic casts. DynTypedMatcher now remembers the stricter type in the chain of casts and checks it before calling into DynMatcherInterface. This change improves our clang-tidy related benchmark by ~14%. Also, it opens the door for more optimizations of this kind that are coming in future changes. As a side effect of removing these template instantiations, it also speeds up compilation of Dynamic/Registry.cpp by ~17% and reduces the number of symbols generated by ~30%. Reviewers: klimek Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D5485 llvm-svn: 218616
* Add matcher for linkage specificationManuel Klimek2014-09-041-0/+5
| | | | | | Patch by Jacques Pienaar. llvm-svn: 217135
* ASTMatchers: Add a matcher to detect whether a decl or stmt is inside a ↵Benjamin Kramer2014-09-031-0/+56
| | | | | | | | | | | template instantiation. This is hoisted from clang-tidy where it's used everywhere. The implementation is not particularly efficient right now, but there is no easy fix for that. Differential Revision: http://reviews.llvm.org/D5085 llvm-svn: 217029
* Add hasAttr matcher for declarations.Manuel Klimek2014-08-252-9/+18
| | | | | | | | Delete special-case CUDA attribute matchers. Patch by Jacques Pienaar. llvm-svn: 216379
* Add isDeleted() matcher for FunctionDecl nodes.Samuel Benzaquen2014-08-151-0/+7
| | | | | | | | | | Reviewers: klimek Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D4911 llvm-svn: 215714
* Header guard canonicalization, clang part.Benjamin Kramer2014-08-131-2/+2
| | | | | | Modifications made by clang-tidy with minor tweaks. llvm-svn: 215557
* Support named values in the autocomplete feature.Samuel Benzaquen2014-08-122-31/+56
| | | | | | | | | | | | | | | | | | | Summary: This includes: - Passing a Sema to completeExpression to allow for named values in the expression. - Passing a map of names to values to the parser. - Update the Sema interface to include completion for matchers. - Change the parser to use the Sema for completion, instead of going directly to Registry. Reviewers: pcc Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D3509 llvm-svn: 215472
* ASTMatchersTests/matchesConditionallyWithCuda: Add -fno-ms-extensions, and ↵NAKAMURA Takumi2014-08-051-1/+4
| | | | | | | | get rid of initializer list. I am not sure whether -xcuda might imply -fno-ms-extensions. llvm-svn: 214876
* Adds AST matchers for matching CUDA declarations.Manuel Klimek2014-08-052-0/+84
| | | | | | Patch by Jacques Pienaar. llvm-svn: 214852
* Prevent assert in ASTMatchFinder.Daniel Jasper2014-07-231-0/+6
| | | | | | | | | | | | If nodes without memoization data (e.g. TypeLocs) are bound to specific names, that effectively prevents memoization as those elements cannot be compared effectively. If it is tried anyway, this can lead to an assert as demonstrated in the new test. In the long term, the better solution will be to enable DynTypedNodes without memoization data. For now, simply skip memoization instead. llvm-svn: 213751
* ASTMatchers: Bound node results are always const, make selectFirst's ↵Benjamin Kramer2014-07-231-4/+4
| | | | | | | | | | template argument implicitly const. This avoids adding const to every user of selectFirst and also allows it to match TypeLocs which BoundNodes doesn't use magic const removal specializations for. No functionality change. llvm-svn: 213737
* Make clang's rewrite engine a core featureAlp Toker2014-07-162-2/+2
| | | | | | | | | | | | | | | The rewrite facility's footprint is small so it's not worth going to these lengths to support disabling at configure time, particularly since key compiler features now depend on it. Meanwhile the Objective-C rewriters have been moved under the ENABLE_CLANG_ARCMT umbrella for now as they're comparatively heavy and still potentially worth excluding from lightweight builds. Tests are now passing with any combination of feature flags. The flags historically haven't been tested by LLVM's build servers so caveat emptor. llvm-svn: 213171
* [ASTMatchers] Add a usingDirectiveDecl matcher.Benjamin Kramer2014-07-161-0/+7
| | | | | | | | This matches 'using namespace' declarations. Differential Revision: http://reviews.llvm.org/D4517 llvm-svn: 213152
* [ASTMatchers] Make hasOverloadedOperatorName also match freestanding overloads.Benjamin Kramer2014-07-141-0/+7
| | | | | | | | | Freestanding overloads are represented as FunctionDecls in the AST, make the matcher also match them. Differential Revision: http://reviews.llvm.org/D4493 llvm-svn: 212940
OpenPOWER on IntegriCloud