Граф коммитов

86 Коммитов

Автор SHA1 Сообщение Дата
Edwin Vane 7b69cd0944 Adding a hasLocalQualifiers() AST Matcher.
Updated tests and docs.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@178556 91177308-0d34-0410-b5e6-96231b3b80d8
2013-04-02 18:15:55 +00:00
Edwin Vane 88be2fdec7 Adding parenType() and innerType() AST Matchers
Updated docs and tests.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@178487 91177308-0d34-0410-b5e6-96231b3b80d8
2013-04-01 18:33:34 +00:00
Manuel Klimek 374516c8ec Implements memoization for ancestor matching.
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@177081 91177308-0d34-0410-b5e6-96231b3b80d8
2013-03-14 16:33:21 +00:00
Edwin Vane f4b4804272 Adding lvalue and rvalue reference type matchers
Updated docs and tests.
    
Reviewers: klimek, gribozavr


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176630 91177308-0d34-0410-b5e6-96231b3b80d8
2013-03-07 15:44:40 +00:00
Edwin Vane 6a19a97e57 New ASTMatchers and enhancement to hasOverloadedOperatorName
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


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176556 91177308-0d34-0410-b5e6-96231b3b80d8
2013-03-06 17:02:57 +00:00
Edwin Vane aec89ac22e hasQualifer() matcher should return false if there's no qualifier
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>


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176441 91177308-0d34-0410-b5e6-96231b3b80d8
2013-03-04 17:51:00 +00:00
Manuel Klimek 0cc798f29d Make the negative test of recordType depend on a specific record.
Otherwise it'll break if there's a record type in the AST by default.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176181 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-27 11:56:58 +00:00
Edwin Vane 742d9e77e3 Various additions to ASTMatcher library:
New type matchers:
* recordType
* elaboratedType

New narrowing matchers:
* hasQualifier
* namesType
* hasDeclContext

Added tests and updated LibASTMatchersReference.

Reviewers: klimek


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176047 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-25 20:43:32 +00:00
Edwin Vane 3abf77872c Adding hasDeclaration overload for TemplateSpecializationType
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


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176025 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-25 14:49:29 +00:00
Edwin Vane b45083d083 Support in hasDeclaration for types with getDecl()
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


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176024 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-25 14:32:42 +00:00
Edwin Vane 1b354b868c Reverting r176019. Corrupt patch.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176021 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-25 14:09:28 +00:00
Edwin Vane 0b6f23a23c Support in hasDeclaration for types with getDecl()
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


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176019 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-25 13:59:06 +00:00
Daniel Jasper f3197e9eb0 Add matcher for AccessSpecDecls.
Also, add matchers isPrivate(), isProtected() and isPublic(), that
restrict the matching of such AccessSpecDecls and all other Decls.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176017 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-25 12:02:08 +00:00
Edwin Vane 523806028d Support in hasDeclaration for types with getDecl()
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


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175532 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-19 17:14:34 +00:00
David Blaikie 5be093c0ef Clean up last use of dyn_cast on TypeLoc in ASTMatchers
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175454 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-18 19:04:16 +00:00
Edwin Vane 7f43fcf5d9 Adding more overloads for allOf matcher
Adding overloads of allOf accepting 4 and 5 arguments.
    
Reviewer: klimek



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174967 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-12 13:55:40 +00:00
Manuel Klimek fa37c5ca61 Implements equalsNode for Decl and Stmt.
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174605 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-07 12:42:10 +00:00
Manuel Klimek cf87bffc34 Adds a convenience function selectFirst to simplify matching.
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174499 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-06 10:33:21 +00:00
Manuel Klimek 152ea0e471 Implements the convenience matcher findAll.
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174320 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-04 10:59:20 +00:00
Manuel Klimek 7387673f83 Add an eachOf matcher.
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).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174315 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-04 09:42:38 +00:00
Manuel Klimek 60969f5f6b Re-design the convenience interfaces on MatchFinder.
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174172 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-01 13:41:35 +00:00
Chris Lattner 3a5fa0383c fix the unit tests too.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172907 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-19 18:30:39 +00:00
Dmitri Gribenko cfa88f8939 Remove useless 'llvm::' qualifier from names like StringRef and others that are
brought into 'clang' namespace by clang/Basic/LLVM.h


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172323 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-12 19:30:44 +00:00
Manuel Klimek ec33b6f644 Adding tests since when I was asked whether this works I wasn't
100% sure.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169725 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-10 07:08:53 +00:00
Manuel Klimek 30ace37150 Implements multiple parents in the parent map.
Previously we would match the last visited parent, which in the
case of template instantiations was the last instantiated template.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169508 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-06 14:42:48 +00:00
Manuel Klimek 8cb9bf577e Fix spelling I ran over while proof-reading tests.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169271 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-04 14:42:08 +00:00
Manuel Klimek 987c2f590f Fixes crash in isDerivedFrom for recursive templates.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169262 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-04 13:40:29 +00:00
Daniel Jasper 36e29d6732 Add parameterCountIs() matcher.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169257 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-04 11:54:27 +00:00
Chandler Carruth 1050e8b225 Sort the #include lines for unittests/...
I've tried to place sensible headers at the top as main-module headers.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169243 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-04 09:45:34 +00:00
NAKAMURA Takumi d031c6aa0c ASTTests, ASTMatchersTests: Move clangEdit before clangAst in USEDLIB.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169236 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-04 08:20:41 +00:00
NAKAMURA Takumi bf5bc4cba5 Untabify (in USEDLIBS, Makefile(s)).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169235 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-04 08:20:35 +00:00
Daniel Jasper 189f2e421d Make hasDeclaration work for enums.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169129 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-03 15:43:25 +00:00
Benjamin Kramer 8b9ed7106a Update unit tests not to rely on transitive includes.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169096 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-01 17:22:05 +00:00
Daniel Jasper 5f684e90c2 Fix partial-match-bind-behavior with forEachDescendant() matchers.
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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@168177 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-16 18:39:22 +00:00
Daniel Jasper 278057fd9f Do not use data recursion in ASTMatchFinder.
The matchers rely on the complete AST being traversed as shown by the new test cases.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@168022 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-15 03:29:05 +00:00
Daniel Jasper 11c98771ba Fix binding of nodes in case of forEach..() matchers.
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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167695 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-11 22:14:55 +00:00
Manuel Klimek e579328ec9 Insert interception point onStartOfTranslationUnit.
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167271 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-02 01:31:03 +00:00
Daniel Jasper d1ce3c178b Implement descendant matchers for NestedNamespecifiers
This implements has(), hasDescendant(), forEach() and
forEachDescendant() for NestedNameSpecifier and NestedNameSpecifierLoc
matchers.

Review: http://llvm-reviews.chandlerc.com/D86

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167017 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-30 15:42:00 +00:00
Daniel Jasper 452abbc76b Fix ASTMatchersTests to not create an overloaded-virtual warning.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166921 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-29 10:48:25 +00:00
Daniel Jasper a267cf6f87 Implement has(), hasDescendant(), forEach() and forEachDescendant() for
Types, QualTypes and TypeLocs.

Review: http://llvm-reviews.chandlerc.com/D83

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166917 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-29 10:14:44 +00:00
Manuel Klimek 3e2aa99e99 Adds the possibility to run ASTMatchFinder over arbitrary AST nodes.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166567 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-24 14:47:44 +00:00
Daniel Jasper c711af2ddb Make hasDeclaration() matcher work inside the memberExpr() matcher.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166479 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-23 15:46:39 +00:00
Manuel Klimek 70b9db9879 Implements the thisExpr matcher.
Patch by Gabor Horvath.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166477 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-23 10:40:50 +00:00
Daniel Jasper c99a3ad8c2 Implement hasParent()-matcher.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166421 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-22 16:26:51 +00:00
Daniel Jasper 1802daf853 Fix tests, which accidentally matched implicit code on specific
platforms to make buildbots happy.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166100 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-17 13:35:36 +00:00
Daniel Jasper ce62007526 First version of matchers for Types and TypeLocs.
Review: http://llvm-reviews.chandlerc.com/D47

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166094 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-17 08:52:59 +00:00
Daniel Jasper 1a00fee393 Fix ASTMatchersTests in configurations where
"#include <initializer_list>" is unavailable for whatever reason.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164944 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-01 15:05:34 +00:00
Daniel Jasper 31f7c08a0d Add matchers for selected C++11 features.
Patch by Gábor Horváth.
Review: http://llvm-reviews.chandlerc.com/D46

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164943 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-01 13:40:41 +00:00
Daniel Jasper aaa8e45b8e Fix refersToDeclaration()-matcher and add missing test case. This was
broken as of r164656 as TemplateArgument::getAsDecl() now asserts
instead of returning NULL for other template arugment kinds.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164896 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-29 15:55:18 +00:00
Daniel Jasper b54b7646b2 Add some matchers for basic AST nodes.
Patch by Gábor Horváth.
Review: http://llvm-reviews.chandlerc.com/D45

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164304 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-20 14:12:57 +00:00