summaryrefslogtreecommitdiffstats
path: root/clang/unittests/ASTMatchers/ASTMatchersTest.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Add voidType() matcher.Samuel Benzaquen2014-12-151-0/+5
| | | | | | | | | | | | Summary: Add voidType() matcher. Reviewers: klimek Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D6656 llvm-svn: 224250
* Re-apply r222646 (was reverted in r222667). Adding 4 ASTMatchers: ↵Manuel Klimek2014-11-251-0/+53
| | | | | | | | | | | | | | | | | | | | | | | typedefDecl, isInMainFile, isInSystemFile, isInFileMatchingName Change to original: ifndef out tests in Windows due to /-separated paths. Summary: Often one is only interested in matches within the main-file or matches that are not within a system-header, for which this patch adds isInMainFile and isInSystemFile. They take no arguments and narrow down the matches. The isInFileMatchingName is mainly thought for interactive clang-query-sessions, to make a matcher more specific without restarting the session with the files you are interested in for that moment. It takes a string that will be used as regular-expression to match the filename of where the matched node is expanded. Patch by Hendrik von Prince. llvm-svn: 222765
* Reverting r222646; the tests do not pass on Windows. Also reverts r222664, ↵Aaron Ballman2014-11-241-48/+0
| | | | | | which was required for r222646 to compile with Visual Studio 2012. llvm-svn: 222667
* Unbreaking the MSVC 2012 build; however, these tests still fail on Windows.Aaron Ballman2014-11-241-5/+12
| | | | llvm-svn: 222664
* Adding 4 ASTMatchers: typedefDecl, isInMainFile, isInSystemFile, ↵Manuel Klimek2014-11-241-0/+41
| | | | | | | | | | | | | | | | | | | | isInFileMatchingName Summary: Often one is only interested in matches within the main-file or matches that are not within a system-header, for which this patch adds isInMainFile and isInSystemFile. They take no arguments and narrow down the matches. The isInFileMatchingName is mainly thought for interactive clang-query-sessions, to make a matcher more specific without restarting the session with the files you are interested in for that moment. It takes a string that will be used as regular-expression to match the filename of where the matched node is expanded. Patch by Hendrik von Prince. llvm-svn: 222646
* Add valueDecl() matcher.Samuel Benzaquen2014-10-281-0/+7
| | | | | | | | | | | | Summary: Add valueDecl() matcher. Reviewers: klimek Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D6005 llvm-svn: 220776
* Fix segfault in hasDeclContext for nodes that have no decl context.Samuel Benzaquen2014-10-271-0/+2
| | | | | | | | | | | | | | Summary: Some declarations do not have a declaration context, like TranslationUnitDecl. Fix hasDeclContext() to not segfault on these nodes. Reviewers: klimek Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D6003 llvm-svn: 220719
* Add support for profiling the matchers used.Samuel Benzaquen2014-10-221-0/+19
| | | | | | | | | | | | | | | Summary: Add support for profiling the matchers used. This will be connected with clang-tidy to generate a report to determine and debug slow checks. Reviewers: alexfh Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D5911 llvm-svn: 220418
* Fix bug in DynTypedMatcher::constructVariadic() that would cause false ↵Samuel Benzaquen2014-10-131-0/+5
| | | | | | | | | | | | | | | | | | | negatives. Summary: Change r219118 fixed the bug for anyOf and eachOf, but it is still present for unless. The variadic wrapper doesn't have enough information to know how to restrict the type. Different operators handle restrict failures in different ways. Reviewers: klimek Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D5731 llvm-svn: 219622
* Implement various matchers around template argument handling.Manuel Klimek2014-10-091-0/+58
| | | | llvm-svn: 219408
* Fix bug in DynTypedMatcher::constructVariadic() that would cause false ↵Samuel Benzaquen2014-10-061-0/+5
| | | | | | | | | | | | | | | | | | | negatives. Summary: DynTypedMatcher::constructVariadic() where the restrict kind of the different matchers are not related causes the matcher to have a "None" restrict kind. This causes false negatives for anyOf and eachOf. Change the logic to get a common ancestor if there is one. Also added regression tests that fail without the fix. Reviewers: klimek Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D5580 llvm-svn: 219118
* Adds 'override' to overriding methods. NFC.Fariborz Jahanian2014-10-011-2/+2
| | | | | | These were uncoveredby my yet undelivered patch. llvm-svn: 218774
* Refactor Matcher<T> and DynTypedMatcher to reduce overhead of casts.Samuel Benzaquen2014-10-011-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This change introduces DynMatcherInterface and changes the internal representation of DynTypedMatcher and Matcher<T> to use a generic interface instead. It removes unnecessary indirections and virtual function calls when converting matchers by implicit and dynamic casts. DynTypedMatcher now remembers the stricter type in the chain of casts and checks it before calling into DynMatcherInterface. This change improves our clang-tidy related benchmark by ~14%. Also, it opens the door for more optimizations of this kind that are coming in future changes. As a side effect of removing these template instantiations, it also speeds up compilation of Dynamic/Registry.cpp by ~17% and reduces the number of symbols generated by ~30%. Reviewers: klimek Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D5542 llvm-svn: 218769
* Revert r218616, "Refactor Matcher<T> and DynTypedMatcher to reduce overhead ↵NAKAMURA Takumi2014-09-291-14/+0
| | | | | | | | | | | | of casts." MSC17, aka VS2012, cannot compile it. clang/include/clang/ASTMatchers/ASTMatchersInternal.h(387) : error C4519: default template arguments are only allowed on a class template clang/include/clang/ASTMatchers/ASTMatchersInternal.h(443) : see reference to class template instantiation 'clang::ast_matchers::internal::Matcher<T>' being compiled llvm-svn: 218648
* Refactor Matcher<T> and DynTypedMatcher to reduce overhead of casts.Samuel Benzaquen2014-09-291-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This change introduces DynMatcherInterface and changes the internal representation of DynTypedMatcher and Matcher<T> to use a generic interface instead. It removes unnecessary indirections and virtual function calls when converting matchers by implicit and dynamic casts. DynTypedMatcher now remembers the stricter type in the chain of casts and checks it before calling into DynMatcherInterface. This change improves our clang-tidy related benchmark by ~14%. Also, it opens the door for more optimizations of this kind that are coming in future changes. As a side effect of removing these template instantiations, it also speeds up compilation of Dynamic/Registry.cpp by ~17% and reduces the number of symbols generated by ~30%. Reviewers: klimek Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D5485 llvm-svn: 218616
* Add matcher for linkage specificationManuel Klimek2014-09-041-0/+5
| | | | | | Patch by Jacques Pienaar. llvm-svn: 217135
* ASTMatchers: Add a matcher to detect whether a decl or stmt is inside a ↵Benjamin Kramer2014-09-031-0/+56
| | | | | | | | | | | template instantiation. This is hoisted from clang-tidy where it's used everywhere. The implementation is not particularly efficient right now, but there is no easy fix for that. Differential Revision: http://reviews.llvm.org/D5085 llvm-svn: 217029
* Add hasAttr matcher for declarations.Manuel Klimek2014-08-251-9/+10
| | | | | | | | Delete special-case CUDA attribute matchers. Patch by Jacques Pienaar. llvm-svn: 216379
* Add isDeleted() matcher for FunctionDecl nodes.Samuel Benzaquen2014-08-151-0/+7
| | | | | | | | | | Reviewers: klimek Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D4911 llvm-svn: 215714
* Adds AST matchers for matching CUDA declarations.Manuel Klimek2014-08-051-0/+18
| | | | | | Patch by Jacques Pienaar. llvm-svn: 214852
* Prevent assert in ASTMatchFinder.Daniel Jasper2014-07-231-0/+6
| | | | | | | | | | | | If nodes without memoization data (e.g. TypeLocs) are bound to specific names, that effectively prevents memoization as those elements cannot be compared effectively. If it is tried anyway, this can lead to an assert as demonstrated in the new test. In the long term, the better solution will be to enable DynTypedNodes without memoization data. For now, simply skip memoization instead. llvm-svn: 213751
* ASTMatchers: Bound node results are always const, make selectFirst's ↵Benjamin Kramer2014-07-231-4/+4
| | | | | | | | | | template argument implicitly const. This avoids adding const to every user of selectFirst and also allows it to match TypeLocs which BoundNodes doesn't use magic const removal specializations for. No functionality change. llvm-svn: 213737
* [ASTMatchers] Add a usingDirectiveDecl matcher.Benjamin Kramer2014-07-161-0/+7
| | | | | | | | This matches 'using namespace' declarations. Differential Revision: http://reviews.llvm.org/D4517 llvm-svn: 213152
* [ASTMatchers] Make hasOverloadedOperatorName also match freestanding overloads.Benjamin Kramer2014-07-141-0/+7
| | | | | | | | | Freestanding overloads are represented as FunctionDecls in the AST, make the matcher also match them. Differential Revision: http://reviews.llvm.org/D4493 llvm-svn: 212940
* Add a matcher for SubstNonTypeTemplateParmExpr.Alexander Kornienko2014-06-291-0/+11
| | | | | | | | | | | | Reviewers: klimek, djasper Reviewed By: djasper Subscribers: klimek, aemerson, cfe-commits Differential Revision: http://reviews.llvm.org/D4327 llvm-svn: 212001
* Do not store duplicate parents when memoization data is available.Samuel Benzaquen2014-06-131-0/+21
| | | | | | | | | | | | | | Summary: Do not store duplicate parents when memoization data is available. This does not solve the duplication problem, but ameliorates it. Reviewers: klimek Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D4124 llvm-svn: 210902
* [C++11] Use 'nullptr'. Unittests edition.Craig Topper2014-06-081-10/+12
| | | | llvm-svn: 210423
* Add hasLocalStorage/hasGlobalStorage matchers.Samuel Benzaquen2014-06-051-0/+12
| | | | | | | | | | | | | | Summary: Add hasLocalStorage/hasGlobalStorage matchers for VarDecl nodes. Update the doc. Also add them to the dynamic registry. Reviewers: klimek Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D4034 llvm-svn: 210278
* Make equalsNode work with pointers to subtypes.Manuel Klimek2014-05-271-8/+16
| | | | llvm-svn: 209652
* Adds child traversal matchers for IfStmt's then and else branches.Manuel Klimek2014-05-271-0/+11
| | | | llvm-svn: 209649
* Allow hasBody on CXXForRangeStmt nodes and update the docs.Manuel Klimek2014-05-271-0/+2
| | | | llvm-svn: 209647
* Add the hasRangeInit() matcher for range-based for loop.Manuel Klimek2014-05-231-0/+3
| | | | llvm-svn: 209533
* [ASTMatchers] Move the 'isImplicit' matcher from CXXConstructorDecl to Decl.Joey Gouly2014-05-161-0/+3
| | | | llvm-svn: 209006
* Add matcher for ExprWithCleanups.Samuel Benzaquen2014-04-021-0/+9
| | | | | | | | | | | | Summary: Add matcher for ExprWithCleanups. Reviewers: klimek CC: cfe-commits, klimek Differential Revision: http://llvm-reviews.chandlerc.com/D3248 llvm-svn: 205420
* Render anonymous entities as '(anonymous <thing>)' (and lambdas as '(lambda ↵David Blaikie2014-04-021-1/+1
| | | | | | | | | | | | 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
* Use the new Windows environment for target detectionSaleem Abdulrasool2014-03-271-2/+3
| | | | | | | | | 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
* Fixes a bug in DynTypedNode.Manuel Klimek2014-03-251-1/+32
| | | | | | | | 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
* Replace OwningPtr with std::unique_ptr.Ahmed Charles2014-03-071-4/+6
| | | | | | This compiles cleanly with lldb/lld/clang-tools-extra/llvm. llvm-svn: 203279
* Speculatively fix MSVC buildbotsDavid Majnemer2014-03-051-5/+9
| | | | llvm-svn: 202938
* Switch all uses of LLVM_OVERRIDE to just use 'override' directly.Craig Topper2014-03-021-1/+1
| | | | llvm-svn: 202625
* ASTMatchers: added CXXMethodDecl matcher isPure()Dmitri Gribenko2014-02-241-0/+7
| | | | | | | | | | | | | 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
* Add TemplateSpecializationType polymorphism for hasTemplateArgument andPeter Collingbourne2014-02-201-0/+24
| | | | | | | | | | | 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
* clang/unittests/AST,ASTMatchers: Remove _MSC_VER.NAKAMURA Takumi2014-02-161-15/+18
| | | | llvm-svn: 201485
* Consistently print anonymous namespace names as "<anonymous namespace>"David Blaikie2014-02-141-1/+1
| | | | | | | | | | | 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
* Add isListInitialization matcher.Peter Collingbourne2014-02-061-0/+11
| | | | | | Differential Revision: http://llvm-reviews.chandlerc.com/D2708 llvm-svn: 200949
* PR18128: a lambda capture-default is not permitted for a non-local lambdaRichard Smith2014-02-061-1/+1
| | | | | | expression. llvm-svn: 200948
* Added the hasLoopVariable sub-matcher for forRangeStmt.Alexander Kornienko2014-02-051-0/+5
| | | | | | | | | | | | | | | | | | | 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
* Fix string-literal to char* conversion in overload resolution for C++11Ismail Pazarbasi2014-01-171-2/+2
| | | | | | | | 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
* Fix 'declartion' typosAlp Toker2014-01-051-1/+1
| | | | llvm-svn: 198549
* Introduce MatchFinder::matchAST.Peter Collingbourne2013-11-071-0/+12
| | | | | | Differential Revision: http://llvm-reviews.chandlerc.com/D2115 llvm-svn: 194223
OpenPOWER on IntegriCloud