summaryrefslogtreecommitdiffstats
path: root/clang/unittests/ASTMatchers/ASTMatchersTest.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Make hasLHS and hasRHS matchers available for ArraySubscriptExprAlexander Kornienko2015-11-021-0/+5
| | | | | | | | | | | | | | Summary: The hasBase and hasIndex don't tell anything about the position of the base and the index in the code, so we need hasLHS and hasRHS in some cases. Reviewers: klimek Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D14212 llvm-svn: 251842
* Add "equalsNode" for types and "isCopyAssignmentOperator" matchers.Angel Garcia Gomez2015-10-301-0/+29
| | | | | | | | | | | | Summary: This matchers are going to be used in modernize-use-default, but are generic enough to be placed in ASTMatchers.h. Reviewers: klimek Subscribers: alexfh, cfe-commits, klimek Differential Revision: http://reviews.llvm.org/D14152 llvm-svn: 251693
* Add an AST node matcher for TemplateTypeParmDecl objects.Eric Fiselier2015-10-171-0/+7
| | | | llvm-svn: 250602
* Add decayedType and hasDecayedType AST matchersMatthias Gehre2015-10-121-0/+5
| | | | | | | | | | | | Summary: Add decayedType and hasDecayedType AST matchers Reviewers: klimek Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D13639 llvm-svn: 250114
* Adding an AST node matcher for NonTypeTemplateParmDecl objects.Aaron Ballman2015-10-051-0/+7
| | | | llvm-svn: 249341
* Adding a narrowing AST matcher for FunctionDecl::isVariadic(), plus tests ↵Aaron Ballman2015-10-051-0/+7
| | | | | | and documentation. llvm-svn: 249321
* Rename AST node matchers to match the AST node names directly. Part of this ↵Aaron Ballman2015-09-171-258/+266
| | | | | | rename also splits recordDecl() (which used to match CXXRecordDecl) into recordDecl() (that matches RecordDecl) and cxxRecordDecl (that matches CXXRecordDecl). Also adds isStruct(), isUnion(), and isClass() narrowing matchers for RecordDecl objects. llvm-svn: 247885
* Fixed HasDeclarationMatcher to properly convert all types into decls where ↵Aaron Ballman2015-09-111-0/+48
| | | | | | | | | | | | | | possible. Added objcObjectPointerType(), objcInterfaceDecl(), templateTypeParmType(), injectedClassNameType(), and unresolvedUsingTypenameDecl(). Updated documentation for pointerType() to call out that it does not match ObjCObjectPointerType types. Changed pointsTo() to handle ObjCObjectPointerType as well as PointerType. While this may seem like a lot of unrelated changes, they all relate back to fixing HasDeclarationMatcher. This now allows us to write a matcher like: varDecl(hasType(namedDecl(hasName("Foo")))) that matches code using typedefs, objc interfaces, template type parameters, injected class names, or unresolved using typenames. llvm-svn: 247404
* Fix documentation of numSelectorArgs.Manuel Klimek2015-09-081-0/+3
| | | | | | | | | | | | Currently, the documentation for numSelectorArgs includes an incorrect example. It shows a case where an argument of 1 will match a property getter, but a getter will be matched only when N == 0. This diff corrects the documentation and adds a test for numSelectorArgs(0). Patch by Dave Lee. llvm-svn: 246998
* Fixing a bug where hasType(decl()) would fail to match on C code involving ↵Aaron Ballman2015-09-041-0/+3
| | | | | | structs or unions. llvm-svn: 246860
* Adding an AST matcher for namespaceAliasDecl.Aaron Ballman2015-08-281-0/+5
| | | | llvm-svn: 246322
* [ASTMatchers] Add type matcher for SubstTemplateTypeParmType.Samuel Benzaquen2015-08-261-0/+12
| | | | llvm-svn: 246037
* Add AST narrowing matchers for inline and anonymous namespaces. Since the ↵Aaron Ballman2015-08-181-0/+12
| | | | | | inline keyword can also be specified on a FunctionDecl, this is a polymorphic matcher. llvm-svn: 245337
* Add a polymorphic AST matcher for testing whether a constructor or a ↵Aaron Ballman2015-08-111-0/+14
| | | | | | conversion declaration is marked as explicit or not. llvm-svn: 244666
* Add an AST matcher to match member intializers of a CXXCtorInitializer.Aaron Ballman2015-08-111-0/+6
| | | | llvm-svn: 244662
* Add AST matchers for narrowing constructors that are default, copy, or move ↵Aaron Ballman2015-08-051-0/+41
| | | | | | constructors, as well as functionality to determine whether a ctor initializer is a base initializer. llvm-svn: 244036
* Add an AST matcher, isFinal(), for testing whether a method or class ↵Aaron Ballman2015-07-241-0/+9
| | | | | | declaration are marked final. llvm-svn: 243107
* [ASTMatchers] Use provided target NodeKind instead of inferring it from the ↵Samuel Benzaquen2015-07-171-0/+10
| | | | | | | | | | matchers. Individual matchers might not be convertible to each other's kind, but they might still all be convertible to the target kind. All the callers already know the target kind, so just pass it down. llvm-svn: 242534
* Add the ability to AST match a variable declaration that is an exception ↵Aaron Ballman2015-07-151-0/+4
| | | | | | variable. llvm-svn: 242303
* When testing for anyOf(), the test should not be for an exact type match for ↵Aaron Ballman2015-07-021-0/+4
| | | | | | all members of the set. Instead, test that all members are convertible to the common type. llvm-svn: 241263
* Implement an AST matcher for C++ exception catch handlers that can catch any ↵Aaron Ballman2015-07-021-0/+4
| | | | | | exception type (...). llvm-svn: 241256
* Adding new AST matcher: isConstexprSzabolcs Sipos2015-05-221-0/+7
| | | | | | It matches constexpr variable and function declarations. llvm-svn: 238016
* Adding new AST matcher: gnuNullExprSzabolcs Sipos2015-05-071-0/+4
| | | | | | It matches GNU __null expression. llvm-svn: 236731
* Add conversionDecl matcher for node CXXConversionDecl.Samuel Benzaquen2015-04-201-0/+6
| | | | llvm-svn: 235348
* Use 'override/final' instead of 'virtual' for overridden methodsAlexander Kornienko2015-04-111-15/+11
| | | | | | | | | | | | | | | | | | | | Summary: The patch is generated using clang-tidy misc-use-override check. This command was used: tools/clang/tools/extra/clang-tidy/tool/run-clang-tidy.py \ -checks='-*,misc-use-override' -header-filter='llvm|clang' -j=32 -fix Reviewers: dblaikie Reviewed By: dblaikie Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D8926 llvm-svn: 234678
* Add support for a few Objective-C matchers.Manuel Klimek2015-03-121-0/+45
| | | | | | | | | | | Add some matchers for Objective-C selectors and messages to ASTMatchers.h. Minor mods to ASTMatchersTest.h to allow test files with ".m" extension in addition to ".cpp". New tests added to ASTMatchersTest.c. Patch by Dean Sutherland. llvm-svn: 232051
* Reverting r232034, as it broke one of the bots with link errors. Details at: ↵Aaron Ballman2015-03-121-45/+0
| | | | | | http://bb.pgr.jp/builders/ninja-clang-x64-mingw64-RA/builds/6352/steps/build/logs/stdio llvm-svn: 232038
* Added some matchers for objective c selectors and messages to ASTMatchers.h. ↵Aaron Ballman2015-03-121-0/+45
| | | | | | | | Minor mods to ASTMatchersTest.h to allow test files with ".m" extension in addition to ".cpp". New tests added to ASTMatchersTest.c. Patch by Dean Sutherland, reviewed by Manuel Klimek. From http://reviews.llvm.org/D7710 llvm-svn: 232034
* ASTMatchers: Make AST_POLYMORPHIC_SUPPORTED_TYPES a variadic macroBenjamin Kramer2015-03-071-4/+3
| | | | | | C++11 finally allows us to use this C99 feature. llvm-svn: 231575
* Fix isOverride() for the case of a dependent typed base class.Samuel Benzaquen2015-03-061-0/+3
| | | | | | | | The method decl is not marked as overriding any other method decls until the template is instantiated. Use the override attribute as another signal. llvm-svn: 231487
* Add translationUnitDecl matcher.Samuel Benzaquen2015-02-101-0/+15
| | | | | | | | | | | | Summary: Add translationUnitDecl matcher. Reviewers: alexfh Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D7512 llvm-svn: 228694
* Rewrite r228138 to be somewhat saner.Daniel Jasper2015-02-041-0/+2
| | | | | | | | | | While probably technically correct, the solution r228138 was quite hard to read/understand. This should be simpler. Also added a test to ensure that we are still visiting the syntactic form as well. llvm-svn: 228144
* Let RecursiveASTVisitor walk both syntactic and semantic form of InitListExprs.Daniel Jasper2015-02-041-0/+4
| | | | | | | | | | | | | | Otherwise, this can lead to unexpected results when AST matching as some nodes are only present in the semantic form. For example, only looking at the syntactic form does not find the DeclRefExpr to f() in: struct S { S(void (*a)()); }; void f(); S s[1] = {&f}; llvm-svn: 228138
* Add some overloads so that floating point literals can be AST matched properly.Daniel Jasper2015-02-031-0/+8
| | | | | | | | | | I am not entirely sure whether the implemented sematics are ideal. In particular, should floatLiteral(equals(0.5)) match "0.5f" and should floatLiteral(equals(0.5f)) match "0.5". With the overloads in this patch, the answer to both questions is yes, but I am happy to change that. llvm-svn: 227956
* Revert "Add some overloads so that floating point literals can be AST ↵Daniel Jasper2015-02-021-8/+0
| | | | | | | | | | matched properly." Apparently the build bots get angry for some reason. Can't reproduce that in a local cmake/ninja build. Will look closer. Rolling back for now. llvm-svn: 227895
* Add some overloads so that floating point literals can be AST matched properly.Daniel Jasper2015-02-021-0/+8
| | | | | | | | | | I am not entirely sure whether the implemented sematics are ideal. In particular, should floatLiteral(equals(0.5)) match "0.5f" and should floatLiteral(equals(0.5f)) match "0.5". With the overloads in this patch, the answer to both questions is yes, but I am happy to change that. llvm-svn: 227892
* Add voidType() matcher.Samuel Benzaquen2014-12-151-0/+5
| | | | | | | | | | | | Summary: Add voidType() matcher. Reviewers: klimek Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D6656 llvm-svn: 224250
* Re-apply r222646 (was reverted in r222667). Adding 4 ASTMatchers: ↵Manuel Klimek2014-11-251-0/+53
| | | | | | | | | | | | | | | | | | | | | | | typedefDecl, isInMainFile, isInSystemFile, isInFileMatchingName Change to original: ifndef out tests in Windows due to /-separated paths. Summary: Often one is only interested in matches within the main-file or matches that are not within a system-header, for which this patch adds isInMainFile and isInSystemFile. They take no arguments and narrow down the matches. The isInFileMatchingName is mainly thought for interactive clang-query-sessions, to make a matcher more specific without restarting the session with the files you are interested in for that moment. It takes a string that will be used as regular-expression to match the filename of where the matched node is expanded. Patch by Hendrik von Prince. llvm-svn: 222765
* Reverting r222646; the tests do not pass on Windows. Also reverts r222664, ↵Aaron Ballman2014-11-241-48/+0
| | | | | | which was required for r222646 to compile with Visual Studio 2012. llvm-svn: 222667
* Unbreaking the MSVC 2012 build; however, these tests still fail on Windows.Aaron Ballman2014-11-241-5/+12
| | | | llvm-svn: 222664
* Adding 4 ASTMatchers: typedefDecl, isInMainFile, isInSystemFile, ↵Manuel Klimek2014-11-241-0/+41
| | | | | | | | | | | | | | | | | | | | isInFileMatchingName Summary: Often one is only interested in matches within the main-file or matches that are not within a system-header, for which this patch adds isInMainFile and isInSystemFile. They take no arguments and narrow down the matches. The isInFileMatchingName is mainly thought for interactive clang-query-sessions, to make a matcher more specific without restarting the session with the files you are interested in for that moment. It takes a string that will be used as regular-expression to match the filename of where the matched node is expanded. Patch by Hendrik von Prince. llvm-svn: 222646
* Add valueDecl() matcher.Samuel Benzaquen2014-10-281-0/+7
| | | | | | | | | | | | Summary: Add valueDecl() matcher. Reviewers: klimek Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D6005 llvm-svn: 220776
* Fix segfault in hasDeclContext for nodes that have no decl context.Samuel Benzaquen2014-10-271-0/+2
| | | | | | | | | | | | | | Summary: Some declarations do not have a declaration context, like TranslationUnitDecl. Fix hasDeclContext() to not segfault on these nodes. Reviewers: klimek Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D6003 llvm-svn: 220719
* Add support for profiling the matchers used.Samuel Benzaquen2014-10-221-0/+19
| | | | | | | | | | | | | | | Summary: Add support for profiling the matchers used. This will be connected with clang-tidy to generate a report to determine and debug slow checks. Reviewers: alexfh Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D5911 llvm-svn: 220418
* Fix bug in DynTypedMatcher::constructVariadic() that would cause false ↵Samuel Benzaquen2014-10-131-0/+5
| | | | | | | | | | | | | | | | | | | negatives. Summary: Change r219118 fixed the bug for anyOf and eachOf, but it is still present for unless. The variadic wrapper doesn't have enough information to know how to restrict the type. Different operators handle restrict failures in different ways. Reviewers: klimek Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D5731 llvm-svn: 219622
* Implement various matchers around template argument handling.Manuel Klimek2014-10-091-0/+58
| | | | llvm-svn: 219408
* Fix bug in DynTypedMatcher::constructVariadic() that would cause false ↵Samuel Benzaquen2014-10-061-0/+5
| | | | | | | | | | | | | | | | | | | negatives. Summary: DynTypedMatcher::constructVariadic() where the restrict kind of the different matchers are not related causes the matcher to have a "None" restrict kind. This causes false negatives for anyOf and eachOf. Change the logic to get a common ancestor if there is one. Also added regression tests that fail without the fix. Reviewers: klimek Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D5580 llvm-svn: 219118
* Adds 'override' to overriding methods. NFC.Fariborz Jahanian2014-10-011-2/+2
| | | | | | These were uncoveredby my yet undelivered patch. llvm-svn: 218774
* Refactor Matcher<T> and DynTypedMatcher to reduce overhead of casts.Samuel Benzaquen2014-10-011-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This change introduces DynMatcherInterface and changes the internal representation of DynTypedMatcher and Matcher<T> to use a generic interface instead. It removes unnecessary indirections and virtual function calls when converting matchers by implicit and dynamic casts. DynTypedMatcher now remembers the stricter type in the chain of casts and checks it before calling into DynMatcherInterface. This change improves our clang-tidy related benchmark by ~14%. Also, it opens the door for more optimizations of this kind that are coming in future changes. As a side effect of removing these template instantiations, it also speeds up compilation of Dynamic/Registry.cpp by ~17% and reduces the number of symbols generated by ~30%. Reviewers: klimek Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D5542 llvm-svn: 218769
* Revert r218616, "Refactor Matcher<T> and DynTypedMatcher to reduce overhead ↵NAKAMURA Takumi2014-09-291-14/+0
| | | | | | | | | | | | of casts." MSC17, aka VS2012, cannot compile it. clang/include/clang/ASTMatchers/ASTMatchersInternal.h(387) : error C4519: default template arguments are only allowed on a class template clang/include/clang/ASTMatchers/ASTMatchersInternal.h(443) : see reference to class template instantiation 'clang::ast_matchers::internal::Matcher<T>' being compiled llvm-svn: 218648
OpenPOWER on IntegriCloud