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

86 Коммитов

Автор SHA1 Сообщение Дата
Daniel Jasper 08f0c53175 Fix isDerivedFrom matcher.
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164127 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-18 14:17:42 +00:00
Daniel Jasper e6d2a96cc9 Add missing matcher for C-style cast expressions.
Patch by Gábor Horváth.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164123 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-18 13:36:17 +00:00
Daniel Jasper 3680b4f749 Make all VariadicDynCast-Expr-matchers StatementMatchers
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164121 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-18 13:09:13 +00:00
Daniel Jasper a756443319 Create initial support for matching and binding NestedNameSpecifier(Loc)s.
Review: http://llvm-reviews.chandlerc.com/D39

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163794 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-13 13:11:25 +00:00
Daniel Jasper 63d88728d8 Rename isA to isSameOrDerivedFrom.
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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163740 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-12 21:14:15 +00:00
Daniel Jasper 76dafa7e64 Change the behavior of the isDerivedFrom-matcher to not match on the
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163385 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-07 12:48:17 +00:00
Manuel Klimek 579b120038 Implements hasAncestor.
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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163382 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-07 09:26:10 +00:00
Manuel Klimek a78d0d6203 Introduces DynTypedMatcher as a new concept that replaces the 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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163212 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-05 12:12:07 +00:00
Ted Kremenek 305c613af6 Split library clangRewrite into clangRewriteCore and clangRewriteFrontend.
This is similar to how we divide up the StaticAnalyzer libraries to separate
core functionality to what is clearly associated with Frontend actions.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163050 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-01 05:09:24 +00:00
Manuel Klimek 66341c596f Fixes a bug for binding memoized match results.
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@162936 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-30 19:41:06 +00:00
Nico Weber 50f88b99c6 Reland r160052: Default to -std=c++11 on Windows.
Also update the tests that rely on c++98 to explicitly mention that.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@162890 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-30 02:08:31 +00:00
Sam Panzer e16acd3817 New matcher for MaterializeTemporaryExpr
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@162609 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-24 22:04:44 +00:00
Daniel Jasper 2dc75ed2ef Rename the ASTMatchers to better match AST nodes. Now, all
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@162536 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-24 05:12:34 +00:00
Dmitri Gribenko 02ed37f95e AST Matchers tests: test that member() matches member allocation functions:
declare size_t in system-independent way.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@162158 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-18 00:41:04 +00:00
Dmitri Gribenko 671a045cc6 AST Matchers tests: test that member() matches member allocation functions.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@162153 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-18 00:29:27 +00:00
Dmitri Gribenko 8456ae6027 AST Matchers: introduce functionTemplate(), classTemplate() and
isExplicitTemplateSpecialization() matchers which do what their name says.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@162115 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-17 18:42:47 +00:00
Sam Panzer 425f41b370 Matchers related to DeclStmt for matching the count of declarations, a particular declaration within the statement, and single-Decl DeclStmts.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@162027 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-16 17:20:59 +00:00
Sam Panzer 089e5b3bf2 Matchers which correspond to CastExpr, IgnoreImpCasts, IgnoreParenCasts, and IgnoreParenImpCasts
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@162025 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-16 16:58:10 +00:00
Daniel Jasper 8cc7efa2da Add ASTMatcher for matching extern "C" function declarations.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161974 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-15 18:52:19 +00:00
Chad Rosier 1a5d421c26 [ms-inline asm] Add various MC components to clang build to support MS-style inline assembly.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161594 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-09 17:17:01 +00:00
Chad Rosier fa1d30ddb1 Add various MC components to clang build to support MS-style inline assembly.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161498 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-08 16:27:29 +00:00
Daniel Jasper 371f939132 Add missing tests for class template specialization and template
argument matchers.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161102 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-01 08:40:24 +00:00
Daniel Jasper 9bd2809085 Fix for ASTMatchFinder to visit a functions parameter declarations.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160947 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-30 05:03:25 +00:00
Manuel Klimek 715c9568ee Introduces the 'decl' matcher which was missing for a while
and became necessary with the change to require BindableMatchers
for binding.

Also fixes PR 13445: "hasSourceExpression only works for implicit casts".



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160716 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-25 10:02:02 +00:00
Manuel Klimek 9f17408d50 Introduces a new concept for binding results to matchers
as per Chandler's request:
- introduces a new matcher base type BindableMatcher that
  provides the bind() call
- makes all dynamic-cast matcher creation functions return
  BindableMatchers; the special case about dynamic-cast
  matchers is that the node they match on and the node
  their child matchers match on are the same node, just
  casted to a different type; thus, there is no ambiguity
  on what bind() matches on; additionally, those are the
  matchers that we name with nouns in the matcher language,
  so it's easy for users to intuitively know which matchers
  are bindable

To make this change possible, we got rid of a non-orthogonal
implementation of thisPointerType, which had an implicit
dynamic-cast matcher from CallExpr to CXXMemberCallExpr; as
alternative, we now provide a memberCall dynamic-cast matcher
and thisPointerType is a predicate on CXXMemberCallExpr.

Last, the ArgumentAdaptingMatcher is actually not required
for the implementation of makeDynCastAllOfComposite - this
simplification makes it more obvious where the bind() call
can be used based on the matcher creation function types.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160673 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-24 13:37:29 +00:00
Daniel Jasper d5c66dd664 Move RefactoringCallbacks to Tooling to avoid dependency from
ASTMatchers (lower level abstraction) to Tooling (higher level
abstraction).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160351 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-17 08:03:01 +00:00
Daniel Jasper 20b802d186 Make the isDerivedFrom matcher more generic.
It now accepts an arbitrary inner matcher but is fully backwards
compatible.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160348 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-17 07:39:27 +00:00
Daniel Jasper fe7beeb421 Add refactoring callbacks to make common kinds of refactorings easy.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160255 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-16 09:18:17 +00:00
Daniel Jasper ff2fcb8db2 Fix spelling of anyOf matcher and add missing test.
Patch by Sam Panzer!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160233 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-15 19:57:12 +00:00
Daniel Jasper 6a12449ec8 This commit combines three patches to the ASTMatchers.
One adds matchers for the various parts of a for loop (initializer, condition,
increment), as well as extending the hasBody matcher to work for while and
do-while loops. The second patch adds an isInteger matcher for types.
The third patch fixes a bug in allOf, where a few of the name chages
(AllOf --> allOf) had been missed.

All matchers come with unit tests.

Patches by Sam Panzer!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160115 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-12 08:50:38 +00:00
Daniel Jasper e0e6b9e79a Add more matchers and do cleanups.
Reviewers: klimek

    Differential Revision: http://ec2-50-18-127-156.us-west-1.compute.amazonaws.com/D2

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160013 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-10 20:20:19 +00:00
Benjamin Kramer 78a0ce4ed3 Disable death tests on platforms which don't support them.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160000 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-10 17:30:44 +00:00
Manuel Klimek e265c87793 Fixes the MSVC build.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159992 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-10 14:21:30 +00:00
Manuel Klimek 28c82ee1ae Another fix for the configure build: correct order of dependencies.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159809 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-06 08:13:45 +00:00
Manuel Klimek c76dfb451a Build-fix: Remove non-existent directories from Makefiles.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159807 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-06 06:00:30 +00:00
Manuel Klimek 4da216637f Adds the AST Matcher library, which provides a in-C++ DSL to express
matches on interesting parts of the AST, and callback mechanisms to
act on them.




git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159805 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-06 05:48:52 +00:00