summaryrefslogtreecommitdiffstats
path: root/clang/lib/ASTMatchers
Commit message (Collapse)AuthorAgeFilesLines
* [ASTMatchers] HasNameMatcher handles `extern "C"`Nathan James2020-02-271-1/+7
| | | | | | | | | | | | | | | | 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)
* Revert "[ASTMatchers] extract public matchers from const-analysis into own ↵Jonas Toth2020-01-111-2/+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/+2
| | | | | | | | | | | | | | | | | | | 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/+1
| | | | Accepts child matchers cxxThisExpr to match on capture of this and also on varDecl.
* Add a new AST matcher 'optionally'.Rihan Yang2020-01-082-0/+28
| | | | | | | | 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.
* Fixing a formatting nit; NFCAaron Ballman2020-01-081-1/+2
|
* Allow using traverse() with bindingsStephen Kelly2020-01-051-0/+5
|
* Handle init statements in readability-else-after-returnNathan James2020-01-021-0/+1
| | | | | | | | | | 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.
* Match code following lambdas when ignoring invisible nodesStephen Kelly2019-12-311-1/+1
| | | | | | | | | | Reviewers: aaron.ballman Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D71976
* Fix formatting in previous commitsStephen Kelly2019-12-291-1/+2
|
* Fix use of named values surrounded by newlines in clang-queryStephen Kelly2019-12-291-7/+8
|
* Fix handling of newlines in clang-queryStephen Kelly2019-12-291-3/+1
| | | | Replace assert with diagnostic for missing newline.
* Allow newlines in AST Matchers in clang-query filesStephen Kelly2019-12-271-21/+55
| | | | | | | | | | 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-55/+21
| | | | | | | | | 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");
* Fix -Wunused-lambda-capture warnings.Eric Christopher2019-12-261-1/+1
|
* Allow newlines in AST Matchers in clang-query filesStephen Kelly2019-12-261-21/+55
| | | | | | | | | | 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-55/+21
| | | | This reverts commit 6a3ecf4dc7ec299394e71b3124df2b3a34ed4ac3.
* Allow newlines in AST Matchers in clang-query filesStephen Kelly2019-12-261-21/+55
| | | | | | | | | | 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-7/+54
| | | | | | | | | | 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-35/+1
| | | | This reverts commit 494b1318ca77927e919bbf9a61749a58553d738c.
* Customize simplified dumping and matching of LambdaExprStephen Kelly2019-12-201-1/+35
| | | | | | | | | | Reviewers: aaron.ballman Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D71680
* Make it possible control matcher traversal kind with ASTContextStephen Kelly2019-12-062-22/+48
| | | | | | | | | | | | | | | | 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
* [ASTMatchers] work around a miscompile; "NFC"George Burgess IV2019-11-221-1/+2
| | | | | | | | I chatted with Reid offline, and we agreed that having a workaround here would be appropriate until PR43879 is resolved. The given transformation Works On My Machine(TM), and should hopefully hold more broadly, but my fingers are crossed nonetheless. :)
* [Clang] Migrate llvm::make_unique to std::make_uniqueJonas Devlieghere2019-08-143-9/+9
| | | | | | | | | | 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-121-1/+62
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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] Add isDirectlyDerivedFrom AST matcher.Anton Bikineev2019-07-252-3/+6
| | | | | | Differential Revision: https://reviews.llvm.org/D65092 llvm-svn: 367010
* Revert "[clang] Fixing windows buildbot after D61552"Gauthier Harnisch2019-06-201-2/+0
| | | | | | | | This reverts commit 5d5d2ca69e2b29b36db1a7dd1993ead7b7d2680f. has already been fixed by c230eea2f349533468e14672eee94c2016476784 llvm-svn: 363920
* [clang] Fixing windows buildbot after D61552Gauthier Harnisch2019-06-201-0/+2
| | | | | | | | | | | | | | | | Summary: original review : https://reviews.llvm.org/D61552 build bot faillure : http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/110 this adds a missing definition of cxxDeductionGuideDecl. surprisingly it was still working on linux with out it. Reviewers: aaron.ballman Differential Revision: https://reviews.llvm.org/D63592 llvm-svn: 363919
* [clang][ASTMatchers] Add definition for cxxDeductionGuideDecl introduced in ↵Kadir Cetinkaya2019-06-201-0/+2
| | | | | | rL363855 llvm-svn: 363917
* [clang] Adapt ASTMatcher to explicit(bool) specifierGauthier Harnisch2019-06-191-0/+2
| | | | | | | | | | | | | | | | | | | | 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-131-0/+1
| | | | | | | | | | | | | | | | | | 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-19/+15
| | | | | | | | | | | | | | | | | 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/+1
| | | | | | | | | | | | 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/+3
| | | | | | | | | | | | | | | | | | | | | | | `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
* [ASTMatchers][OpenMP] OpenMP Structured-block-related matchersRoman Lebedev2019-03-211-0/+3
| | | | | | | | | | | | | | | | | 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-213-0/+30
| | | | | | | | | | | | | | | | | | | 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/+4
| | | | | | | | | | | | | | | | | | 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
* [NFC][ASTMatchers] Alphabetically sort REGISTER_MATCHER() macros in ↵Roman Lebedev2019-03-201-16/+17
| | | | | | | | RegistryMaps::RegistryMaps() As noted in https://reviews.llvm.org/D59453#inline-526253 llvm-svn: 356578
* [ASTImporter] Add support for importing ChooseExpr AST nodes.Tom Roeder2019-02-262-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-262-2/+0
| | | | | | Test does not pass on Windows llvm-svn: 354839
* [ASTImporter] Add support for importing ChooseExpr AST nodes.Tom Roeder2019-02-252-0/+2
| | | | | | | | | | | | | | | | | | | | | 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
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-197-28/+21
| | | | | | | | | | | | | | | | | 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
* [ASTMatchers] Improve assert message for broken parent map.Sam McCall2019-01-081-7/+11
| | | | | | | | | | | | | | | | Summary: This assert catches places where the AST (as seen by RecursiveASTVisitor) becomes disconnected due to incomplete traversal. Making it print the actual parent-less node is a lot more helpful - it's possible to work out which part of the tree wasn't traversed. Reviewers: ilya-biryukov Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D56395 llvm-svn: 350612
* [clang] Add AST matcher for initializer list membersHyrum Wright2019-01-071-0/+1
| | | | | | | | | | | | | Summary: Much like hasArg for various call expressions, this allows LibTooling users to match against a member of an initializer list. This is currently being used as part of the abseil-duration-scale clang-tidy check. Differential Revision: https://reviews.llvm.org/D56090 llvm-svn: 350523
* [ASTImporter] Fix redecl chain of classes and class templatesGabor Marton2018-12-172-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | Summary: The crux of the issue that is being fixed is that lookup could not find previous decls of a friend class. The solution involves making the friend declarations visible in their decl context (i.e. adding them to the lookup table). Also, we simplify `VisitRecordDecl` greatly. This fix involves two other repairs (without these the unittests fail): (1) We could not handle the addition of injected class types properly when a redecl chain was involved, now this is fixed. (2) DeclContext::removeDecl failed if the lookup table in Vector form did not contain the to be removed element. This caused troubles in ASTImporter::ImportDeclContext. This is also fixed. Reviewers: a_sidorin, balazske, a.sidorin Subscribers: rnkovacs, dkrupp, Szelethus, cfe-commits Differential Revision: https://reviews.llvm.org/D53655 llvm-svn: 349349
* [clang] Add AST matcher for block expressions 🔍Stephane Moore2018-12-132-0/+2
| | | | | | | | | | | | | | | | | | Summary: This change adds a new AST matcher for block expressions. Test Notes: Ran the clang unit tests. Reviewers: aaron.ballman Reviewed By: aaron.ballman Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D55546 llvm-svn: 349004
* [AST] Store "UsesADL" information in CallExpr.Eric Fiselier2018-12-121-0/+1
| | | | | | | | | | | | | | | | | | | | | 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
* Revert rL347462 "[ASTMatchers] Add hasSideEffect() matcher."Clement Courbet2018-11-221-1/+0
| | | | | | Breaks some buildbots. llvm-svn: 347463
* [ASTMatchers] Add hasSideEffect() matcher.Clement Courbet2018-11-221-0/+1
| | | | | | | | | | | | Summary: Exposes Expr::HasSideEffects. Reviewers: aaron.ballman Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D54830 llvm-svn: 347462
* Fix parens warning in assert in ASTMatchFinderErich Keane2018-11-151-7/+7
| | | | | Change-Id: Ie34f9c6846b98fba87449e73299519fc2346bac1 llvm-svn: 346996
OpenPOWER on IntegriCloud