Commit Graph

108 Commits

Author SHA1 Message Date
Joey Gouly 0d9a2b2205 [ASTMatchers] Move the 'isImplicit' matcher from CXXConstructorDecl to Decl.
llvm-svn: 209006
2014-05-16 19:31:08 +00:00
Samuel Benzaquen f10662923a Add matcher for ExprWithCleanups.
Summary: Add matcher for ExprWithCleanups.

Reviewers: klimek

CC: cfe-commits, klimek

Differential Revision: http://llvm-reviews.chandlerc.com/D3248

llvm-svn: 205420
2014-04-02 13:12:14 +00:00
David Blaikie abe1a398e3 Render anonymous entities as '(anonymous <thing>)' (and lambdas as '(lambda at ... )')
For namespaces, this is consistent with mangling and GCC's debug info
behavior. For structs, GCC uses <anonymous struct> but we prefer
consistency between all anonymous entities but don't want to confuse
them with template arguments, etc, so we'll just go with parens in all
cases.

llvm-svn: 205398
2014-04-02 05:58:29 +00:00
Saleem Abdulrasool 377066a5f5 Use the new Windows environment for target detection
This follows the LLVM change to canonicalise the Windows target triple
spellings.  Rather than treating each Windows environment as a single entity,
the environments are now modelled properly as an environment.  This is a
mechanical change to convert the triple use to reflect that change.

llvm-svn: 204978
2014-03-27 22:50:18 +00:00
Manuel Klimek ce68f7714a Fixes a bug in DynTypedNode.
Two DynTypedNodes can be equal if they do not have the same node type,
because DynTypedNodes for the same underlying object might have been
created from different types (for example, Decl vs VarDecl).

llvm-svn: 204722
2014-03-25 14:39:26 +00:00
Ahmed Charles b89843299a Replace OwningPtr with std::unique_ptr.
This compiles cleanly with lldb/lld/clang-tools-extra/llvm.

llvm-svn: 203279
2014-03-07 20:03:18 +00:00
David Majnemer 197e2103a2 Speculatively fix MSVC buildbots
llvm-svn: 202938
2014-03-05 06:32:38 +00:00
Craig Topper a798a9db93 Switch all uses of LLVM_OVERRIDE to just use 'override' directly.
llvm-svn: 202625
2014-03-02 09:32:10 +00:00
Dmitri Gribenko 51c1b55bc2 ASTMatchers: added CXXMethodDecl matcher isPure()
The isPure() CXXMethodDecl matcher matches pure method declaration like "A::x"
in this example:

class A {
  virtual void x() = 0;
}

Patch by Konrad Kleine.

llvm-svn: 202012
2014-02-24 09:27:46 +00:00
Peter Collingbourne 564597fd26 Add TemplateSpecializationType polymorphism for hasTemplateArgument and
hasAnyTemplateArgument, and (out of necessity) an isExpr matcher.

Also updates the TemplateArgument doxygen to reflect reality for
non-canonical template arguments.

Differential Revision: http://llvm-reviews.chandlerc.com/D2810

llvm-svn: 201804
2014-02-20 19:18:03 +00:00
NAKAMURA Takumi 7d2da0b2ae clang/unittests/AST,ASTMatchers: Remove _MSC_VER.
llvm-svn: 201485
2014-02-16 10:16:09 +00:00
David Blaikie 8972f4e966 Consistently print anonymous namespace names as "<anonymous namespace>"
For some reason we have two bits of code handling this printing:

lib/AST/Decl.cpp:        OS << "<anonymous namespace>";
lib/AST/TypePrinter.cpp:      OS << "<anonymous namespace>::";

it would be nice if we only had one...

llvm-svn: 201437
2014-02-14 22:12:54 +00:00
Peter Collingbourne 1fec3dfe43 Add isListInitialization matcher.
Differential Revision: http://llvm-reviews.chandlerc.com/D2708

llvm-svn: 200949
2014-02-06 21:52:24 +00:00
Richard Smith 3d584b0ced PR18128: a lambda capture-default is not permitted for a non-local lambda
expression.

llvm-svn: 200948
2014-02-06 21:49:08 +00:00
Alexander Kornienko 9b539e1dd9 Added the hasLoopVariable sub-matcher for forRangeStmt.
Summary:
This sub-matcher makes it possible to access directly the range-based for
loop variable: forRangeStmt(hasLoopVariable(anything()).bind(...)).
I've tried to re-generate the docs, but the diffs seem to include much more than
this change could cause, so I'd better leave docs update to someone who knows
the intended changes in the contents better.

Reviewers: klimek

Reviewed By: klimek

CC: cfe-commits, klimek

Differential Revision: http://llvm-reviews.chandlerc.com/D2702

llvm-svn: 200850
2014-02-05 16:35:08 +00:00
Ismail Pazarbasi 1121de36c2 Fix string-literal to char* conversion in overload resolution for C++11
String literal to char* conversion is deprecated in C++03, and is removed in
C++11. We still accept this conversion in C++11 mode as an extension, if we find
it in the best viable function.

llvm-svn: 199513
2014-01-17 21:08:52 +00:00
Alp Toker 8db6e7a972 Fix 'declartion' typos
llvm-svn: 198549
2014-01-05 06:38:57 +00:00
Peter Collingbourne a2334162cf Introduce MatchFinder::matchAST.
Differential Revision: http://llvm-reviews.chandlerc.com/D2115

llvm-svn: 194223
2013-11-07 22:30:36 +00:00
Peter Collingbourne 2b94713053 Re-introduce MatchFinder::addDynamicMatcher.
Differential Revision: http://llvm-reviews.chandlerc.com/D2114

llvm-svn: 194222
2013-11-07 22:30:32 +00:00
Peter Collingbourne 093a729e03 Introduce BoundNodes::getMap.
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
2013-11-06 00:27:07 +00:00
Michael Han c90d12d1df Teach RAV to visit parameter variable declarations of implicit functions. 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
2013-09-11 15:53:29 +00:00
Manuel Klimek 1863e505ce Fix crash when encountering alias templates in isDerivedFrom matches.
- 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
2013-08-02 21:24:09 +00:00
Daniel Jasper 91f1c8ca27 Add matcher for float literals.
Patch by Chris Gray! Thanks!

llvm-svn: 187232
2013-07-26 18:52:58 +00:00
Manuel Klimek ba46fc01a8 Adds ctorInitializer and forEachConstructorInitializer matchers.
llvm-svn: 186668
2013-07-19 11:50:54 +00:00
Samuel Benzaquen c6f2c9b566 Add support for polymorphic matchers. Use runtime type checking to determine the right polymorphic overload to use.
llvm-svn: 184558
2013-06-21 15:51:31 +00:00
Manuel Klimek bbb758577f Adds the equalsBoundNode matcher.
Most of the tests contributed by Edwin Vane.

llvm-svn: 184427
2013-06-20 14:06:32 +00:00
Manuel Klimek c16c652ca5 Implements declaratorDecl, parmVarDecl and hassTypeLoc matchers.
llvm-svn: 184419
2013-06-20 13:08:29 +00:00
Manuel Klimek a0c025f5d2 Completely revamp node binding for AST matchers.
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
2013-06-19 15:42:45 +00:00
Peter Collingbourne 6a55bb2307 Add an overridable MatchCallback::onEndOfTranslationUnit() function.
Differential Revision: http://llvm-reviews.chandlerc.com/D745

llvm-svn: 182798
2013-05-28 19:21:51 +00:00
Peter Collingbourne 3154a10bcb Add caseStmt(), defaultStmt(), eachCase() and hasCaseConstant() matchers.
Differential Revision: http://llvm-reviews.chandlerc.com/D744

llvm-svn: 181588
2013-05-10 11:52:02 +00:00
Edwin Vane fc4f7dc0a6 Adding isConst() ASTMatcher for CXXMethodDecl nodes
Updated reference and unit tests.

llvm-svn: 181522
2013-05-09 17:00:17 +00:00
Richard Smith 061f1e21be When deducing an 'auto' type, don't modify the type-as-written.
llvm-svn: 180808
2013-04-30 21:23:01 +00:00
Edwin Vane 37ee1d7b80 Adding new AST Matchers isVirtual and isOverride
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
2013-04-09 20:46:36 +00:00
Daniel Jasper 9fcdc461ed Add matcher for NamespaceDecls.
llvm-svn: 179027
2013-04-08 16:44:05 +00:00
Edwin Vane 119d3dfcba Adding a hasLocalQualifiers() AST Matcher.
Updated tests and docs.

llvm-svn: 178556
2013-04-02 18:15:55 +00:00
Edwin Vane ec0748068e Adding parenType() and innerType() AST Matchers
Updated docs and tests.

llvm-svn: 178487
2013-04-01 18:33:34 +00:00
Manuel Klimek b64d6b7fee 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.

llvm-svn: 177081
2013-03-14 16:33:21 +00:00
Edwin Vane 2a760d02f7 Adding lvalue and rvalue reference type matchers
Updated docs and tests.
    
Reviewers: klimek, gribozavr

llvm-svn: 176630
2013-03-07 15:44:40 +00:00
Edwin Vane 0a4836ed0e 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
llvm-svn: 176556
2013-03-06 17:02:57 +00:00
Edwin Vane 6972f6d3c7 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>
llvm-svn: 176441
2013-03-04 17:51:00 +00:00
Manuel Klimek 59b0af6381 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.

llvm-svn: 176181
2013-02-27 11:56:58 +00:00
Edwin Vane b6eae14c15 Various additions to ASTMatcher library:
New type matchers:
* recordType
* elaboratedType

New narrowing matchers:
* hasQualifier
* namesType
* hasDeclContext

Added tests and updated LibASTMatchersReference.

Reviewers: klimek
llvm-svn: 176047
2013-02-25 20:43:32 +00:00
Edwin Vane f901b71921 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
llvm-svn: 176025
2013-02-25 14:49:29 +00:00
Edwin Vane ed93645739 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
llvm-svn: 176024
2013-02-25 14:32:42 +00:00
Edwin Vane d0dfa07b44 Reverting r176019. Corrupt patch.
llvm-svn: 176021
2013-02-25 14:09:28 +00:00
Edwin Vane 8342598d1b 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
llvm-svn: 176019
2013-02-25 13:59:06 +00:00
Daniel Jasper 639522ca35 Add matcher for AccessSpecDecls.
Also, add matchers isPrivate(), isProtected() and isPublic(), that
restrict the matching of such AccessSpecDecls and all other Decls.

llvm-svn: 176017
2013-02-25 12:02:08 +00:00
Edwin Vane 2c197e0939 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
llvm-svn: 175532
2013-02-19 17:14:34 +00:00
David Blaikie b61d087d40 Clean up last use of dyn_cast on TypeLoc in ASTMatchers
llvm-svn: 175454
2013-02-18 19:04:16 +00:00
Edwin Vane e9dd3608ea Adding more overloads for allOf matcher
Adding overloads of allOf accepting 4 and 5 arguments.
    
Reviewer: klimek

llvm-svn: 174967
2013-02-12 13:55:40 +00:00