summaryrefslogtreecommitdiffstats
path: root/clang/unittests/ASTMatchers
Commit message (Collapse)AuthorAgeFilesLines
* [ASTMatchers] HasNameMatcher handles `extern "C"`Nathan James2020-02-271-0/+15
| | | | | | | | | | | | | | | | Summary: Fixes [[ https://bugs.llvm.org/show_bug.cgi?id=42193 | hasName AST matcher is confused by extern "C" in namespace. ]] Reviewers: klimek, aaron.ballman, gribozavr2 Reviewed By: aaron.ballman Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D75202 (cherry picked from commit 16cabf278fc8c14d415e677ce0bc40d46a6de30d)
* [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
|
* Add a new AST matcher 'optionally'.Rihan Yang2020-01-081-0/+21
| | | | | | | | This matcher matches any node and at the same time executes all its inner matchers to produce any possbile result bindings. This is useful when a user wants certain supplementary information that's not always present along with the main match result.
* 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
|
* [ParserTest] Move raw string literal out of macroDavid Green2020-01-051-3/+3
| | | | | Some combinations of gcc and ccache do not deal well with raw strings in macros. Moving the string out to attempt to fix the bots.
* Handle init statements in readability-else-after-returnNathan James2020-01-021-0/+29
| | | | | | | | | | Adds a new ASTMatcher condition called 'hasInitStatement()' that matches if, switch and range-for statements with an initializer. Reworked clang-tidy readability-else-after-return to handle variables in the if condition or init statements in c++17 ifs. Also checks if removing the else would affect object lifetimes in the else branch. Fixes PR44364.
* 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
* Allow newlines in AST Matchers in clang-query filesStephen Kelly2019-12-271-23/+142
| | | | | | | | | | Reviewers: aaron.ballman Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D71842
* Revert "Allow newlines in AST Matchers in clang-query files" + 1Evgenii Stepanov2019-12-261-142/+23
| | | | | | | | | Revert "Fix -Wunused-lambda-capture warnings." This reverts commit 2369560f4a7720b19edfbf9de14ef061307ff773. This reverts commit 522ee29a4fb3814db604b585c8637247477ec057. clang/lib/ASTMatchers/Dynamic/Parser.cpp:610:13: warning: implicit conversion turns string literal into bool: 'const char [35]' to 'bool' [-Wstring-conversion] assert(!"Newline should never be found here");
* Allow newlines in AST Matchers in clang-query filesStephen Kelly2019-12-261-23/+142
| | | | | | | | | | Reviewers: aaron.ballman Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D71842
* Revert "Allow newlines in AST Matchers in clang-query files"Stephen Kelly2019-12-261-142/+23
| | | | This reverts commit 6a3ecf4dc7ec299394e71b3124df2b3a34ed4ac3.
* Allow newlines in AST Matchers in clang-query filesStephen Kelly2019-12-261-23/+142
| | | | | | | | | | Reviewers: aaron.ballman Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D71842
* 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
* Add matchDynamic convenience functionsStephen Kelly2019-12-071-0/+24
| | | | | | | | | | Summary: These correspond to the existing match() free functions. Reviewers: aaron.ballman Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D54406
* 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
* Fix the nullPointerConstant() test to get bots back to green.Aaron Ballman2019-08-221-1/+1
| | | | llvm-svn: 369686
* [Clang] Migrate llvm::make_unique to std::make_uniqueJonas Devlieghere2019-08-145-93/+93
| | | | | | | | | | 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] Update isDerivedFrom to support Objective-C classes 🔍Stephane Moore2019-08-122-1/+106
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This change updates `isDerivedFrom` to support Objective-C classes by converting it to a polymorphic matcher. Notes: The matching behavior for Objective-C classes is modeled to match the behavior of `isDerivedFrom` with C++ classes. To that effect, `isDerivedFrom` matches aliased types of derived Objective-C classes, including compatibility aliases. To achieve this, the AST visitor has been updated to map compatibility aliases to their underlying Objective-C class. `isSameOrDerivedFrom` also provides similar behaviors for C++ and Objective-C classes. The behavior that `cxxRecordDecl(isSameOrDerivedFrom("X"))` does not match `class Y {}; typedef Y X;` is mirrored for Objective-C in that `objcInterfaceDecl(isSameOrDerivedFrom("X"))` does not match either `@interface Y @end typedef Y X;` or `@interface Y @end @compatibility_alias X Y;`. Test Notes: Ran clang unit tests. Reviewers: aaron.ballman, jordan_rose, rjmccall, klimek, alexfh, gribozavr Reviewed By: aaron.ballman, gribozavr Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D60543 llvm-svn: 368632
* [clang][NFC] Move matcher ignoringElidableConstructorCall's tests to ↵Yitzhak Mandelbaum2019-08-082-85/+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] Update `ignoringElidableConstructorCall` matcher to ignore ↵Yitzhak Mandelbaum2019-08-081-0/+17
| | | | | | | | | | | | | | | | | | | `ExprWithCleanups`. Summary: The `ExprWithCleanups` node is added to the AST along with the elidable CXXConstructExpr. If it is the outermost node of the node being matched, ignore it as well. Reviewers: gribozavr Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D65944 llvm-svn: 368319
* [clang] Remove IsDerivedFromDeathTest.DiesOnEmptyBaseName test.Anton Bikineev2019-07-251-7/+0
| | | | | | | The semantics of an empty basename passed to isDerivedFrom matchers changed in r367022, so this test is no longer relevant. llvm-svn: 367026
* [clang] Fail for empty names in is*DerivedFrom matchers.Anton Bikineev2019-07-251-0/+7
| | | | | | Differential Revision: https://reviews.llvm.org/D65279 llvm-svn: 367022
* [clang] Add isDirectlyDerivedFrom AST matcher.Anton Bikineev2019-07-251-0/+30
| | | | | | Differential Revision: https://reviews.llvm.org/D65092 llvm-svn: 367010
* cmake: Add CLANG_LINK_CLANG_DYLIB optionTom Stellard2019-07-032-2/+2
| | | | | | | | | | | | | | | | Summary: Setting CLANG_LINK_CLANG_DYLIB=ON causes clang tools to link against libclang_shared.so instead of the individual component libraries. Reviewers: mgorny, beanz, smeenai, phosek, sylvestre.ledru Subscribers: arphaman, cfe-commits, llvm-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D63503 llvm-svn: 365092
* [clang] Adapt ASTMatcher to explicit(bool) specifierGauthier Harnisch2019-06-192-0/+91
| | | | | | | | | | | | | | | | | | | | 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
* Added AST matcher for ignoring elidable constructorsDmitri Gribenko2019-06-132-9/+145
| | | | | | | | | | | | | | | | | | Summary: Added AST matcher for ignoring elidable move constructors Reviewers: hokein, gribozavr Reviewed By: hokein, gribozavr Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D63149 Patch by Johan Vikström. llvm-svn: 363262
* Move TraversalKind enum to ast_type_traitsStephen Kelly2019-05-161-1/+1
| | | | | | | | | | | | | | | | | Summary: Make it usable outside of ASTMatchFinder. This will make it possible to use this enum to control whether certain implicit nodes are skipped while AST dumping for example. Reviewers: klimek, aaron.ballman Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D61836 llvm-svn: 360920
* Added an AST matcher for declarations that are in the `std` namespaceDmitri Gribenko2019-05-031-0/+51
| | | | | | | | | | | | Reviewers: alexfh Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D61480 llvm-svn: 359876
* [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
* [clang][OpenMP] Fix another test when using libgomp.Jordan Rupprecht2019-03-211-2/+2
| | | | | | Similarly to r356614, -fopenmp=libomp needs to be used for some omp-related AST matching. llvm-svn: 356700
* [ASTMatchers][OpenMP] OpenMP Structured-block-related matchersRoman Lebedev2019-03-211-0/+65
| | | | | | | | | | | | | | | | | Summary: Exposes to the for ASTMatchers the interface/modelling of OpenMP structured-block. Reviewers: gribozavr, aaron.ballman, JonasToth, george.karpenkov Reviewed By: gribozavr, aaron.ballman Subscribers: guansong, jdoerfert, cfe-commits Tags: #clang, #openmp Differential Revision: https://reviews.llvm.org/D59463 llvm-svn: 356676
* [ASTTypeTraits][ASTMatchers][OpenMP] OMPClause handlingRoman Lebedev2019-03-212-0/+206
| | | | | | | | | | | | | | | | | | | 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
* [ASTMatchers][OpenMP] Add base ompExecutableDirective() matcher.Roman Lebedev2019-03-212-0/+36
| | | | | | | | | | | | | | | | | | 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
* [ASTImporter] Add support for importing ChooseExpr AST nodes.Tom Roeder2019-02-261-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
* Revert r354832 "[ASTImporter] Add support for importing ChooseExpr AST nodes."Reid Kleckner2019-02-261-5/+0
| | | | | | Test does not pass on Windows llvm-svn: 354839
* [ASTImporter] Add support for importing ChooseExpr AST nodes.Tom Roeder2019-02-251-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
* 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
OpenPOWER on IntegriCloud