summaryrefslogtreecommitdiffstats
path: root/clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [clang] Remove raw string literals in macrosOliver Stannard2020-01-131-19/+13
| | | | | Older (but still supported) versions of GCC don't handle C++11 raw string literals in macro parameters correctly.
* Revert "[ASTMatchers] extract public matchers from const-analysis into own ↵Jonas Toth2020-01-111-166/+0
| | | | | | | | patch" This reverts commit 4c48ea68e491cb42f1b5d43ffba89f6a7f0dadc4. The powerpc buildbots had an internal compiler error after this patch. This requires some inspection.
* [ASTMatchers] extract public matchers from const-analysis into own patchJonas Toth2020-01-111-0/+166
| | | | | | | | | | | | | | | | | | | Summary: The analysis for const-ness of local variables required a view generally useful matchers that are extracted into its own patch. They are `decompositionDecl` and `forEachArgumentWithParamType`, that works for calls through function pointers as well. Reviewers: aaron.ballman Reviewed By: aaron.ballman Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D72505
* Implement new AST matcher hasAnyCapture to match on LambdaExpr captures.Reid2020-01-101-0/+20
| | | | Accepts child matchers cxxThisExpr to match on capture of this and also on varDecl.
* [ASTMatchers] Make test more clear about what it is verifyingStephen Kelly2020-01-101-2/+5
|
* Clang-format previous commitStephen Kelly2020-01-051-3/+1
|
* Add missing testStephen Kelly2020-01-051-0/+12
|
* Allow using traverse() with bindingsStephen Kelly2020-01-051-0/+22
|
* Implement additional traverse() overloadsStephen Kelly2019-12-311-0/+86
| | | | | | | | | | | | | | Summary: These overloads make it possible to wrap unless(), anyOf(), has() etc with the traverse matcher. Reviewers: aaron.ballman Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D71977
* Match code following lambdas when ignoring invisible nodesStephen Kelly2019-12-311-0/+6
| | | | | | | | | | Reviewers: aaron.ballman Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D71976
* Customize simplified dumping and matching of LambdaExprStephen Kelly2019-12-211-0/+28
| | | | | | | | | | Reviewers: aaron.ballman Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D71680
* Revert "Customize simplified dumping and matching of LambdaExpr"Stephen Kelly2019-12-201-28/+0
| | | | This reverts commit 494b1318ca77927e919bbf9a61749a58553d738c.
* Customize simplified dumping and matching of LambdaExprStephen Kelly2019-12-201-0/+28
| | | | | | | | | | Reviewers: aaron.ballman Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D71680
* Add method to ignore invisible AST nodesStephen Kelly2019-12-181-0/+143
| | | | | | | | | | Reviewers: aaron.ballman Subscribers: mgorny, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D70613
* Make it possible control matcher traversal kind with ASTContextStephen Kelly2019-12-061-0/+85
| | | | | | | | | | | | | | | | Summary: This will eventually allow traversal of an AST while ignoring invisible AST nodes. Currently it depends on the available enum values for TraversalKinds. That can be extended to ignore all invisible nodes in the future. Reviewers: klimek, aaron.ballman Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D61837
* [Clang] Migrate llvm::make_unique to std::make_uniqueJonas Devlieghere2019-08-141-65/+65
| | | | | | | | | | Now that we've moved to C++14, we no longer need the llvm::make_unique implementation from STLExtras.h. This patch is a mechanical replacement of (hopefully) all the llvm::make_unique instances across the monorepo. Differential revision: https://reviews.llvm.org/D66259 llvm-svn: 368942
* [clang][NFC] Move matcher ignoringElidableConstructorCall's tests to ↵Yitzhak Mandelbaum2019-08-081-0/+85
| | | | | | | | | | | | | | | | | | | appropriate file. Summary: `ignoringElidableConstructorCall` is a traversal matcher, but its tests are grouped with narrowing-matcher tests. This revision moves them to the correct file. Reviewers: gribozavr Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D65963 llvm-svn: 368326
* [clang] Adapt ASTMatcher to explicit(bool) specifierGauthier Harnisch2019-06-191-0/+50
| | | | | | | | | | | | | | | | | | | | Summary: Changes: - add an ast matcher for deductiong guide. - allow isExplicit matcher for deductiong guide. - add hasExplicitSpecifier matcher which give access to the expression of the explicit specifier if present. Reviewers: klimek, rsmith, aaron.ballman Reviewed By: aaron.ballman Subscribers: aaron.ballman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D61552 llvm-svn: 363855
* [ASTMatchers] Introduce Objective-C matchers `isClassMessage`, ↵Ben Hamilton2019-04-221-0/+54
| | | | | | | | | | | | | | | | | | | | | | | `isClassMethod`, and `isInstanceMethod` Summary: isClassMessage is an equivalent to isInstanceMessage for ObjCMessageExpr, but matches message expressions to classes. isClassMethod and isInstanceMethod check whether a method declaration (or definition) is for a class method or instance method (respectively). Contributed by @mywman! Reviewers: benhamilton, klimek, mwyman Reviewed By: benhamilton, mwyman Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D60920 llvm-svn: 358904
* Move multiline raw string literal out of macro. NFCDavid Green2019-02-161-18/+16
| | | | | | | | Certain combinations of gcc and ccache fail when the raw string literal is preprocessed. This just moves the string out as is done elsewhere in the same file. llvm-svn: 354201
* Exteded test of .Yitzhak Mandelbaum2019-02-151-9/+13
| | | | llvm-svn: 354136
* Remove unnecessary expectation.Yitzhak Mandelbaum2019-02-151-1/+0
| | | | llvm-svn: 354135
* Added test for matcher On.Yitzhak Mandelbaum2019-02-151-12/+14
| | | | llvm-svn: 354134
* Add tests for assorted `CXXMemberCallExpr` matchers.Yitzhak Mandelbaum2019-02-151-0/+89
| | | | | | | | | | Summary: Add tests for matchers `on`, `onImplicitObjectArgument` and `hasObjectExpression`. Reviewers: alexfh, steveire, aaron.ballman Differential Revision: https://reviews.llvm.org/D56850 llvm-svn: 354133
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-191-4/+3
| | | | | | | | | | | | | | | | | to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
* Compound literals, enums, et al require const exprBill Wendling2018-11-091-3/+6
| | | | | | | | | | | | | | | | | | Summary: Compound literals, enums, file-scoped arrays, etc. require their initializers and size specifiers to be constant. Wrap the initializer expressions in a ConstantExpr so that we can easily check for this later on. Reviewers: rsmith, shafik Reviewed By: rsmith Subscribers: cfe-commits, jyknight, nickdesaulniers Differential Revision: https://reviews.llvm.org/D53921 llvm-svn: 346455
* Fix ASTMatchersTraversalTest testcase compile on older compilersDavid Green2018-08-151-3/+3
| | | | | | | | Some versions of gcc, especially when invoked through ccache (-E), can have trouble with raw string literals inside macros. This moves the string out of the macro. llvm-svn: 339759
* Fix Stmt::ignoreImplicitStephen Kelly2018-08-141-0/+39
| | | | | | | | | | | | | | | | Summary: A CXXBindTemporaryExpr can appear inside an ImplicitCastExpr, and was not ignored previously. Fixes the case reported in PR37327. Reviewers: rsmith, dblaikie, klimek Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D50666 llvm-svn: 339730
* [ASTMatchers] Let hasAnyArgument also support CXXUnresolvedConstructExprShuai Wang2018-08-121-0/+19
| | | | | | | | Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D50605 llvm-svn: 339530
* [ASTMatchers] Quickfix for tests.George Karpenkov2018-07-161-6/+6
| | | | llvm-svn: 337214
* [ASTMatchers] Introduce Objective-C matchers `hasReceiver` and ↵George Karpenkov2018-07-161-0/+29
| | | | | | | | `isInstanceMessage` for ObjCMessageExpr Differential Revision: https://reviews.llvm.org/D49333 llvm-svn: 337209
* [ASTMatchers] Introduce a blockDecl matcher for matching block declarationsGeorge Karpenkov2018-05-161-0/+4
| | | | | | | | Blocks can be matched just as well as functions or Objective-C methods. Differential Revision: https://reviews.llvm.org/D46980 llvm-svn: 332545
* [ASTMatchers] Extend hasParameter and hasAnyParameter matches to handle ↵George Karpenkov2018-03-291-0/+4
| | | | | | | | Objective-C methods Differential Revision: https://reviews.llvm.org/D44707 llvm-svn: 328746
* [ASTMatcher] Extend hasAnyArgument to ObjCMessageExprGeorge Karpenkov2018-03-071-3/+10
| | | | | | | | | | | | | | | Currently hasArgument works with both ObjC messages and function calls, but not hasAnyArgument. This patch fixes that discrepancy, as it's often more convenient to use hasAnyArgument. On a more general note, it would be great to have a common superclass for objc-call and function call, and a matcher matching that, but that's probably a job for another commit. Differential Revision: https://reviews.llvm.org/D44169 llvm-svn: 326865
* Unify and simplify the behavior of the hasDeclaration matcher.Manuel Klimek2017-08-021-2/+33
| | | | | | | | | | | | | | | | | | | | | | | | | Originally, we weren't able to match on Type nodes themselves (only QualType), so the hasDeclaration matcher was initially written to give what we thought are reasonable results for QualType matches. When we chagned the matchers to allow matching on Type nodes, it turned out that the hasDeclaration matcher was by chance written templated enough to now allow hasDeclaration to also match on (some) Type nodes. This patch change the hasDeclaration matcher to: a) work the same on Type and QualType nodes, b) be completely explicit about what nodes we can match instead of just allowing anything with a getDecl() to match, c) explicitly control desugaring only one level in very specific instances. d) adds hasSpecializedTemplate and tagType matchers to allow migrating existing use cases that now need more explicit matchers Note: This patch breaks clang-tools-extra. The corresponding patch there is approved and will land in a subsequent patch. Differential Revision: https://reviews.llvm.org/D27104 llvm-svn: 309809
* [ASTMatchers] Allow forField to match indirect fields.Malcolm Parsons2017-08-011-2/+6
| | | | | | | | This is needed for PR32966. Reviewed by alexfh. llvm-svn: 309667
* [gtest] The way EXPECT_TEST now works after upgrading gtest triggers anChandler Carruth2017-01-041-3/+6
| | | | | | | | ODR use. These traits don't have a definition as they're intended to be used strictly at compile time. Change the tests to use static_assert to move the entire thing into compile-time. llvm-svn: 291036
* DR1315: a non-type template argument in a partial specialization is permittedRichard Smith2016-12-281-2/+2
| | | | | | | | | | to make reference to template parameters. This is only a partial implementation; we retain the restriction that the argument must not be type-dependent, since it's unclear how that would work given the existence of other language rules requiring an exact type match in this context, even for type-dependent cases (a question has been raised on the core reflector). llvm-svn: 290647
* [ASTMatcher] Add hasReplacementType matcher for SubstTemplateTypeParmTypeMalcolm Parsons2016-12-081-0/+17
| | | | | | | | | | | | Summary: Needed for https://reviews.llvm.org/D27166 Reviewers: sbenza, bkramer, klimek Subscribers: aemerson, cfe-commits Differential Revision: https://reviews.llvm.org/D27447 llvm-svn: 289042
* Adds hasUnqualifiedDesugaredType to allow matching through type sugar.Manuel Klimek2016-12-011-0/+9
| | | | | | Differential Revision: https://reviews.llvm.org/D27207 llvm-svn: 288366
* [ASTMatcher] Add CXXNewExpr support to hasDeclarationMalcolm Parsons2016-10-311-0/+6
| | | | | | | | | | Reviewers: sbenza, lukasza, aaron.ballman, klimek Subscribers: lukasza, sbenza, cfe-commits Differential Revision: https://reviews.llvm.org/D26032 llvm-svn: 285644
* Traversing template paramter lists of DeclaratorDecls and/or TagDecls.Nico Weber2016-09-131-0/+83
| | | | | | | | | | | | | | The unit tests in this patch demonstrate the need to traverse template parameter lists of DeclaratorDecls (e.g. VarDecls, CXXMethodDecls) and TagDecls (e.g. EnumDecls, RecordDecls). Fixes PR29042. https://reviews.llvm.org/D24268 Patch from Lukasz Łukasz Anforowicz <lukasza@chromium.org>! llvm-svn: 281345
* [ASTMatchers] Add matchers canReferToDecl() and hasUnderlyingDecl()Martin Bohme2016-08-091-0/+34
| | | | | | | | | | | | Summary: Required for D22220 Reviewers: sbenza, klimek, aaron.ballman, alexfh Subscribers: alexfh, klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D23004 llvm-svn: 278123
* [ASTMatcher] Add templateName matcher.Haojian Wu2016-07-291-0/+8
| | | | | | | | | | Reviewers: klimek Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D22963 llvm-svn: 277155
* [ASTMatcher] Add hasTemplateArgument/hasAnyTemplateArgument support in ↵Haojian Wu2016-07-291-0/+13
| | | | | | | | | | | | functionDecl. Reviewers: klimek Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D22957 llvm-svn: 277142
* [ASTMatchers] New forEachOverriden matcher.Clement Courbet2016-07-051-0/+44
| | | | | | Matches methods overridden by the given method. llvm-svn: 274531
* IgnoringImplicit matcher.Cong Liu2016-06-241-0/+10
| | | | llvm-svn: 273659
* Revert "[ASTMatchers] New forEachOverriden matcher."Chandler Carruth2016-06-111-44/+0
| | | | | | | This reverts commit r272386. It doesn't compile with MSVC and those bots have been red the entire day as a consequence. llvm-svn: 272453
* [ASTMatchers] New forEachOverriden matcher.Clement Courbet2016-06-101-0/+44
| | | | | | Matches methods overridden by the given method. llvm-svn: 272386
* [ASTMatchers] Breaking change of `has` matcherPiotr Padlewski2016-05-311-2/+2
| | | | | | | | has matcher can now match to implicit and paren casts http://reviews.llvm.org/D20801 llvm-svn: 271288
OpenPOWER on IntegriCloud