summaryrefslogtreecommitdiffstats
path: root/clang/unittests/ASTMatchers
Commit message (Collapse)AuthorAgeFilesLines
...
* 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
* fix the unit tests too.Chris Lattner2013-01-192-1/+2
| | | | llvm-svn: 172907
* Remove useless 'llvm::' qualifier from names like StringRef and others that areDmitri Gribenko2013-01-121-1/+1
| | | | | | brought into 'clang' namespace by clang/Basic/LLVM.h llvm-svn: 172323
* 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
* ASTTests, ASTMatchersTests: Move clangEdit before clangAst in USEDLIB.NAKAMURA Takumi2012-12-041-1/+1
| | | | llvm-svn: 169236
* Untabify (in USEDLIBS, Makefile(s)).NAKAMURA Takumi2012-12-041-1/+1
| | | | llvm-svn: 169235
* 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-112-1/+12
| | | | | | | | | | 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
* Fix ASTMatchersTests to not create an overloaded-virtual warning.Daniel Jasper2012-10-292-4/+11
| | | | llvm-svn: 166921
* Implement has(), hasDescendant(), forEach() and forEachDescendant() forDaniel Jasper2012-10-291-52/+113
| | | | | | | Types, QualTypes and TypeLocs. Review: http://llvm-reviews.chandlerc.com/D83 llvm-svn: 166917
* Adds the possibility to run ASTMatchFinder over arbitrary AST nodes.Manuel Klimek2012-10-242-2/+42
| | | | llvm-svn: 166567
* Make hasDeclaration() matcher work inside the memberExpr() matcher.Daniel Jasper2012-10-231-0/+9
| | | | llvm-svn: 166479
* Implements the thisExpr matcher.Manuel Klimek2012-10-231-0/+7
| | | | | | Patch by Gabor Horvath. llvm-svn: 166477
* Implement hasParent()-matcher.Daniel Jasper2012-10-221-0/+12
| | | | llvm-svn: 166421
* Fix tests, which accidentally matched implicit code on specificDaniel Jasper2012-10-171-26/+44
| | | | | | platforms to make buildbots happy. llvm-svn: 166100
* First version of matchers for Types and TypeLocs.Daniel Jasper2012-10-171-2/+181
| | | | | Review: http://llvm-reviews.chandlerc.com/D47 llvm-svn: 166094
* Fix ASTMatchersTests in configurations whereDaniel Jasper2012-10-011-4/+4
| | | | | | "#include <initializer_list>" is unavailable for whatever reason. llvm-svn: 164944
* Add matchers for selected C++11 features.Daniel Jasper2012-10-012-9/+41
| | | | | | | Patch by Gábor Horváth. Review: http://llvm-reviews.chandlerc.com/D46 llvm-svn: 164943
* Fix refersToDeclaration()-matcher and add missing test case. This wasDaniel Jasper2012-09-291-0/+6
| | | | | | | broken as of r164656 as TemplateArgument::getAsDecl() now asserts instead of returning NULL for other template arugment kinds. llvm-svn: 164896
* Add some matchers for basic AST nodes.Daniel Jasper2012-09-201-0/+35
| | | | | | | Patch by Gábor Horváth. Review: http://llvm-reviews.chandlerc.com/D45 llvm-svn: 164304
* Fix isDerivedFrom matcher.Daniel Jasper2012-09-181-0/+10
| | | | | | | | | | | | | Without this patch, the isDerivedFrom matcher asserts in the "assert(ClassDecl != NULL);" in the new test, as a DependentTemplateSpecilizationType is not a sub-type of TemplateSpecializationType and also does not offer getAsCXXRecordDecl(). I am not sure why this did not cause problems before. It is now (after the changed implementation of isDerivedFrom) easier to write a matcher that actually gets into this branch of the code. llvm-svn: 164127
* Add missing matcher for C-style cast expressions.Daniel Jasper2012-09-181-0/+14
| | | | | | Patch by Gábor Horváth. llvm-svn: 164123
* Make all VariadicDynCast-Expr-matchers StatementMatchersDaniel Jasper2012-09-181-70/+64
| | | | | | | | | | Having Expr-subclass-matchers being VariadicDynCast-Expr-matchers does not provide additional type safety and just makes using them harder. In the clang AST, expressions are always statements and an expression matcher can be used anywhere, a statement matcher is expected. Any given matcher definition still has at least one noun. llvm-svn: 164121
* Create initial support for matching and binding NestedNameSpecifier(Loc)s.Daniel Jasper2012-09-131-45/+95
| | | | | Review: http://llvm-reviews.chandlerc.com/D39 llvm-svn: 163794
* Rename isA to isSameOrDerivedFrom.Daniel Jasper2012-09-121-1/+1
| | | | | | | | | | | There are two evils we can choose from: - Name overlap between isA-matcher and llvm::isa<>() - Bad name for what the isA-matcher currently does After some discussion we have agreed to go with the latter evil. Review: http://llvm-reviews.chandlerc.com/D40 llvm-svn: 163740
* Change the behavior of the isDerivedFrom-matcher to not match on theDaniel Jasper2012-09-071-4/+10
| | | | | | | | | | | | class itself. This caused some confusion (intuitively, a class is not derived from itself) and makes it hard to write certain matchers, e.g. "match and bind any pair of base and subclass". The original behavior can be achieved with a new isA-matcher. Similar to all other matchers, this matcher has the same behavior and name as the corresponding AST-entity - in this case the isa<>() function. llvm-svn: 163385
* Implements hasAncestor.Manuel Klimek2012-09-071-10/+89
| | | | | | | | | | | | | | | | | | | | | | Implements the hasAncestor matcher. This builds on the previous patch that introduced DynTypedNode to build up a parent map for an additional degree of freedom in the AST traversal. The map is only built once we hit an hasAncestor matcher, in order to not slow down matching for cases where this is not needed. We could implement some speed-ups for special cases, like building up the parent map as we go and only building up the full map if we break out of the already visited part of the tree, but that is probably not going to be worth it, and would make the code significantly more complex. Major TODOs are: - implement hasParent - implement type traversal - implement memoization in hasAncestor llvm-svn: 163382
* Introduces DynTypedMatcher as a new concept that replaces the ↵Manuel Klimek2012-09-051-2/+1
| | | | | | | | | | | | | | | | | | | | | | | UntypedBaseMatcher and TypedMatcher. Due to DynTypedNode the basic dynamically typed matcher interface can now be simplified. Also switches the traversal interfaces to use DynTypedNode; this is in preperation for the hasAncestor implementation, and also allows us to need fewer changes when we want to add new nodes to traverse, thus making the code a little more decoupled. Main design concerns: I went back towards the original design of getNodeAs to return a pointer, and switched DynTypedNode::get to always return a pointer (in case of value types like QualType the pointer points into the storage of DynTypedNode, thus allowing us to treat all the nodes the same from the point of view of a user of the DynTypedNodes. Adding the QualType implementation for DynTypedNode was needed for the recursive traversal interface changes. llvm-svn: 163212
* Split library clangRewrite into clangRewriteCore and clangRewriteFrontend.Ted Kremenek2012-09-011-1/+2
| | | | | | | This is similar to how we divide up the StaticAnalyzer libraries to separate core functionality to what is clearly associated with Frontend actions. llvm-svn: 163050
* Fixes a bug for binding memoized match results.Manuel Klimek2012-08-301-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | Intorduces an abstraction for DynTypedNode which makes is impossible to create in ways that introduced the bug; also hides the implementation details of the template magic away from the user and prepares the code for adding QualType and TypeLoc bindings, as well as using DynTypedNode instead of overloads for child and ancestor matching. getNodeAs<T> was changed towards a non-pointer type, as we'll want QualType and TypeLoc nodes to be returned by value (the alternative would be to create new storage which is prohibitively costly if we want to use it for child / ancestor matching). DynTypedNode is moved into a new header ASTTypeTraits.h, as it is completely independent of the rest of the matcher infrastructure - if the need comes up, we can move it to a more common place. The interface for users before the introduction of the common storage change remains the same, minus the introduced bug, for which a regression test was added. llvm-svn: 162936
* Reland r160052: Default to -std=c++11 on Windows.Nico Weber2012-08-301-3/+7
| | | | | | Also update the tests that rely on c++98 to explicitly mention that. llvm-svn: 162890
* New matcher for MaterializeTemporaryExprSam Panzer2012-08-241-0/+35
| | | | llvm-svn: 162609
* Rename the ASTMatchers to better match AST nodes. Now, allDaniel Jasper2012-08-241-458/+464
| | | | | | | | | ASTMatchers have the same name as the corresponding AST nodes but are lower case. The only exceptions are the "CXX" prefixes which are not copied over to the matcher names as the goal is to actually remove these prefixes from the AST node names. llvm-svn: 162536
* AST Matchers tests: test that member() matches member allocation functions:Dmitri Gribenko2012-08-181-2/+2
| | | | | | declare size_t in system-independent way. llvm-svn: 162158
* AST Matchers tests: test that member() matches member allocation functions.Dmitri Gribenko2012-08-181-0/+13
| | | | llvm-svn: 162153
* AST Matchers: introduce functionTemplate(), classTemplate() andDmitri Gribenko2012-08-171-0/+91
| | | | | | isExplicitTemplateSpecialization() matchers which do what their name says. llvm-svn: 162115
* Matchers related to DeclStmt for matching the count of declarations, a ↵Sam Panzer2012-08-161-0/+34
| | | | | | particular declaration within the statement, and single-Decl DeclStmts. llvm-svn: 162027
* Matchers which correspond to CastExpr, IgnoreImpCasts, IgnoreParenCasts, and ↵Sam Panzer2012-08-161-0/+217
| | | | | | IgnoreParenImpCasts llvm-svn: 162025
* Add ASTMatcher for matching extern "C" function declarations.Daniel Jasper2012-08-151-0/+6
| | | | llvm-svn: 161974
OpenPOWER on IntegriCloud