aboutsummaryrefslogtreecommitdiff
path: root/clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
AgeCommit message (Collapse)AuthorFilesLines
2020-12-11Remove references to the ast_type_traits namespaceAlexander Kornienko1-59/+48
Follow up to cd62511496938e33c061c90796dd23a5288ff843 / https://reviews.llvm.org/D74499 Reviewed By: aaron.ballman Differential Revision: https://reviews.llvm.org/D92994
2020-08-11[clang] Add a matcher for template template parameters.Bruno Ricci1-0/+9
There are already matchers for type template parameters and non-type template parameters, but somehow no matcher exists for template template parameters and I need it to write unit tests. Differential Revision: https://reviews.llvm.org/D85536 Reviewed By: aaron.ballman
2020-07-12[OpenMP] Add firstprivate as a default data-sharing attribute to clangAtmn Patel1-450/+375
This implements the default(firstprivate) clause as defined in OpenMP Technical Report 8 (2.22.4). Reviewed By: jdoerfert, ABataev Differential Revision: https://reviews.llvm.org/D75591
2020-07-03Revert AST Matchers default to AsIs modeStephen Kelly1-1/+6
Reviewers: aaron.ballman, klimek Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D83076
2020-07-02[ASTMatchers] Enhanced support for matchers taking Regex argumentsNathan James1-0/+6
Added new Macros `AST(_POLYMORPHIC)_MATCHER_REGEX(_OVERLOAD)` that define a matchers that take a regular expression string and optionally regular expression flags. This lets users match against nodes while ignoring the case without having to manually use `[Aa]` or `[A-Fa-f]` in their regex. The other point this addresses is in the current state, matchers that use regular expressions have to compile them for each node they try to match on, Now the regular expression is compiled once when you define the matcher and used for every node that it tries to match against. If there is an error while compiling the regular expression an error will be logged to stderr showing the bad regex string and the reason it couldn't be compiled. The old behaviour of this was down to the Matcher implementation and some would assert, whereas others just would never match. Support for this has been added to the documentation script as well. Support for this has been added to dynamic matchers ensuring functionality is the same between the 2 use cases. Reviewed By: aaron.ballman Differential Revision: https://reviews.llvm.org/D82706
2020-06-29Move TestClangConfig into libClangTesting and use it in AST Matchers testsDmitri Gribenko1-322/+793
Summary: Previously, AST Matchers tests were using a custom way to run a test with a specific C++ standard version. I'm migrating them to a shared infrastructure to specify a Clang target from libClangTesting. I'm also changing tests for AST Matchers to run in multiple language standards versions, and under multiple triples that have different behavior with regards to templates. To keep the size of the patch manageable, in this patch I'm only migrating one file to get the process started and get feedback on this approach. One caveat is that increasing the number of test configuration does significantly increase the runtime of AST Matchers tests. On my machine, the test runtime increases from 2.0 to 6.0s. I think it is worth the improved test coverage. Reviewers: jdoerfert, ymandel Reviewed By: ymandel Subscribers: gribozavr2, jfb, sstefan1, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D82179
2020-06-04Use libClangTesting in the unittest for AST matchersDmitri Gribenko1-48/+27
Summary: The unittest for AST matchers has its own way to specify language standards. I unified it with the shared infrastructure from libClangTesting. Reviewers: jdoerfert, hlopko Reviewed By: hlopko Subscribers: mgorny, sstefan1, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D81150
2020-06-02[NFC][ASTMatchers] StringRef-ify and Twine-ify ASTMatchers tests.Nathan James1-90/+82
2020-05-24Fix ignore-traversal to call correct methodStephen Kelly1-2/+4
As is done by ignoreParenImpCasts(). We were not previously calling the correct internal method. Adjust tests to account for this.
2020-05-21Set traversal explicitly where needed in testsStephen Kelly1-62/+79
Reviewers: aaron.ballman, shafik Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D72531
2020-02-03[clang][AST] Add an AST matcher for deducedTemplateSpeializationType.Haojian Wu1-0/+6
Summary: misc-unused-using clang-tidy check needs this matcher to fix a false positive of C++17 deduced class template types. Reviewers: gribozavr2 Reviewed By: gribozavr2 Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D73869
2020-01-29Add TagDecl AST matcherKarasev Nikita1-0/+7
2020-01-28[ASTMatchers] Add cxxNoexceptExpr AST matcherNathan1-0/+10
Summary: Adds a cxxNoexceptExpr matcher that matches the [[ https://en.cppreference.com/w/cpp/language/noexcept | noexcept operator ]]. Reviewers: aaron.ballman Reviewed By: aaron.ballman Subscribers: merge_guards_bot, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D73439
2019-12-07Add matchDynamic convenience functionsStephen Kelly1-0/+24
Summary: These correspond to the existing match() free functions. Reviewers: aaron.ballman Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D54406
2019-08-14[Clang] Migrate llvm::make_unique to std::make_uniqueJonas Devlieghere1-5/+5
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
2019-03-21[ASTTypeTraits][ASTMatchers][OpenMP] OMPClause handlingRoman Lebedev1-0/+38
Summary: `OMPClause` is the base class, it is not descendant from **any** other class, therefore for it to work with e.g. `VariadicDynCastAllOfMatcher<>`, it needs to be handled here. Reviewers: sbenza, bkramer, pcc, klimek, hokein, gribozavr, aaron.ballman, george.karpenkov Reviewed By: gribozavr, aaron.ballman Subscribers: guansong, jdoerfert, alexfh, ABataev, cfe-commits Tags: #openmp, #clang Differential Revision: https://reviews.llvm.org/D57112 llvm-svn: 356675
2019-03-21[ASTMatchers][OpenMP] Add base ompExecutableDirective() matcher.Roman Lebedev1-0/+24
Summary: A simple matcher for `OMPExecutableDirective` Stmt type. Split off from D57113. Reviewers: gribozavr, aaron.ballman, JonasToth, george.karpenkov Reviewed By: gribozavr, aaron.ballman Subscribers: guansong, jdoerfert, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D59453 llvm-svn: 356674
2019-02-26[ASTImporter] Add support for importing ChooseExpr AST nodes.Tom Roeder1-0/+5
Summary: This allows ASTs to be merged when they contain ChooseExpr (the GNU __builtin_choose_expr construction). This is needed, for example, for cross-CTU analysis of C code that makes use of __builtin_choose_expr. The node is already supported in the AST, but it didn't have a matcher in ASTMatchers. So, this change adds the matcher and adds support to ASTImporter. This was originally reviewed and approved in https://reviews.llvm.org/D58292 and submitted as r354832. It was reverted in r354839 due to failures on the Windows CI builds. This version fixes the test failures on Windows, which were caused by differences in template expansion between versions of clang on different OSes. The version of clang built with MSVC and running on Windows never expands the template in the C++ test in ImportExpr.ImportChooseExpr in clang/unittests/AST/ASTImporter.cpp, but the version on Linux does for the empty arguments and -fms-compatibility. So, this version of the patch drops the C++ test for __builtin_choose_expr, since that version was written to catch regressions of the logic for isConditionTrue() in the AST import code for ChooseExpr, and those regressions are also caught by ASTImporterOptionSpecificTestBase.ImportChooseExpr, which does work on Windows. Reviewers: shafik, a_sidorin, martong, aaron.ballman, rnk, a.sidorin Subscribers: cfe-commits, jdoerfert, rnkovacs, aaron.ballman Tags: #clang Differential Revision: https://reviews.llvm.org/D58663 llvm-svn: 354916
2019-02-26Revert r354832 "[ASTImporter] Add support for importing ChooseExpr AST nodes."Reid Kleckner1-5/+0
Test does not pass on Windows llvm-svn: 354839
2019-02-25[ASTImporter] Add support for importing ChooseExpr AST nodes.Tom Roeder1-0/+5
Summary: This allows ASTs to be merged when they contain ChooseExpr (the GNU __builtin_choose_expr construction). This is needed, for example, for cross-CTU analysis of C code that makes use of __builtin_choose_expr. The node is already supported in the AST, but it didn't have a matcher in ASTMatchers. So, this change adds the matcher and adds support to ASTImporter. Reviewers: shafik, a_sidorin, martong, aaron.ballman Subscribers: aaron.ballman, rnkovacs, jdoerfert, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D58292 llvm-svn: 354832
2019-01-19Update the file headers across all of the LLVM projects in the monorepoChandler Carruth1-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
2018-12-12[AST] Store "UsesADL" information in CallExpr.Eric Fiselier1-0/+34
Summary: Currently the Clang AST doesn't store information about how the callee of a CallExpr was found. Specifically if it was found using ADL. However, this information is invaluable to tooling. Consider a tool which renames usages of a function. If the originally CallExpr was formed using ADL, then the tooling may need to additionally qualify the replacement. Without information about how the callee was found, the tooling is left scratching it's head. Additionally, we want to be able to match ADL calls as quickly as possible, which means avoiding computing the answer on the fly. This patch changes `CallExpr` to store whether it's callee was found using ADL. It does not change the size of any AST nodes. Reviewers: fowles, rsmith, klimek, shafik Reviewed By: rsmith Subscribers: aaron.ballman, riccibruno, calabrese, titus, cfe-commits Differential Revision: https://reviews.llvm.org/D55534 llvm-svn: 348977
2018-11-09[ASTMatchers] overload ignoringParens for ExprJonas Toth1-0/+8
Summary: This patch allows fixing PR39583. Reviewers: aaron.ballman, sbenza, klimek Reviewed By: aaron.ballman Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D54307 llvm-svn: 346554
2018-11-09Compound literals, enums, et al require const exprBill Wendling1-6/+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
2018-09-17[ASTMatchers] Let isArrow also support UnresolvedMemberExpr, ↵Shuai Wang1-1/+1
CXXDependentScopeMemberExpr Reviewers: aaron.ballman Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D52157 llvm-svn: 342407
2018-08-12[ASTMatchers] Add matchers unresolvedMemberExpr, cxxDependentScopeMemberExprShuai Wang1-0/+14
Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D50606 llvm-svn: 339522
2018-07-23[ASTMatchers] add matcher for decltypeType and its underlyingTypeJonas Toth1-0/+6
Summary: This patch introduces a new matcher for `DecltypeType` and its underlying type in order to fix a bug in clang-tidy, see https://reviews.llvm.org/D48717 for more. Reviewers: aaron.ballman, alexfh, NoQ, dcoughlin Reviewed By: aaron.ballman Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D48759 llvm-svn: 337703
2018-07-06[ASTMatchers] A matcher for Objective-C @autoreleasepoolGeorge Karpenkov1-0/+12
Differential Revision: https://reviews.llvm.org/D48910 llvm-svn: 336468
2018-06-18[ASTMatchers] Add support for matching the type of a friend decl.David L. Jones1-0/+10
This allows matchers like: friendDecl(hasType(cxxRecordDecl(...))) friendDecl(hasType(asString(...))) It seems that hasType is probably the most reasonable narrowing matcher to overload, since it is already used to narrow to other declaration kinds. Differential Revision: https://reviews.llvm.org/D48242 Reviewers: klimek, aaron.ballman Subscribers: cfe-commits llvm-svn: 334930
2018-06-18[ASTMatchers] Don't assert-fail in specifiesTypeLoc().David L. Jones1-0/+4
The specifiesTypeLoc() matcher narrows a nestedNameSpecifier matcher based on a typeloc within the NNS. However, the matcher does not guard against NNS which are a namespace, and cause getTypeLoc to assert-fail. llvm-svn: 334929
2018-03-29[ASTMatchers] Introduce a matcher for matching any given Objective-C selectorGeorge Karpenkov1-0/+11
Incudes a tiny related refactoring. Differential Revision: https://reviews.llvm.org/D44858 llvm-svn: 328747
2017-11-11Add ObjC exception statement AST matchersDave Lee1-0/+23
Summary: Add AST matchers for Objective-C @throw, @try, @catch and @finally. Reviewers: aaron.ballman, malcolm.parsons, alexshap, compnerd Reviewed By: aaron.ballman Subscribers: cfe-commits, klimek Differential Revision: https://reviews.llvm.org/D39940 llvm-svn: 317992
2017-10-26Add objcCategoryImplDecl matcherDave Lee1-1/+7
Summary: Add `objcCategoryImplDecl` which matches ObjC category definitions (`@implementation`). This matcher complements `objcCategoryDecl` (`@interface`) which was added in D30854. Reviewers: aaron.ballman, malcolm.parsons, alexshap Reviewed By: aaron.ballman Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D39293 llvm-svn: 316670
2017-09-10Add objcImplementationDecl matcherDave Lee1-0/+3
Summary: Add the `objcImplementationDecl` matcher. See related: D30854 Tested with: ``` ./tools/clang/unittests/ASTMatchers/ASTMatchersTests ``` Reviewers: aaron.ballman, compnerd, alexshap Reviewed By: aaron.ballman Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D37643 llvm-svn: 312889
2017-08-04[ASTMatcher] Add handling for DeducedType to HasDeclarationMatcherFlorian Gross1-0/+4
HasDeclarationMatcher did not handle DeducedType, it always returned false for deduced types. So with code like this: struct X{}; auto x = X{}; This did no longer match: varDecl(hasType(recordDecl(hasName("X")))) Because HasDeclarationMatcher didn't resolve the DeducedType of x. Differential Revision: https://reviews.llvm.org/D36308 llvm-svn: 310095
2017-07-11[ASTMatchers][NFC] integerLiteral(): Mention negative integers inClement Courbet1-0/+6
documentation. Trying to match integerLiteral(-1) will silently fail, because an numeric literal is always positive. - Update the documentation to explain how to match negative numeric literals. - Add a unit test. Differential Revision: https://reviews.llvm.org/D35196 llvm-svn: 307663
2017-05-05Add cxxStdInitializerListExpr AST matcherJakub Kuderski1-0/+23
Summary: This adds a new ASTMatcher for CXXStdInitializerListExprs that matches C++ initializer list expressions. The primary motivation is to use it to fix [[ https://bugs.llvm.org/show_bug.cgi?id=32896 | PR32896 ]] (review here [[ https://reviews.llvm.org/D32767 | D32767 ]]). Reviewers: alexfh, Prazek, aaron.ballman Reviewed By: alexfh, aaron.ballman Subscribers: malcolm.parsons, cfe-commits, klimek Differential Revision: https://reviews.llvm.org/D32810 llvm-svn: 302287
2017-03-28[ASTMatchers] add typeAliasTemplateDecl matcher.Eric Liu1-0/+16
Reviewers: hokein, aaron.ballman Reviewed By: aaron.ballman Subscribers: aaron.ballman, cfe-commits, klimek Differential Revision: https://reviews.llvm.org/D28671 llvm-svn: 298912
2017-03-15Add AST matchers for ObjCProtocolDecl, ObjCCategoryDecl, ObjCMethodDecl, ↵Aaron Ballman1-1/+42
ObjCIvarDecl, and ObjCPropertyDecl. Patch by Dave Lee. llvm-svn: 297882
2016-12-03DR616, and part of P0135R1: member access (or pointer-to-member access) on aRichard Smith1-1/+1
temporary produces an xvalue, not a prvalue. Support this by materializing the temporary prior to performing the member access. llvm-svn: 288563
2016-09-26Complete support for the cxxCtorInitializer() AST matcher so that it can be ↵Aaron Ballman1-0/+5
used as a top-level matcher. llvm-svn: 282417
2016-06-30Fix ASTMatchersNodeTest to work on Windows.Justin Lebar1-7/+5
It was failing because it had an explicit check for whether we're on Windows. There are a few other similar explicit checks in this file which I didn't remove because they serve as reasonable documentation that the test doesn't work with a Windows triple. llvm-svn: 274269
2016-06-30[ASTMatcher] Add a node matcher for EnumType.Haojian Wu1-0/+7
Reviewers: aaron.ballman Subscribers: cfe-commits, klimek Differential Revision: http://reviews.llvm.org/D21860 llvm-svn: 274217
2016-06-21Re-commit "[Temporary] Add an ExprWithCleanups for each C++ ↵Tim Shen1-2/+2
MaterializeTemporaryExpr." Since D21243 fixes relative clang-tidy tests. This reverts commit a71d9fbd41e99def9159af2b01ef6509394eaeed. llvm-svn: 273312
2016-06-09Revert "[Temporary] Add an ExprWithCleanups for each C++ ↵Tim Shen1-2/+2
MaterializeTemporaryExpr." This reverts r272296, since there are clang-tidy failures that appear to be caused by this change. llvm-svn: 272310
2016-06-09[Temporary] Add an ExprWithCleanups for each C++ MaterializeTemporaryExpr.Tim Shen1-2/+2
These ExprWithCleanups are added for holding a RunCleanupsScope not for destructor calls; rather, they are for lifetime marks. This requires ExprWithCleanups to keep a bit to indicate whether it have cleanups with side effects (e.g. dtor calls). Differential Revision: http://reviews.llvm.org/D20498 llvm-svn: 272296
2016-06-06Adding an AST matcher to ignore parenthesis in *types* (rather than ↵Aaron Ballman1-0/+7
expressions). This is required for traversing certain types (like function pointer types). llvm-svn: 271927
2016-05-18[ASTMacther] A follow-up on unresolvedLookupExpr test fixing.Haojian Wu1-1/+4
llvm-svn: 269957
2016-05-18[ASTMatcher] Fix a ASTMatcher test failure on Windows.Haojian Wu1-7/+8
Reviewers: alexfh, aaron.ballman Subscribers: thakis, cfe-commits, klimek Differential Revision: http://reviews.llvm.org/D20369 llvm-svn: 269936
2016-05-18[ASTMatcher] Add a node matcher for UnresolvedLookupExpr.Haojian Wu1-0/+9
Reviewers: alexfh, aaron.ballman Subscribers: aaron.ballman, klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D20360 llvm-svn: 269916