summaryrefslogtreecommitdiffstats
path: root/clang/docs/LibASTMatchersReference.html
Commit message (Collapse)AuthorAgeFilesLines
* Revert "[ASTMatchers] extract public matchers from const-analysis into own ↵Jonas Toth2020-01-111-132/+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/+132
| | | | | | | | | | | | | | | | | | | 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/+31
| | | | Accepts child matchers cxxThisExpr to match on capture of this and also on varDecl.
* Add a new AST matcher 'optionally'.Rihan Yang2020-01-081-12/+38
| | | | | | | | 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.
* Handle init statements in readability-else-after-returnNathan James2020-01-021-17/+114
| | | | | | | | | | 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.
* Fix typo in the AST Matcher Reference doc Closes: #54Sylvestre Ledru2019-12-081-1/+1
|
* [clang] Update isDerivedFrom to support Objective-C classes 🔍Stephane Moore2019-08-121-9/+88
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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] Update `ignoringElidableConstructorCall` matcher to ignore ↵Yitzhak Mandelbaum2019-08-081-11/+10
| | | | | | | | | | | | | | | | | | | `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][NFC] Fix typo in matcher commentYitzhak Mandelbaum2019-08-071-1/+1
| | | | | | Also updates corresponding html doc. llvm-svn: 368188
* [clang] Add isDirectlyDerivedFrom AST matcher.Anton Bikineev2019-07-251-0/+25
| | | | | | Differential Revision: https://reviews.llvm.org/D65092 llvm-svn: 367010
* [clang] Adapt ASTMatcher to explicit(bool) specifierGauthier Harnisch2019-06-191-6/+79
| | | | | | | | | | | | | | | | | | | | 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/+26
| | | | | | | | | | | | | | | | | | 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
* [clang] Regenerate AST matcher docs 📖Stephane Moore2019-05-121-24/+24
| | | | | | | | | | | | | | | | | | | Summary: The documentation seems to have been manually edited in https://reviews.llvm.org/rGa282bde69e375985edd4c371b79864f617380ad5. This commit regenerates the documentation and commits the resulting diff. Reviewers: benhamilton, mwyman Reviewed By: mwyman Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D61769 llvm-svn: 360545
* Added an AST matcher for declarations that are in the `std` namespaceDmitri Gribenko2019-05-031-0/+23
| | | | | | | | | | | | 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-1/+38
| | | | | | | | | | | | | | | | | | | | | | | `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
* Fixing a typo; NFC.Aaron Ballman2019-04-031-1/+1
| | | | llvm-svn: 357579
* [ASTMatcher] Add clang-query disclaimer to two more matchers that take enumRoman Lebedev2019-03-211-0/+6
| | | | | | | | | | | As we have figured out in https://reviews.llvm.org/D57112 and https://bugs.llvm.org/show_bug.cgi?id=41176 this kind-of works, but needs special care. llvm-svn: 356677
* [ASTMatchers][OpenMP] OpenMP Structured-block-related matchersRoman Lebedev2019-03-211-0/+45
| | | | | | | | | | | | | | | | | 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-211-0/+71
| | | | | | | | | | | | | | | | | | | 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-211-0/+14
| | | | | | | | | | | | | | | | | | 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
* [ASTMatchers][NFC] Update comments on assorted `CXXMemberCallExpr` matchers.Yitzhak Mandelbaum2019-02-081-32/+79
| | | | | | | | | | | | | | | | Specifically: * fixes the comments on `hasObjectExpression`, * clarifies comments on `thisPointerType` and `on`, * adds comments to `onImplicitObjectArgument`. It also updates associated reference docs (using the doc tool). Reviewers: alexfh, steveire, aaron.ballman Differential Revision: https://reviews.llvm.org/D56849 llvm-svn: 353532
* [clang] Add AST matcher for initializer list membersHyrum Wright2019-01-071-1/+10
| | | | | | | | | | | | | 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-171-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | 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-131-0/+8
| | | | | | | | | | | | | | | | | | 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/+22
| | | | | | | | | | | | | | | | | | | | | 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
* Stop stripping comments from AST matcher example code.Aaron Ballman2018-12-111-71/+70
| | | | | | The AST matcher documentation dumping script was being a bit over-zealous about stripping comment markers, which ended up causing comments in example code to stop being comments. Fix that by only stripping comments at the start of a line, rather than removing any forward slash (which also impacts prose text). llvm-svn: 348891
* Revert rL347462 "[ASTMatchers] Add hasSideEffect() matcher."Clement Courbet2018-11-221-18/+0
| | | | | | Breaks some buildbots. llvm-svn: 347463
* [ASTMatchers] Add hasSideEffect() matcher.Clement Courbet2018-11-221-0/+18
| | | | | | | | | | | | Summary: Exposes Expr::HasSideEffects. Reviewers: aaron.ballman Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D54830 llvm-svn: 347462
* [ASTMatchers] Re-generate ast matchers doc after rL346455.Clement Courbet2018-11-221-0/+11
| | | | llvm-svn: 347453
* [ASTMatchers] overload ignoringParens for ExprJonas Toth2018-11-091-0/+11
| | | | | | | | | | | | | | | | 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
* Update our URLs in clang doc to use httpsSylvestre Ledru2018-11-041-658/+658
| | | | llvm-svn: 346101
* Add the isStaticLocal() AST matcher for matching on local static variables.Aaron Ballman2018-10-291-0/+12
| | | | | | Patch by Joe Ranieri. llvm-svn: 345502
* Remove non-existant typeloc matchers from documentationStephen Kelly2018-10-091-107/+0
| | | | llvm-svn: 344023
* Regenerate AST Matcher docsStephen Kelly2018-10-091-7/+29
| | | | llvm-svn: 344022
* [ASTMatchers] Let isArrow also support UnresolvedMemberExpr, ↵Shuai Wang2018-09-171-0/+61
| | | | | | | | | | | | CXXDependentScopeMemberExpr Reviewers: aaron.ballman Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D52157 llvm-svn: 342407
* [ASTMatchers] add three matchers for dependent expressionsJonas Toth2018-09-111-0/+40
| | | | | | | | | | | | | | | | | | | Summary: The new matchers can be used to check if an expression is type-, value- or instantiation-dependent in a templated context. These matchers are used in a clang-tidy check and generally useful as the problem of unresolved templates occurs more often in clang-tidy and they provide an easy way to check for this issue. Reviewers: aaron.ballman, alexfh, klimek Reviewed By: aaron.ballman Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D51880 llvm-svn: 341958
* [ASTMatchers] Let hasObjectExpression also support UnresolvedMemberExpr, ↵Shuai Wang2018-08-231-0/+28
| | | | | | | | | | | | CXXDependentScopeMemberExpr Reviewers: aaron.ballman Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D50617 llvm-svn: 340547
* [ASTMatchers] Let hasAnyArgument also support CXXUnresolvedConstructExprShuai Wang2018-08-121-2/+21
| | | | | | | | Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D50605 llvm-svn: 339530
* [ASTMatchers] Add matchers unresolvedMemberExpr, cxxDependentScopeMemberExprShuai Wang2018-08-121-1/+26
| | | | | | | | Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D50606 llvm-svn: 339522
* [ASTMatchers] Introduce a matcher for `ObjCIvarExpr`, support getting it's ↵George Karpenkov2018-07-271-0/+30
| | | | | | | | | | | | | declaration. ObjCIvarExpr is *not* a subclass of MemberExpr, and a separate matcher is required to support it. Adding a hasDeclaration support as well, as it's not very useful without it. Differential Revision: https://reviews.llvm.org/D49701 llvm-svn: 338137
* [ASTMatchers] fix the missing documentation for new decltypeType matcherJonas Toth2018-07-261-0/+25
| | | | | | | | | | | | | | Summary: Regenerate the Matchers documentation, forgotten in the original patch. Reviewers: alexfh, aaron.ballman Reviewed By: aaron.ballman Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D49850 llvm-svn: 338022
* [ASTMatchers] Add an isMain() matcherGeorge Karpenkov2018-07-231-0/+6
| | | | | | Differential Revision: https://reviews.llvm.org/D49615 llvm-svn: 337761
* [ASTMatchers] [NFC] Regenerate HTML docs.George Karpenkov2018-07-231-4/+4
| | | | llvm-svn: 337760
* [ASTMatchers] Introduce Objective-C matchers `hasReceiver` and ↵George Karpenkov2018-07-161-0/+25
| | | | | | | | `isInstanceMessage` for ObjCMessageExpr Differential Revision: https://reviews.llvm.org/D49333 llvm-svn: 337209
* [ASTMatchers] A matcher for Objective-C @autoreleasepoolGeorge Karpenkov2018-07-061-8/+66
| | | | | | Differential Revision: https://reviews.llvm.org/D48910 llvm-svn: 336468
* [ASTMatchers] Introduce a blockDecl matcher for matching block declarationsGeorge Karpenkov2018-05-161-4/+81
| | | | | | | | Blocks can be matched just as well as functions or Objective-C methods. Differential Revision: https://reviews.llvm.org/D46980 llvm-svn: 332545
* [ASTMatchers] Overload isConstexpr for ifStmtsGabor Horvath2018-05-081-2/+27
| | | | | | Differential Revision: https://reviews.llvm.org/D46233 llvm-svn: 331759
OpenPOWER on IntegriCloud