Commit Graph

178 Commits

Author SHA1 Message Date
Jonas Toth 295aa09dd2 [ASTMatchers] overload ignoringParens for Expr
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-09 20:54:06 +00:00
Sylvestre Ledru bc5c3f5727 Update our URLs in clang doc to use https
llvm-svn: 346101
2018-11-04 17:02:00 +00:00
Aaron Ballman 31f48c50cd Add the isStaticLocal() AST matcher for matching on local static variables.
Patch by Joe Ranieri.

llvm-svn: 345502
2018-10-29 13:47:56 +00:00
Stephen Kelly 7b79fb45ca Remove non-existant typeloc matchers from documentation
llvm-svn: 344023
2018-10-09 08:24:18 +00:00
Stephen Kelly 9b8fa52ff6 Regenerate AST Matcher docs
llvm-svn: 344022
2018-10-09 08:24:11 +00:00
Shuai Wang e0248aecbe [ASTMatchers] Let isArrow also support UnresolvedMemberExpr, CXXDependentScopeMemberExpr
Reviewers: aaron.ballman

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D52157

llvm-svn: 342407
2018-09-17 18:48:43 +00:00
Jonas Toth 2253878a40 [ASTMatchers] add three matchers for dependent expressions
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
2018-09-11 16:09:19 +00:00
Shuai Wang 92f9d1b8ac [ASTMatchers] Let hasObjectExpression also support UnresolvedMemberExpr, CXXDependentScopeMemberExpr
Reviewers: aaron.ballman

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D50617

llvm-svn: 340547
2018-08-23 17:16:06 +00:00
Shuai Wang 3b2a17bd1d [ASTMatchers] Let hasAnyArgument also support CXXUnresolvedConstructExpr
Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D50605

llvm-svn: 339530
2018-08-12 23:30:05 +00:00
Shuai Wang 72b56ed6b4 [ASTMatchers] Add matchers unresolvedMemberExpr, cxxDependentScopeMemberExpr
Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D50606

llvm-svn: 339522
2018-08-12 17:34:36 +00:00
George Karpenkov 079275b4dc [ASTMatchers] Introduce a matcher for `ObjCIvarExpr`, support getting it's 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
2018-07-27 17:26:11 +00:00
Jonas Toth acf836763c [ASTMatchers] fix the missing documentation for new decltypeType matcher
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
2018-07-26 13:02:05 +00:00
George Karpenkov fc3d72eeea [ASTMatchers] Add an isMain() matcher
Differential Revision: https://reviews.llvm.org/D49615

llvm-svn: 337761
2018-07-23 22:29:35 +00:00
George Karpenkov daac52cabc [ASTMatchers] [NFC] Regenerate HTML docs.
llvm-svn: 337760
2018-07-23 22:29:10 +00:00
George Karpenkov b5ea4df0eb [ASTMatchers] Introduce Objective-C matchers `hasReceiver` and `isInstanceMessage` for ObjCMessageExpr
Differential Revision: https://reviews.llvm.org/D49333

llvm-svn: 337209
2018-07-16 20:22:12 +00:00
George Karpenkov ba02bc5226 [ASTMatchers] A matcher for Objective-C @autoreleasepool
Differential Revision: https://reviews.llvm.org/D48910

llvm-svn: 336468
2018-07-06 21:36:04 +00:00
George Karpenkov b4c0cbda1e [ASTMatchers] Introduce a blockDecl matcher for matching block declarations
Blocks can be matched just as well as functions or Objective-C methods.

Differential Revision: https://reviews.llvm.org/D46980

llvm-svn: 332545
2018-05-16 22:47:03 +00:00
Gabor Horvath 3cd0aa3b7e [ASTMatchers] Overload isConstexpr for ifStmts
Differential Revision: https://reviews.llvm.org/D46233

llvm-svn: 331759
2018-05-08 11:53:32 +00:00
Alexander Kornienko 395ab2e212 Regenerated AST Matchers doc.
Backported a minor fix to the comment in the header.

llvm-svn: 331207
2018-04-30 18:12:15 +00:00
Alexander Kornienko 2a8c18d991 Fix typos in clang
Found via codespell -q 3 -I ../clang-whitelist.txt
Where whitelist consists of:

  archtype
  cas
  classs
  checkk
  compres
  definit
  frome
  iff
  inteval
  ith
  lod
  methode
  nd
  optin
  ot
  pres
  statics
  te
  thru

Patch by luzpaz! (This is a subset of D44188 that applies cleanly with a few
files that have dubious fixes reverted.)

Differential revision: https://reviews.llvm.org/D44188

llvm-svn: 329399
2018-04-06 15:14:32 +00:00
George Karpenkov 88a16a0790 [ASTMatchers] Introduce a matcher for matching any given Objective-C selector
Incudes a tiny related refactoring.

Differential Revision: https://reviews.llvm.org/D44858

llvm-svn: 328747
2018-03-29 00:51:12 +00:00
George Karpenkov 9d1d0c4c57 [ASTMatchers] Extend hasParameter and hasAnyParameter matches to handle Objective-C methods
Differential Revision: https://reviews.llvm.org/D44707

llvm-svn: 328746
2018-03-29 00:51:11 +00:00
Peter Szecsi fff11dbc48 [ASTMatchers] Add isAssignmentOperator matcher
Adding a matcher for BinaryOperator and cxxOperatorCallExpr to be able to
decide whether it is any kind of assignment operator or not. This would be
useful since allows us to easily detect assignments via matchers for static
analysis (Tidy, SA) purposes.

Differential Revision: https://reviews.llvm.org/D44893

llvm-svn: 328618
2018-03-27 12:11:46 +00:00
Clement Courbet 369e97511d [ASTMatchers] Remove extra qualifier for consistency (LibASTMatchersReference.html)
+ Regenerate doc.

llvm-svn: 328087
2018-03-21 10:54:29 +00:00
Clement Courbet 2513aa0523 [ASTMatchers] Regenerate doc.
llvm-svn: 328086
2018-03-21 10:48:00 +00:00
George Karpenkov a763fdfadd [ASTMatcher] Extend hasAnyArgument to ObjCMessageExpr
Currently hasArgument works with both ObjC messages and function calls,
but not hasAnyArgument.
This patch fixes that discrepancy, as it's often more convenient to use
hasAnyArgument.

On a more general note, it would be great to have a common superclass
for objc-call and function call, and a matcher matching that, but that's
probably a job for another commit.

Differential Revision: https://reviews.llvm.org/D44169

llvm-svn: 326865
2018-03-07 02:32:44 +00:00
Eric Liu 09ee48e2af [ASTMatchers] Regenerate documentation after r325678
llvm-svn: 325682
2018-02-21 14:22:42 +00:00
Julie Hockett 239d25a158 Add hasTrailingReturn AST matcher
Adds AST matcher for a FunctionDecl that has a trailing return type.

Differential Revision: https://reviews.llvm.org/D42273

llvm-svn: 323158
2018-01-22 22:45:23 +00:00
Fangrui Song 55942abb92 [ASTMatchers] [NFC] Fix code examples
Subscribers: klimek, cfe-commits

Differential Revision: https://reviews.llvm.org/D42213

llvm-svn: 323157
2018-01-22 22:34:15 +00:00
Haojian Wu 9c3be3a4e5 [ASTMatcher] Add isScoped matcher for enumDecl.
Summary:

Reviewers: bkramer, aaron.ballman

Subscribers: aaron.ballman, cfe-commits, klimek

Differential Revision: https://reviews.llvm.org/D42185

llvm-svn: 322826
2018-01-18 09:47:57 +00:00
Roman Lebedev 6c3871b139 [ASTMatchers] Add isNoReturn() match narrower for FunctionDeclarations
Reviewers: aaron.ballman

Reviewed By: aaron.ballman

Subscribers: dblaikie, klimek, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D41455

llvm-svn: 322746
2018-01-17 19:40:55 +00:00
Benjamin Kramer ae7ff385c6 Update dump_ast_matchers for many recent changes.
The html file hasn't been updated in a long time so there are quite a
few changes in there. No matchers were removed though.

llvm-svn: 322687
2018-01-17 16:50:14 +00:00
Aaron Ballman 813e36c2c1 Add the hasDefinition() AST matcher to match class declarations that also have a definition.
Patch by Julie Hockett.

llvm-svn: 319360
2017-11-29 21:21:51 +00:00
Adam Balogh da488a65e2 [ASTMatchers] Matchers for new[] operators
Two new matchers for `CXXNewExpr` are added which may be useful e.g. in
`clang-tidy` checkers. One of them is `isArray` which matches `new[]` but not
plain `new`. The other one, `hasArraySize` matches `new[]` for a given size.

llvm-svn: 318909
2017-11-23 12:43:20 +00:00
Aaron Ballman 5f8980a995 Add an AST matcher for hasDefaultArgument() to match on parameter declarations that have a default value.
Patch by Julie Hockett.

llvm-svn: 318794
2017-11-21 19:22:34 +00:00
Dave Lee be39868bfc Make isDefinition matcher support ObjCMethodDecl
Summary:
Allow the `isDefinition()` matcher to apply to `ObjCMethodDecl` nodes, in
addition to those it already supports. For whatever reason, `ObjCMethodDecl`
does not inherit from `FunctionDecl` and so this is specialization is necessary.

Reviewers: aaron.ballman, malcolm.parsons, alexshap

Reviewed By: aaron.ballman

Subscribers: cfe-commits, klimek

Differential Revision: https://reviews.llvm.org/D39948

llvm-svn: 318152
2017-11-14 14:17:26 +00:00
Dave Lee bfb990b783 Fix AST matcher documentation typo
llvm-svn: 317993
2017-11-11 23:53:27 +00:00
Dave Lee 0934fdc3a5 Add ObjC exception statement AST matchers
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-11-11 22:46:15 +00:00
Dave Lee 55540a0ce7 Add objcCategoryImplDecl matcher
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-10-26 15:53:37 +00:00
Alexander Shaposhnikov f681c4e5a9 [clang] Fix isExternC matcher docs
The wording in the documentation for the matcher isExternC 
appears to be misleading since this matcher 
is applicable to functions and variables as well. 
This diff changes the comment and regenerates the html file.

Differential revision: https://reviews.llvm.org/D38151

llvm-svn: 314022
2017-09-22 19:29:38 +00:00
Dave Lee e6d362cea8 Add objcImplementationDecl matcher
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-09-10 21:00:15 +00:00
Manuel Klimek 696e505278 Unify and simplify the behavior of the hasDeclaration matcher.
Originally, we weren't able to match on Type nodes themselves (only QualType),
so the hasDeclaration matcher was initially written to give what we thought are
reasonable results for QualType matches.

When we chagned the matchers to allow matching on Type nodes, it turned out
that the hasDeclaration matcher was by chance written templated enough to now
allow hasDeclaration to also match on (some) Type nodes.

This patch change the hasDeclaration matcher to:
a) work the same on Type and QualType nodes,
b) be completely explicit about what nodes we can match instead of just allowing
   anything with a getDecl() to match,
c) explicitly control desugaring only one level in very specific instances.
d) adds hasSpecializedTemplate and tagType matchers to allow migrating
  existing use cases that now need more explicit matchers

Note: This patch breaks clang-tools-extra. The corresponding patch there
is approved and will land in a subsequent patch.

Differential Revision: https://reviews.llvm.org/D27104

llvm-svn: 309809
2017-08-02 13:04:44 +00:00
Clement Courbet 43bdba4086 [ASTMatchers][NFC] integerLiteral(): Mention negative integers in
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-07-11 15:45:22 +00:00
Peter Wu a9244b57ff [ASTMatchers] Add clang-query support for equals matcher
Summary:
This allows the clang-query tool to use matchers like
"integerLiteral(equals(32))". For this to work, an overloaded function
is added for each possible parameter type.

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D33094

llvm-svn: 305022
2017-06-08 22:00:58 +00:00
Jakub Kuderski 64b6c78e94 Add cxxStdInitializerListExpr AST matcher
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-05-05 21:01:12 +00:00
Eric Liu 285f804282 [ASTMatchers] add typeAliasTemplateDecl matcher.
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-28 12:56:47 +00:00
Aaron Ballman 9fd6ee6a78 Add AST matchers for ObjCProtocolDecl, ObjCCategoryDecl, ObjCMethodDecl, ObjCIvarDecl, and ObjCPropertyDecl.
Patch by Dave Lee.

llvm-svn: 297882
2017-03-15 20:14:25 +00:00
Malcolm Parsons def8f90e67 Fix documentation typo.
llvm-svn: 292595
2017-01-20 09:54:26 +00:00
Malcolm Parsons 4ca3d18b96 [ASTMatchers] Add hasInClassInitializer traversal matcher for FieldDecl.
Summary:
I needed to know whether a FieldDecl had an in-class
initializer for D26453. I used a narrowing matcher there, but a
traversal matcher might be generally useful.

Reviewers: sbenza, bkramer, klimek, aaron.ballman

Subscribers: aaron.ballman, Prazek, cfe-commits

Differential Revision: https://reviews.llvm.org/D28034

llvm-svn: 290492
2016-12-24 13:35:14 +00:00
Malcolm Parsons 81e48b26bc [ASTMatchers] Fix doc for hasBitWidth
llvm-svn: 290491
2016-12-24 13:22:26 +00:00