summaryrefslogtreecommitdiffstats
path: root/clang/lib/ASTMatchers
Commit message (Collapse)AuthorAgeFilesLines
...
* Roll functions back into namespaces, msvc has problems with name lookup ↵Benjamin Kramer2015-03-091-4/+8
| | | | | | outside of it. llvm-svn: 231671
* Make helper functions static. NFC.Benjamin Kramer2015-03-091-13/+9
| | | | | | Found by -Wmissing-prototypes. llvm-svn: 231668
* Add translationUnitDecl matcher.Samuel Benzaquen2015-02-101-0/+1
| | | | | | | | | | | | Summary: Add translationUnitDecl matcher. Reviewers: alexfh Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D7512 llvm-svn: 228694
* Add voidType() matcher.Samuel Benzaquen2014-12-151-0/+1
| | | | | | | | | | | | Summary: Add voidType() matcher. Reviewers: klimek Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D6656 llvm-svn: 224250
* Make the function pointer a template argument instead of a runtime value.Samuel Benzaquen2014-12-011-22/+37
| | | | | | | | | | | | | | | | | Summary: Speed up the variadic matchers by removing one indirect call. Making the function pointer a template arguments allows the compiler to inline the call instead of doing an runtime call by pointer. Also, optimize the allOf() case to avoid redundant kind checks. This speeds up our clang-tidy benchmark by ~2% Reviewers: klimek Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D6424 llvm-svn: 223029
* Re-apply r222646 (was reverted in r222667). Adding 4 ASTMatchers: ↵Manuel Klimek2014-11-251-0/+4
| | | | | | | | | | | | | | | | | | | | | | | 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
* Filter the toplevel matchers by kind.Samuel Benzaquen2014-11-242-10/+86
| | | | | | | | | | | | | | | | | | Summary: Filter the toplevel matchers by kind. Decl and Stmt matchers are tied to a specific node kind and trying to match incompatible nodes is a waste. Precalculate a filtered list of matchers that have a chance of matching the node and ignore the rest. Speeds up our clang-tidy benchmark by ~10% Reviewers: klimek Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D6361 llvm-svn: 222688
* Reverting r222646; the tests do not pass on Windows. Also reverts r222664, ↵Aaron Ballman2014-11-241-4/+0
| | | | | | which was required for r222646 to compile with Visual Studio 2012. llvm-svn: 222667
* Adding 4 ASTMatchers: typedefDecl, isInMainFile, isInSystemFile, ↵Manuel Klimek2014-11-241-0/+4
| | | | | | | | | | | | | | | | | | | | 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
* Replace variadic operator function pointer with an enum value.Samuel Benzaquen2014-11-203-19/+59
| | | | | | | | | | | | | | | Summary: Replace variadic operator function pointer with an enum value. Hiding the implementation of the variadic matcher will allow to specialize them for the operation performed. In particular, it will allow for a more efficient allOf() matcher. Reviewers: klimek Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D6293 llvm-svn: 222432
* Remove VariadicOperatorMatcherInterface as it is redundant with logic from ↵Samuel Benzaquen2014-11-173-8/+9
| | | | | | | | | | | | | | | | | | | DynTypedMatcher. Summary: The generic variadic matcher is faster (one less virtual function call per match) and doesn't require template instantiations which reduces compile time and binary size. Registry.cpp.o generates ~14% less symbols and compiles ~7.5% faster. The change also speeds up our clang-tidy benchmark by ~2%. Reviewers: klimek Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D6278 llvm-svn: 222131
* Add valueDecl() matcher.Samuel Benzaquen2014-10-281-0/+1
| | | | | | | | | | | | Summary: Add valueDecl() matcher. Reviewers: klimek Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D6005 llvm-svn: 220776
* Speed up clang-tidy when profiling in on.Samuel Benzaquen2014-10-271-15/+31
| | | | | | | | | | | | | | | | Summary: Speed up clang-tidy when profiling in on. It makes profiling runs twice as fast by reusing the time samples between the different actions. It also joins together the sampling of different matchers of the same check. Reviewers: alexfh Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D5972 llvm-svn: 220682
* ASTMatchers: Peel off a layer of indirection from true matcher. NFC.Benjamin Kramer2014-10-241-12/+10
| | | | llvm-svn: 220560
* ASTMatchers: for-rangify loops. No functionality change.Benjamin Kramer2014-10-241-11/+9
| | | | llvm-svn: 220559
* Add support for profiling the matchers used.Samuel Benzaquen2014-10-221-7/+52
| | | | | | | | | | | | | | | 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 code to follow the "Don’t use else after a return" rule.Samuel Benzaquen2014-10-161-7/+8
| | | | | | | | | | | | | | Summary: Fix code to follow the "Don’t use else after a return" rule. This is a followup from rL219792. Reviewers: alexfh Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D5826 llvm-svn: 219939
* Speed up hasName() matcher.Samuel Benzaquen2014-10-151-0/+46
| | | | | | | | | | | | | | | | | | Summary: Speed up hasName() matcher by skipping the expensive generation of the fully qualified name unless we need it. In the common case of matching an unqualified name, we don't need to generate the full name. We might not even need to copy any string at all. This change speeds up our clang-tidy benchmark by ~10% Reviewers: klimek Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D5776 llvm-svn: 219792
* Fix order of evaluation bug in DynTypedMatcher::constructVariadic().Samuel Benzaquen2014-10-131-2/+2
| | | | | | | | Fix order of evaluation bug in DynTypedMatcher::constructVariadic(). If it evaluates right-to-left, the vector gets moved before we read the kind from it. llvm-svn: 219624
* Fix bug in DynTypedMatcher::constructVariadic() that would cause false ↵Samuel Benzaquen2014-10-131-12/+13
| | | | | | | | | | | | | | | | | | | 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-10/+15
| | | | | | | | | | | | | | | | | | | | 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-0/+25
| | | | | | | | | | | | | | | | | 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-13/+18
| | | | llvm-svn: 219408
* Fix bug in DynTypedMatcher::constructVariadic() that would cause false ↵Samuel Benzaquen2014-10-061-24/+4
| | | | | | | | | | | | | | | | | | | 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
* Return a reference instead of vector copy for parentmap queries.Benjamin Kramer2014-10-041-26/+24
| | | | | | | The map is immutable until the whole ASTContext dies. While there movify a couple of copies in ASTMatchFinder away. NFC. llvm-svn: 219062
* Adds 'override' to overriding methods. NFC.Fariborz Jahanian2014-10-011-5/+5
| | | | | | These were uncoveredby my yet undelivered patch. llvm-svn: 218774
* Refactor Matcher<T> and DynTypedMatcher to reduce overhead of casts.Samuel Benzaquen2014-10-012-3/+108
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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-108/+3
| | | | | | | | | | | | 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-3/+108
| | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Separate the matchers by type and statically dispatch to the right list.Samuel Benzaquen2014-09-051-40/+72
| | | | | | | | | | | | | | | | | Summary: Separate the matchers by type and statically dispatch to the right list. For any node type that we support, it reduces the number of matchers we run it through. For node types we do not support, it makes match() a noop. This change improves our clang-tidy related benchmark by ~30%. Reviewers: klimek Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D5197 llvm-svn: 217274
* Refactor VariantMatcher::MatcherOps to reduce the amount of generated code.Samuel Benzaquen2014-09-042-7/+48
| | | | | | | | | | | | | | | | | | Summary: Refactor VariantMatcher::MatcherOps to reduce the amount of generated code. - Make some code type agnostic and move it to the cpp file. - Return a DynTypedMatcher instead of storing the object in MatcherOps. This change reduces the number of symbols generated in Registry.cpp by ~19%, the object byte size by ~17% and the compilation time (in non-release mode) by ~20%. Reviewers: klimek Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D5124 llvm-svn: 217152
* ASTMatchers: Add a matcher to detect whether a decl or stmt is inside a ↵Benjamin Kramer2014-09-031-0/+2
| | | | | | | | | | | 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
* Fix some cases where StringRef was being passed by const reference. Remove ↵Craig Topper2014-08-301-1/+1
| | | | | | const from some other StringRefs since its implicitly const already. llvm-svn: 216825
* Use llvm::makeArrayRef instead of explicitly calling ArrayRef constructor ↵Craig Topper2014-08-301-2/+2
| | | | | | and mentioning the type. This works now that we have a conversion from ArrayRef<T*> to ArrayRef<const T*>. llvm-svn: 216824
* ASTMatchers: Replace some copies of the bound nodes tree builder with moves.Benjamin Kramer2014-08-291-2/+2
| | | | | | | | | But don't move if all we do is clearing the thing. The move method is too large to be inlined and performs a ton of unnecessary checking when the RHS is empty. No functionality change. llvm-svn: 216723
* Don't create a null reference to NestedNameSpecifier.Alexey Samsonov2014-08-281-1/+2
| | | | | | This bug was reported by UBSan. llvm-svn: 216691
* Add hasAttr matcher for declarations.Manuel Klimek2014-08-252-3/+22
| | | | | | | | Delete special-case CUDA attribute matchers. Patch by Jacques Pienaar. llvm-svn: 216379
* Add missing matchers to the dynamic registry.Samuel Benzaquen2014-08-151-0/+11
| | | | | | | | | | Reviewers: klimek Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D4910 llvm-svn: 215757
* Add isDeleted() matcher for FunctionDecl nodes.Samuel Benzaquen2014-08-151-0/+1
| | | | | | | | | | 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-124-160/+224
| | | | | | | | | | | | | | | | | | | 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
* Recommit 213307: unique_ptr-ify ownership of ASTConsumers (reverted in r213325)David Blaikie2014-08-101-2/+2
| | | | | | | | After post-commit review and community discussion, this seems like a reasonable direction to continue, making ownership semantics explicit in the source using the type system. llvm-svn: 215323
* Prevent assert in ASTMatchFinder.Daniel Jasper2014-07-231-1/+1
| | | | | | | | | | | | 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
* Revert "unique_ptr-ify ownership of ASTConsumers"David Blaikie2014-07-171-2/+2
| | | | | | | | | This reverts commit r213307. Reverting to have some on-list discussion/confirmation about the ongoing direction of smart pointer usage in the LLVM project. llvm-svn: 213325
* unique_ptr-ify ownership of ASTConsumersDavid Blaikie2014-07-171-2/+2
| | | | | | | | | (after fixing a bug in MultiplexConsumer I noticed the ownership of the nested consumers was implemented with raw pointers - so this fixes that... and follows the source back to its origin pushing unique_ptr ownership up through there too) llvm-svn: 213307
* Remove llvm:: from uses of ArrayRef.Craig Topper2014-06-282-8/+8
| | | | llvm-svn: 211987
* Add hasLocalStorage/hasGlobalStorage matchers.Samuel Benzaquen2014-06-051-0/+2
| | | | | | | | | | | | | | Summary: Add hasLocalStorage/hasGlobalStorage matchers for VarDecl nodes. Update the doc. Also add them to the dynamic registry. Reviewers: klimek Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D4034 llvm-svn: 210278
* [C++11] Use 'nullptr'. ASTMatchers edition.Craig Topper2014-05-174-24/+24
| | | | llvm-svn: 209070
* Add support for named values in the parser.Samuel Benzaquen2014-04-143-35/+69
| | | | | | | | | | | | Summary: Add support for named values in the parser. Reviewers: pcc CC: cfe-commits, klimek Differential Revision: http://llvm-reviews.chandlerc.com/D3276 llvm-svn: 206176
* Revert "Add support for named values in the parser."Samuel Benzaquen2014-04-031-27/+21
| | | | | | | | This was submitted before it was ready. This reverts commit 62060a01e095cf35eb9ca42a333752d12714f35c. llvm-svn: 205533
OpenPOWER on IntegriCloud