summaryrefslogtreecommitdiffstats
path: root/clang/unittests/ASTMatchers/ASTMatchersTest.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Re-introduce MatchFinder::addDynamicMatcher.Peter Collingbourne2013-11-071-1/+20
| | | | | | Differential Revision: http://llvm-reviews.chandlerc.com/D2114 llvm-svn: 194222
* Introduce BoundNodes::getMap.Peter Collingbourne2013-11-061-0/+6
| | | | | | | | | The purpose of this function is to allow clients of the dynamic AST matcher to enumerate each binding. Differential Revision: http://llvm-reviews.chandlerc.com/D2095 llvm-svn: 194112
* Teach RAV to visit parameter variable declarations of implicit functions. ↵Michael Han2013-09-111-1/+5
| | | | | | | | | | | | | | | Fixes PR16182. Normally RAV visits parameter variable declarations of a function by traversing the TypeLoc of the parameter declarations. However, for implicit functions, their parameters don't have any TypeLoc, because they are implicit. So for implicit functions, we visit their parameter variable declarations by traversing them through the function declaration, and visit them accordingly. Reviewed by Richard Smith and Manuel Klimek. llvm-svn: 190528
* Fix crash when encountering alias templates in isDerivedFrom matches.Manuel Klimek2013-08-021-0/+6
| | | | | | | | | - pull out function to drill to the CXXRecordDecl from the type, to allow recursive resolution - make the analysis more robust by rather skipping values we don't understand llvm-svn: 187676
* Add matcher for float literals.Daniel Jasper2013-07-261-0/+11
| | | | | | Patch by Chris Gray! Thanks! llvm-svn: 187232
* Adds ctorInitializer and forEachConstructorInitializer matchers.Manuel Klimek2013-07-191-0/+11
| | | | llvm-svn: 186668
* Add support for polymorphic matchers. Use runtime type checking to determine ↵Samuel Benzaquen2013-06-211-4/+3
| | | | | | the right polymorphic overload to use. llvm-svn: 184558
* Adds the equalsBoundNode matcher.Manuel Klimek2013-06-201-0/+89
| | | | | | Most of the tests contributed by Edwin Vane. llvm-svn: 184427
* Implements declaratorDecl, parmVarDecl and hassTypeLoc matchers.Manuel Klimek2013-06-201-0/+19
| | | | llvm-svn: 184419
* Completely revamp node binding for AST matchers.Manuel Klimek2013-06-191-6/+113
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is in preparation for the backwards references to bound nodes, which will expose a lot more about how matches occur. Main changes: - instead of building the tree of bound nodes, we build a "set" of bound nodes and explode all possible match combinations while running through the matchers; this will allow us to also implement matchers that filter down the current set of matches, like "equalsBoundNode" - take the set of bound nodes at the start of the match into consideration when doing memoization; as part of that, reevaluated that memoization gives us benefits that are large enough (it still does - the effect on common match patterns is up to an order of magnitude) - reset the bound nodes when a node does not match, thus never leaking information from partial sub-matcher matches for failing matchers Effects: - we can now correctly "explode" combinatorial matches, for example: allOf(forEachDescendant(...bind("a")), forEachDescendant(...bind("b"))) will now trigger matches for all combinations of matching "a" and "b"s. - we now never expose bound nodes from partial matches in matchers that did not match in the end - this fixes a long-standing issue FIXMEs: - rename BoundNodesTreeBuilder to BoundNodesBuilder or BoundNodesSetBuilder, as we don't build a tree any more; this is out of scope for this change, though - we're seeing some performance regressions (around 10%), but I expect some performance tuning will get that back, and it's easily worth the increase in expressiveness for now llvm-svn: 184313
* Add an overridable MatchCallback::onEndOfTranslationUnit() function.Peter Collingbourne2013-05-281-0/+21
| | | | | | Differential Revision: http://llvm-reviews.chandlerc.com/D745 llvm-svn: 182798
* Add caseStmt(), defaultStmt(), eachCase() and hasCaseConstant() matchers.Peter Collingbourne2013-05-101-0/+25
| | | | | | Differential Revision: http://llvm-reviews.chandlerc.com/D744 llvm-svn: 181588
* Adding isConst() ASTMatcher for CXXMethodDecl nodesEdwin Vane2013-05-091-0/+7
| | | | | | Updated reference and unit tests. llvm-svn: 181522
* When deducing an 'auto' type, don't modify the type-as-written.Richard Smith2013-04-301-4/+6
| | | | llvm-svn: 180808
* Adding new AST Matchers isVirtual and isOverrideEdwin Vane2013-04-091-0/+21
| | | | | | | | isVirtual - matches CXXMethodDecl nodes for virtual methods isOverride - matches CXXMethodDecl nodes for methods that override virtual methods from a base class. Author: Philip Dunstan <phil@philipdunstan.com> llvm-svn: 179126
* Add matcher for NamespaceDecls.Daniel Jasper2013-04-081-2/+10
| | | | llvm-svn: 179027
* Adding a hasLocalQualifiers() AST Matcher.Edwin Vane2013-04-021-0/+11
| | | | | | Updated tests and docs. llvm-svn: 178556
* Adding parenType() and innerType() AST MatchersEdwin Vane2013-04-011-0/+13
| | | | | | Updated docs and tests. llvm-svn: 178487
* Implements memoization for ancestor matching.Manuel Klimek2013-03-141-2/+22
| | | | | | | | | | | This yields a log(#ast_nodes) worst-case improvement with matchers like stmt(unless(hasAncestor(...))). Also made the order of visitation for ancestor matches BFS, as the most common use cases (for example finding the closest enclosing function definition) rely on that. llvm-svn: 177081
* Adding lvalue and rvalue reference type matchersEdwin Vane2013-03-071-0/+52
| | | | | | | | Updated docs and tests. Reviewers: klimek, gribozavr llvm-svn: 176630
* New ASTMatchers and enhancement to hasOverloadedOperatorNameEdwin Vane2013-03-061-0/+25
| | | | | | | | | | | | | | | Added two new narrowing matchers: * hasMethod: aplies a matcher to a CXXRecordDecl's methods until a match is made or there are no more methods. * hasCanonicalType: applies a matcher to a QualType's canonicalType. Enhanced hasOverloadedOperatorName to work on CXXMethodDecl as well as CXXOperatorCallExpr. Updated tests and docs. Reviewers: klimek, gribozavr llvm-svn: 176556
* hasQualifer() matcher should return false if there's no qualifierEdwin Vane2013-03-041-0/+4
| | | | | | | | Instead of passing NULL on to sub-matcher, just return false. Updated tests and regenerated docs. Author: Tareq A Siraj <tareq.a.siraj@intel.com> llvm-svn: 176441
* Make the negative test of recordType depend on a specific record.Manuel Klimek2013-02-271-2/+4
| | | | | | Otherwise it'll break if there's a record type in the AST by default. llvm-svn: 176181
* Various additions to ASTMatcher library:Edwin Vane2013-02-251-1/+71
| | | | | | | | | | | | | | | | New type matchers: * recordType * elaboratedType New narrowing matchers: * hasQualifier * namesType * hasDeclContext Added tests and updated LibASTMatchersReference. Reviewers: klimek llvm-svn: 176047
* Adding hasDeclaration overload for TemplateSpecializationTypeEdwin Vane2013-02-251-0/+11
| | | | | | | | | | | | | | TemplateSpecializationType doesn't quite have getDecl(). Need to go through TemplateName to get a TemplateDecl. Added test cases for the hasDeclaration() overload for TemplateSpecializationType. Also introduced the type matcher templateSpecializationType() used by the new hasDeclaration() test case. Updated LibASTMatchersReference. Reviewers: klimek llvm-svn: 176025
* Support in hasDeclaration for types with getDecl()Edwin Vane2013-02-251-0/+6
| | | | | | | | | | | Re-introducing r175532. The has_getDecl metafunction didn't compile with Visual Studio. This revision uses approaches has_getDecl from a different angle that isn't a problem for Visual Studio. Added dedicated tests for the metafunction. Reviewers: klimek llvm-svn: 176024
* Reverting r176019. Corrupt patch.Edwin Vane2013-02-251-6/+0
| | | | llvm-svn: 176021
* Support in hasDeclaration for types with getDecl()Edwin Vane2013-02-251-0/+6
| | | | | | | | | | | Re-introducing r175532. The has_getDecl metafunction didn't compile with Visual Studio. This revision approaches has_getDecl from a different angle that isn't a problem for Visual Studio. Added dedicated tests for the metafunction. Reviewers: klimek llvm-svn: 176019
* Add matcher for AccessSpecDecls.Daniel Jasper2013-02-251-0/+40
| | | | | | | Also, add matchers isPrivate(), isProtected() and isPublic(), that restrict the matching of such AccessSpecDecls and all other Decls. llvm-svn: 176017
* Support in hasDeclaration for types with getDecl()Edwin Vane2013-02-191-4/+8
| | | | | | | | | | | | Using a new metafunction for detecting the presence of the member 'getDecl' in a type T, added support to hasDeclaration for any such type T. This allows hasDecl() to be replaced and enables several other subclasses of clang::Type to use hasDeclaration. Updated unittests and LibASTMatchersReference.html. Reviewers: klimek llvm-svn: 175532
* Clean up last use of dyn_cast on TypeLoc in ASTMatchersDavid Blaikie2013-02-181-5/+5
| | | | llvm-svn: 175454
* Adding more overloads for allOf matcherEdwin Vane2013-02-121-1/+16
| | | | | | | | Adding overloads of allOf accepting 4 and 5 arguments. Reviewer: klimek llvm-svn: 174967
* Implements equalsNode for Decl and Stmt.Manuel Klimek2013-02-071-0/+31
| | | | | | | | | This is a powerful tool when doing iterative refined matches, where another match is started inside the match callback of the first one; this allows for example to find out whether the node was in the condition or body of its parent if-statement. llvm-svn: 174605
* Adds a convenience function selectFirst to simplify matching.Manuel Klimek2013-02-061-12/+16
| | | | | | | | A very common use case is to search for the first occurrence of a certain node that is a descendant of another node. In that case, selectFirst significantly simplifies the code at the client side. llvm-svn: 174499
* Implements the convenience matcher findAll.Manuel Klimek2013-02-041-0/+28
| | | | | | | | | | | We found that findAll has been implemented incorrectly multiple times by various people using the matchers. To prevent further wasted development effort, it makes sense to add it as convenience matcher implemented as eachOf(m, forEachDescendant(m)). This patch also updates the docs with the new matchers. llvm-svn: 174320
* Add an eachOf matcher.Manuel Klimek2013-02-041-0/+24
| | | | | | | | | eachOf gives closure on the forEach and forEachDescendant matchers. Before, it was impossible to implement a findAll matcher, as matching the node or any of its descendants was not expressible (since anyOf only triggers the first match). llvm-svn: 174315
* Re-design the convenience interfaces on MatchFinder.Manuel Klimek2013-02-011-25/+34
| | | | | | | | | | | | First, this implements a match() method on MatchFinder; this allows us to get rid of the findAll implementation, as findAll is really a special case of recursive matchers on match. Instead of findAll, provide a convenience function match() that lets users iterate easily over the results instead of needing to implement callbacks. llvm-svn: 174172
* Adding tests since when I was asked whether this works I wasn'tManuel Klimek2012-12-101-0/+7
| | | | | | 100% sure. llvm-svn: 169725
* Implements multiple parents in the parent map.Manuel Klimek2012-12-061-0/+36
| | | | | | | Previously we would match the last visited parent, which in the case of template instantiations was the last instantiated template. llvm-svn: 169508
* Fix spelling I ran over while proof-reading tests.Manuel Klimek2012-12-041-1/+1
| | | | llvm-svn: 169271
* Fixes crash in isDerivedFrom for recursive templates.Manuel Klimek2012-12-041-0/+11
| | | | llvm-svn: 169262
* Add parameterCountIs() matcher.Daniel Jasper2012-12-041-0/+8
| | | | llvm-svn: 169257
* Sort the #include lines for unittests/...Chandler Carruth2012-12-041-1/+1
| | | | | | I've tried to place sensible headers at the top as main-module headers. llvm-svn: 169243
* Make hasDeclaration work for enums.Daniel Jasper2012-12-031-0/+6
| | | | llvm-svn: 169129
* Update unit tests not to rely on transitive includes.Benjamin Kramer2012-12-011-0/+1
| | | | llvm-svn: 169096
* Fix partial-match-bind-behavior with forEachDescendant() matchers.Daniel Jasper2012-11-161-0/+16
| | | | | | | | | | | | | | | | The problem is that a partial match of an (explicit or implicit) allOf matcher binds results, i.e. recordDecl(decl().bind("x"), hasName("A")) can very well bind a record that is not named "A". With this fix, the common cases of stumbling over this bug are fixed by the BoundNodesMap overwriting the results of a partial match. An error can still be created with a weird combination of anyOf and allOf (see inactive test). We need to decide whether this is worth fixing, as the fix will have performance impact. Review: http://llvm-reviews.chandlerc.com/D124 llvm-svn: 168177
* Do not use data recursion in ASTMatchFinder.Daniel Jasper2012-11-151-0/+19
| | | | | | The matchers rely on the complete AST being traversed as shown by the new test cases. llvm-svn: 168022
* Fix binding of nodes in case of forEach..() matchers.Daniel Jasper2012-11-111-0/+11
| | | | | | | | | | When recursively visiting the generated matches, the aggregated bindings need to be copied during the recursion. Otherwise, we they might not be properly overwritten (which is shown by the test), or there might be bound nodes present that were bound on a different matching branch. Review: http://llvm-reviews.chandlerc.com/D112 llvm-svn: 167695
* Insert interception point onStartOfTranslationUnit.Manuel Klimek2012-11-021-0/+21
| | | | | | | | | Often users of the ASTMatchers want to add tasks that are done once per translation unit, for example, cleaning up caches. Combined with the interception point for the end of source file one can add to the factory creation, this covers the cases we've seen users need. llvm-svn: 167271
* Implement descendant matchers for NestedNamespecifiersDaniel Jasper2012-10-301-0/+88
| | | | | | | | | This implements has(), hasDescendant(), forEach() and forEachDescendant() for NestedNameSpecifier and NestedNameSpecifierLoc matchers. Review: http://llvm-reviews.chandlerc.com/D86 llvm-svn: 167017
OpenPOWER on IntegriCloud