294 Commits

Author SHA1 Message Date
Balazs Benics
7457e2c153
[clang][ASTMatcher] Add matchers for isExplicitObjectMemberFunction() (#84446)
Note that this patch will be necessary to fix
`forEachArgumentWithParam()` and `forEachArgumentWithParamType()`
matchers for deducing "this"; which is my true motivation. There the bug
is that with explicit obj params, one should not adjust the number of
arguments in presence of `CXXMethodDecls`, and this causes a mismatch
there mapping the argument to the wrong param. But, I'll come back there
once we have this matcher.
2024-03-08 13:57:27 +01:00
Julian Schmidt
fe97a59a7b
[clang] remove (clang::)ast_matchers:: namespace from AST matcher args for docs (#81437)
When parsing the ASTMatchers.h file, a matcher could specify an argument
that is a matcher using the not needed namespace
`(clang::)ast_matchers::`.
Change the argument parsing in dump_ast_matchers.py to remove those
namespaces such that when parameters with these namespaces slip through,
the namespaces will be not be shown in the matchers reference, like it
is done with the `internal` namespace.
Additionally, remove the not needed namespaces from arguments in
ASTMatchers.h.
2024-02-28 12:43:43 +01:00
Julian Schmidt
cbaadb1f0f
[clang][ASTMatcher] Add matchers for CXXFoldExpr (#71245)
Adds support for the following matchers related to `CXXFoldExpr`:
`cxxFoldExpr`, `callee`,
  `hasInit`, `hasPattern`, `isRightFold`, `isLeftFold`,
  `isUnaryFold`, `isBinaryFold`, `hasOperator`, `hasLHS`, `hasRHS`.
2024-01-16 17:13:38 +01:00
Sam McCall
3dcf3cbc42 [ASTMatchers] Bring comments & docs back in sync
415d9e8ca39c0b42f351cc532ccfb48b6ac97f7f edited the generated html
directly without updating the source of truth.
2023-09-04 13:42:29 +02:00
dingfei
ec483c29a9 [clang][ASTMatcher] Add matcher for 'MacroQualifiedType'
Add matcher for 'MacroQualifiedType'

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D157777
2023-08-16 18:03:16 +08:00
dingfei
415d9e8ca3 [ASTMatcher] Fix typos in LibASTMatchersReference.html 2023-08-12 21:33:43 +08:00
dingfei
8baf862756 [clang][ASTMatcher] Add Matcher 'convertVectorExpr'
Add Matcher convertVectorExpr.

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D157248
2023-08-07 21:53:14 +08:00
dingfei
4cce27d918 [clang][ASTMatcher] Add Matcher 'dependentSizedExtVectorType'
Add Matcher dependentSizedExtVectorType for DependentSizedExtVectorType.

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D157237
2023-08-07 21:50:42 +08:00
Christopher Di Bella
38e1c59703 [clang] adds conceptDecl as an ASTMatcher
Closes #63934

Differential Revision: https://reviews.llvm.org/D155549
2023-07-20 23:33:46 +00:00
Rashmi Mudduluru
27c1033783 [WIP][-Wunsafe-buffer-usage] Handle lambda expressions within a method.
Differential Revision: https://reviews.llvm.org/D150386
2023-07-20 10:00:16 -07:00
Rashmi Mudduluru
3ea673a97b [clang][docs] Update LibASTMatchersReference.html
Differential Revision: https://reviews.llvm.org/D155304
2023-07-18 15:27:59 -07:00
Mike Crowe
2ae8a4a178 [ASTMatchers] Add argumentCountAtLeast narrowing matcher
This will be used by the modernize-use-std-print clang-tidy check and
related checks later.

Reviewed By: PiotrZSL

Differential Revision: https://reviews.llvm.org/D153716
2023-06-25 18:41:55 +00:00
Aaron Ballman
12251c6454 Correct documentation for the refersToType AST matcher
The docs used a nonexisting matcher that caused some confusion. It has
now been replaced with the correct syntax.

Fixes #58044
2023-01-20 15:36:57 -05:00
Aaron Ballman
03b83cd703 Remove a stale FIXME comment; NFC
Also regenerates the AST matcher documentation. This matcher is tested
in TEST(HasImplicitDestinationType, MatchesSimpleCase) and
TEST(HasImplicitDestinationType, DoesNotMatchIncorrectly) in
ASTMatchersTraversalTest.cpp.
2023-01-10 10:44:40 -05:00
Aaron Ballman
44a080eee5 Fix the documentation for the hasBody AST matcher
The problem was whitespace between the comment and the code for the
matcher. Rather than fix the script, I went the easier route and
removed the offending newline. If this problem comes up again though,
we should consider making the script less fragile.
2023-01-10 10:39:30 -05:00
Aaron Ballman
95be33fb99 Update dump_ast_matchers.py to Python 3
Also regenerates the documentation and fixed a validation diagnostic
about use of 'is' vs '=='.
2023-01-10 09:53:06 -05:00
Carlos Galvez
125ccd3751 [ASTMatchers] Add isInAnonymousNamespace narrowing matcher
Used in a couple clang-tidy checks so it could be extracted
out as its own matcher.

Differential Revision: https://reviews.llvm.org/D140328
2022-12-23 07:39:03 +00:00
Clement Courbet
dbfa97bd11 [doc] Fix invalid reference to hasReturnArgument matcher.
The matcher is called `hasReturnValue`.
2022-10-18 08:47:21 +02:00
Ziqing Luo
b17baa1db6 [ASTMatchers] Adding a new matcher for callee declarations of Obj-C
message expressions

For an Obj-C message expression `[o m]`, the adding matcher will match
the declaration of the method `m`.  This commit overloads the existing
`callee` ASTMatcher, which originally was only for C/C++ nodes but
also applies to Obj-C messages now.

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D129398
2022-07-21 13:35:31 -07:00
Rashmi Mudduluru
eb1d908e5c Adds AST matcher for ObjCStringLiteral
Differential Revision: https://reviews.llvm.org/D128103
2022-06-30 15:20:10 -07:00
Jennifer Yu
7aa9c39381 [Clang][[OpenMP5.1] Initial parser/sema for default(private) clause
This implements the default(private) clause as defined in OMP5.1

Differential Revision: https://reviews.llvm.org/D125912
2022-05-19 12:43:13 -07:00
Whisperity
9add949557 [ASTMatchers][clang-tidy][NFC] Hoist forEachTemplateArgument matcher into the core library
Fixes the `FIXME:` related to adding `forEachTemplateArgument` to the
core AST Matchers library.

Reviewed By: aaron.ballman

Differential Revision: http://reviews.llvm.org/D125383
2022-05-13 12:55:48 +02:00
Whisperity
06a98328fc [ASTMatchers][NFC] Fix name of matcher in docs and add a missing test 2022-05-11 14:15:53 +02:00
Nathan James
c34d898183
[ASTMatchers] Expand isInline matcher to VarDecl
Add support to the `isInline` matcher for C++17's inline variables.

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D118900
2022-02-23 08:34:00 +00:00
Nathan James
6f2c95657b
[clang][docs] Regenerate ASTMatchers documentation 2022-02-03 14:11:30 +00:00
Evgeny Shulgin
589a939072 Add isConstinit matcher
Support C++20 constinit variables for AST Matchers.
2022-01-24 08:35:42 -05:00
Evgeny Shulgin
b80db150cd Add isConsteval matcher
Support C++20 consteval functions and C++2b if consteval for AST Matchers.
2022-01-20 13:35:10 -05:00
James King
4e9e2f2417 Fix documentation for forEachLambdaCapture and hasAnyCapture
Updates the return types of these matchers' definitions to use
`internal::Matcher<LambdaCapture>` instead of `LambdaCaptureMatcher`. This
ensures that they are categorized as traversal matchers, instead of narrowing
matchers.

Reviewed By: ymandel, tdl-g, aaron.ballman

Differential Revision: https://reviews.llvm.org/D114809
2021-12-02 13:28:05 +00:00
James King
9809c6c61c Add isInitCapture and forEachLambdaCapture matchers.
This contributes follow-up work from https://reviews.llvm.org/D112491, which
allows for increased control over the matching of lambda captures. This also
updates the documentation for the `lambdaCapture` matcher.

Reviewed By: ymandel, aaron.ballman

Differential Revision: https://reviews.llvm.org/D113575
2021-11-15 22:55:28 +00:00
James King
c0b298fc21 Add LambdaCapture-related matchers.
This provides better support for `LambdaCapture`s by making them first-
class and allowing them to be bindable. In addition, this implements several
`LambdaCapture`-related matchers. This does not update how lambdas are
traversed. As a result, something like trying to match `lambdaCapture()` by
itself will not work - it must be used as an inner matcher.

Reviewed By: aaron.ballman, sammccall

Differential Revision: https://reviews.llvm.org/D112491
2021-11-08 18:50:54 +00:00
James King
ac74296562 Add TypeLoc-related matchers.
Contributes several matchers that involve `TypeLoc`s. These matchers are (in alphabetical order):

- elaboratedTypeLoc
- hasAnyTemplateArgumentLoc
- hasNamedTypeLoc
- hasPointeeLoc
- hasReferentLoc
- hasReturnTypeLoc
- hasTemplateArgumentLoc
- hasUnqualifiedLoc
- pointerTypeLoc
- qualifiedTypeLoc
- referenceTypeLoc
- templateSpecializationTypeLoc

Reviewed By: ymandel, aaron.ballman

Differential Revision: https://reviews.llvm.org/D111242
2021-10-08 17:42:18 +00:00
Kazuaki Ishizaki
8f77dc459e [clang] NFC: Fix trivial typo in comments and document
`the the` -> `the`

Reviewed By: xgupta

Differential Revision: https://reviews.llvm.org/D77470
2021-09-04 12:59:42 +05:30
Shivam Gupta
4a6d8a11f8 [clang] Fix Typo in AST Matcher Reference
In [[ https://clang.llvm.org/docs/LibASTMatchersReference.html | AST Matcher Reference]], the example of matcher `hasDeclContext` contained a typo.

`cxxRcordDecl` was changed to `cxxRecordDecl`.

Differential Revision: https://reviews.llvm.org/D102836
2021-08-31 12:21:47 +05:30
Sam McCall
c8f148274f Reapply "Support Attr in DynTypedNode and ASTMatchers."
This reverts commit 3241680f111ddf3eac37db88cacac199083543f0.
Fixed mangled post-test formatting :-(
2021-08-06 22:30:32 +02:00
Sam McCall
3241680f11 Revert "Support Attr in DynTypedNode and ASTMatchers."
This reverts commit a4bdcdadc6ffab250b218bbdae9a0ced05bebfc9.

Fails bots:
https://lab.llvm.org/buildbot/#/builders/109/builds/20231/steps/6/logs/stdio
2021-08-06 22:27:54 +02:00
Sam McCall
a4bdcdadc6 Support Attr in DynTypedNode and ASTMatchers.
Differential Revision: https://reviews.llvm.org/D89743
2021-08-06 22:06:04 +02:00
liuke
034b94bb71 Fix documentation; NFC
The documentation about ignoringImpCasts is wrong, which can cause
misunderstandings. This patch fixes it.
2021-07-15 09:38:05 -04:00
Artem Dergachev
6a079dfdc9 [ASTMatchers] Add forCallable(), a generalization of forFunction().
The new matcher additionally covers blocks and Objective-C methods.

This matcher actually makes sure that the statement truly belongs
to that declaration's body. forFunction() incorrectly reported that
a statement in a nested block belonged to the surrounding function.

forFunction() is now deprecated due to the above footgun, in favor of
forCallable(functionDecl()) when only functions need to be considered.

Differential Revision: https://reviews.llvm.org/D102213
2021-05-13 11:25:00 -07:00
Artem Dergachev
dd98ea528c [ASTMatchers] NFC: Fix formatting around forFunction().
Differential Revision: https://reviews.llvm.org/D102303
2021-05-13 11:25:00 -07:00
Weston Carvalho
1f65f42dd3 Make hasTypeLoc matcher support more node types.
Differential Revision: https://reviews.llvm.org/D101572
2021-05-08 00:35:22 +01:00
Nikita Kniazev
2f181086b5 [ASTMatchers] Add cxxBaseSpecifier matcher (non-top-level)
Required for capturing base specifier in matchers:
  `cxxRecordDecl(hasDirectBase(cxxBaseSpecifier().bind("base")))`

Reviewed By: steveire, aaron.ballman

Differential Revision: https://reviews.llvm.org/D69218
2021-04-09 00:05:36 +01:00
Chuanqi Xu
55486161fa [ASTMatcher] Add AST Matcher support for C++20 coroutine keywords
Summary: Try to enable the support for C++20 coroutine keywords for AST
Matchers.

Reviewers: sammccall, njames93, aaron.ballman

Differential Revision: https://reviews.llvm.org/D96316
2021-03-22 10:27:46 +08:00
Nathan James
6badd3c52d
[ASTMatchers] Fix documentation for hasAnyBody matcher
Looks like a oversight when the matcher was added.

Reviewed By: steveire

Differential Revision: https://reviews.llvm.org/D98583
2021-03-15 13:06:49 +00:00
Stephen Kelly
b5b3243bf7 Regenerate documentation 2021-02-22 11:07:45 +00:00
Stephen Kelly
39ff002e52 [ASTMatchers] Clarify example in docs 2021-02-14 13:49:06 +00:00
Stephen Kelly
467a045601 [ASTMatchers] Add matchers for decomposition decls
Differential Revision: https://reviews.llvm.org/D95739
2021-02-02 14:11:02 +00:00
Stephen Kelly
68b0595ccb NFC: Re-generate out-of-date matchers docs 2021-02-01 21:25:29 +00:00
Stephen Kelly
3c79734f29 [ASTMatchers] Add invocation matcher
Differential Revision: https://reviews.llvm.org/D94865
2021-01-28 20:47:09 +00:00
Stephen Kelly
b765eaf9a6 [ASTMatchers] Add support for CXXRewrittenBinaryOperator
Differential Revision: https://reviews.llvm.org/D94130
2021-01-16 13:44:22 +00:00
Stephen Kelly
e810e95e4b [ASTMatchers] Add binaryOperation matcher
This is a simple utility which allows matching on binaryOperator and
cxxOperatorCallExpr. It can also be extended to support
cxxRewrittenBinaryOperator.

Add generic support for MapAnyOfMatchers to auto-marshalling functions.

Differential Revision: https://reviews.llvm.org/D94129
2021-01-16 13:44:09 +00:00