Commit Graph

170 Commits

Author SHA1 Message Date
Eugene Zelenko 06becf8f99 [ASTMatchers] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).
llvm-svn: 317137
2017-11-01 23:09:49 +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
Benjamin Kramer 82e2fbad41 [ASTMatchers] Expose forEachOverriden in dynamic AST matchers.
llvm-svn: 316344
2017-10-23 16:48:46 +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
Dave Lee cde4528a8e Register linkageSpecDecl matcher
Summary:
This allows `linkageSpecDecl` to be used from `clang-query`.

See also D31869 which similary adds `isStaticStorageClass`.

Reviewers: aaron.ballman

Reviewed By: aaron.ballman

Subscribers: cfe-commits, klimek

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

llvm-svn: 312283
2017-08-31 21:18:27 +00:00
Benjamin Kramer 96a0b3fc6c [ASTMatchers] Fix use after free.
Found by asan.

llvm-svn: 305094
2017-06-09 17:55:42 +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
Peter Wu 2bbed50a45 [ASTMatchers] Add support for floatLiterals
Summary:
Needed to support something like "floatLiteral(equals(1.0))". The
parser for floating point numbers is kept simple, so instead of ".1" you
have to use "0.1".

Reviewed By: aaron.ballman

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

llvm-svn: 305021
2017-06-08 22:00:50 +00:00
Peter Wu c04b198c50 [ASTMatchers] Add support for boolean literals
Summary:
Recognize boolean literals for future extensions ("equals(true)").
Note that a specific VariantValue constructor is added to resolve
ambiguity (like "Value = 5") between unsigned and bool.

Reviewed By: aaron.ballman

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

llvm-svn: 305020
2017-06-08 22:00:38 +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
Alexander Shaposhnikov ae33dfac6e [clang] Register isConstexpr matcher
This diff registers isConstexpr matcher.

Test plan:
make check-all
check that "match varDecl(isConstexpr())" 
works in clang-query

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

llvm-svn: 300427
2017-04-16 19:05:17 +00:00
Aaron Ballman 565019ff32 Add isStaticStorageClass to the dynamic matcher registry so that it can be used from clang-query.
Patch by Dave Lee.

llvm-svn: 300400
2017-04-15 12:53:20 +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
David Blaikie feaf9d1463 Move VariantMatcher's Payload to std::shared_ptr rather than IntrusiveRefCntPtr
llvm-svn: 291156
2017-01-05 18:51:54 +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 77f039bf58 [ASTMatcher] Add hasReplacementType matcher for SubstTemplateTypeParmType
Summary: Needed for https://reviews.llvm.org/D27166

Reviewers: sbenza, bkramer, klimek

Subscribers: aemerson, cfe-commits

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

llvm-svn: 289042
2016-12-08 11:46:22 +00:00
Manuel Klimek a37e110def Adds hasUnqualifiedDesugaredType to allow matching through type sugar.
Differential Revision: https://reviews.llvm.org/D27207

llvm-svn: 288366
2016-12-01 15:45:06 +00:00
Justin Lebar 82380d8eb4 [AST] Convert Marshallers to use unique_ptr.
Reviewers: timshen

Subscribers: cfe-commits, klimek

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

llvm-svn: 283773
2016-10-10 16:26:40 +00:00
Aaron Ballman a086b9fd15 Add an AST matcher for external formal linkage.
Patch by Visoiu Mistrih

llvm-svn: 278926
2016-08-17 13:10:42 +00:00
Martin Bohme 565bdd9fed [ASTMatchers] Add templateTypeParmDecl() to Registry.cpp
Summary:
This appears to have been forgotten when templateTypeParmDecl() was initially
added.

Reviewers: alexfh, aaron.ballman

Subscribers: aaron.ballman, klimek, aemerson, rengolin, samparker, cfe-commits

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

llvm-svn: 278507
2016-08-12 13:51:00 +00:00
Martin Bohme 8cef2c2f2d [ASTMatchers] Add matchers canReferToDecl() and hasUnderlyingDecl()
Summary: Required for D22220

Reviewers: sbenza, klimek, aaron.ballman, alexfh

Subscribers: alexfh, klimek, cfe-commits

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

llvm-svn: 278123
2016-08-09 15:07:52 +00:00
Haojian Wu b33b02e9f0 [ASTMatcher] Add templateName matcher.
Reviewers: klimek

Subscribers: klimek, cfe-commits

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

llvm-svn: 277155
2016-07-29 15:45:11 +00:00
Mehdi Amini 9670f847b8 [NFC] Header cleanup
Summary: Removed unused headers, replaced some headers with forward class declarations

Patch by: Eugene <claprix@yandex.ru>

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

llvm-svn: 275882
2016-07-18 19:02:11 +00:00
Clement Courbet 425175934e [ASTMatchers] isSignedInteger() and isUnsignedInteger()
Complementary to isInteger(), these match signed and unsigned integers
respectively.

Review: http://reviews.llvm.org/D21989
llvm-svn: 275157
2016-07-12 06:36:00 +00:00
Aaron Ballman 5c574341f5 Add AST matchers for handling bit-fields and narrowing based on their width.
llvm-svn: 274652
2016-07-06 18:25:16 +00:00
Haojian Wu e775de8171 [ASTMatcher] Add a node matcher for EnumType.
Reviewers: aaron.ballman

Subscribers: cfe-commits, klimek

Differential Revision: http://reviews.llvm.org/D21860

llvm-svn: 274217
2016-06-30 07:50:01 +00:00
Samuel Benzaquen 49385c78bc [ASTMatchers] Add isLambda() matcher.
llvm-svn: 274015
2016-06-28 14:08:56 +00:00
Cong Liu 8a02efb143 IgnoringImplicit matcher.
llvm-svn: 273659
2016-06-24 09:38:03 +00:00
Aaron Ballman ba8dbbe86f Adding an AST matcher to ignore parenthesis in *types* (rather than expressions). This is required for traversing certain types (like function pointer types).
llvm-svn: 271927
2016-06-06 18:52:17 +00:00
Haojian Wu 7751c92582 [ASTMatcher] Add a node matcher for UnresolvedLookupExpr.
Reviewers: alexfh, aaron.ballman

Subscribers: aaron.ballman, klimek, cfe-commits

Differential Revision: http://reviews.llvm.org/D20360

llvm-svn: 269916
2016-05-18 12:53:59 +00:00
Aaron Ballman abdbbbc51f Add the hasDynamicExceptionSpec() AST matcher to match function declarations that have a dynamic exception specification.
Patch by Don Hinton.

llvm-svn: 269662
2016-05-16 16:49:01 +00:00
Etienne Bergeron 75e52725e4 Add an AST matcher for CastExpr kind
Summary:
This AST matcher will match a given CastExpr kind.
It's an narrowing matcher on CastExpr.

Reviewers: klimek, alexfh, sbenza, aaron.ballman

Subscribers: Prazek, jroelofs, aaron.ballman, klimek, cfe-commits

Differential Revision: http://reviews.llvm.org/D19871

llvm-svn: 269460
2016-05-13 19:36:55 +00:00
Gabor Horvath 1b3f8db8b6 [ASTMatchers] New matcher forFunction
Summary: Matcher proposed in the review of checker misc-assign-operator (name pending). Its goal is to find the direct enclosing function declaration of a statement and run the inner matcher on it. Two version is attached in this patch (thus it will not compile), to be decided which approach to take. The second one always chooses one single parent while the first one does a depth-first search upwards (thus a height-first search) and returns the first positive match of the inner matcher (thus it always returns zero or one matches, not more). Further questions: is it enough to implement it in-place, or ASTMatchersInternals or maybe ASTMatchFinder should be involved?

Reviewers: sbenza

Subscribers: aaron.ballman, klimek, o.gyorgy, xazax.hun, cfe-commits

Differential Revision: http://reviews.llvm.org/D19357

llvm-svn: 268490
2016-05-04 11:59:39 +00:00
Aaron Ballman 66eb58a756 Add typedefNameDecl() and typeAliasDecl() to the AST matchers; improves hasType() to match on TypedefNameDecl nodes.
Patch by Clement Courbet.

llvm-svn: 266331
2016-04-14 16:05:45 +00:00
Samuel Benzaquen c1384c138c [ASTMatchers] Add own version of VariadicFunction.
Summary:
llvm::VariadicFunction is only being used by ASTMatchers.
Having our own copy here allows us to remove the other one from llvm/ADT.
Also, we can extend the API to meet our needs without modifying the common
implementation.

Reviewers: alexfh

Subscribers: klimek, cfe-commits

Differential Revision: http://reviews.llvm.org/D18275

llvm-svn: 264417
2016-03-25 16:29:30 +00:00
Alexander Kornienko 976921d4b4 [ASTMatchers] New matcher hasReturnValue added
Summary: A checker (will be uploaded after this patch) needs to check implicit casts. Existing generic matcher "has" ignores implicit casts and parenthesized expressions and no specific matcher for matching return value expression preexisted. The patch adds such a matcher (hasReturnValue).

Reviewers: klimek, sbenza

Subscribers: xazax.hun, klimek, cfe-commits

Patch by Ádám Balogh!

Differential Revision: http://reviews.llvm.org/D17986

llvm-svn: 264037
2016-03-22 11:03:03 +00:00
Aaron Ballman a35b8fcef8 Adding new AST matchers for: addrLabelExpr, atomicExpr, binaryConditionalOperator, designatedInitExpr, designatorCountIs, hasSyntacticForm, implicitValueInitExpr, labelDecl, opaqueValueExpr, parenListExpr, predefinedExpr, requiresZeroInitialization, and stmtExpr.
Patch by Aleksei Sidorin.

llvm-svn: 263027
2016-03-09 17:11:51 +00:00
Samuel Benzaquen 922bef4f38 [ASTMatchers] Add matcher hasAnyName.
Summary: Add matcher hasAnyName as an optimization over anyOf(hasName(),...)

Reviewers: alexfh

Subscribers: klimek, cfe-commits

Differential Revision: http://reviews.llvm.org/D17163

llvm-svn: 261574
2016-02-22 21:13:02 +00:00
Aaron Ballman eb7e5d9074 Add an AST matcher for real floating-point types. e.g., float, double, long double, but not complex.
llvm-svn: 261221
2016-02-18 16:36:01 +00:00
Aaron Ballman 232e63d00b Add a nullPointerConstant() AST matcher to handle variations of null pointer constants in one matcher.
llvm-svn: 261008
2016-02-16 21:02:23 +00:00
Felix Berger cc9df3b9cc Add isAnyPointer() matchers. Register missing matchers.
Summary:
The isAnyPointer() matcher is useful for http://reviews.llvm.org/D15623.

Reviewers: alexfh, klimek

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D15819

llvm-svn: 260872
2016-02-15 04:00:39 +00:00
Reid Kleckner 969b1a50a0 Pass /bigobj when building lib/ASTMatchers/Dynamic/Registry.cpp
This is the third time it has crossed the 2^16 section limit. We've
already spent time optimizing this file to reduce template
instantiations, and it's not clear that there is anymore low hanging
fruit.

llvm-svn: 260267
2016-02-09 19:53:30 +00:00
Aaron Ballman 880a65bba5 Registering the gnuNullExpr AST matcher as a dynamic matcher so that it is available from clang-query.
llvm-svn: 260222
2016-02-09 14:04:49 +00:00
Aaron Ballman 7e7b7b2def Reapply r259210 with a fix for RegistryTest.cpp.
Patch by Richard Thomson.

llvm-svn: 259359
2016-02-01 14:11:47 +00:00
Hans Wennborg 2b79910d8b Revert r259210 "Extend hasType narrowing matcher for TypedefDecls, add functionProtoType matcher for FunctionProtoType nodes, extend parameterCountIs to FunctionProtoType nodes."
It didn't pass check-clang.

llvm-svn: 259218
2016-01-29 18:24:34 +00:00
Aaron Ballman fb9d0e354d Extend hasType narrowing matcher for TypedefDecls, add functionProtoType matcher for FunctionProtoType nodes, extend parameterCountIs to FunctionProtoType nodes.
Patch by Richard Thomson

llvm-svn: 259210
2016-01-29 17:03:11 +00:00
Chris Bieneman 2bf68c6c1c Remove autoconf support
Summary:
This patch is provided in preparation for removing autoconf on 1/26. The proposal to remove autoconf on 1/26 was discussed on the llvm-dev thread here: http://lists.llvm.org/pipermail/llvm-dev/2016-January/093875.html

    "This is the way [autoconf] ends
    Not with a bang but a whimper."
    -T.S. Eliot

Reviewers: chandlerc, grosbach, bob.wilson, echristo

Subscribers: klimek, cfe-commits

Differential Revision: http://reviews.llvm.org/D16472

llvm-svn: 258862
2016-01-26 21:30:40 +00:00
Eugene Zelenko 1660a5d298 Fix Clang-tidy modernize-use-nullptr warnings; other minor fixes.
Differential revision: http://reviews.llvm.org/D16567

llvm-svn: 258836
2016-01-26 19:01:06 +00:00
Aaron Ballman 31bde8762e Add am AST matcher for isMoveAssignmentOperator.
Patch by Jonathan Coe.

llvm-svn: 258573
2016-01-22 22:37:09 +00:00