Commit Graph

179 Commits

Author SHA1 Message Date
Aaron Ballman 6c79f352b8 Adding an AST matcher for namespaceAliasDecl.
llvm-svn: 246322
2015-08-28 19:39:21 +00:00
Samuel Benzaquen f8ec454f7d [ASTMatchers] Add type matcher for SubstTemplateTypeParmType.
llvm-svn: 246037
2015-08-26 16:15:59 +00:00
Aaron Ballman 11825f2592 Add AST narrowing matchers for inline and anonymous namespaces. Since the inline keyword can also be specified on a FunctionDecl, this is a polymorphic matcher.
llvm-svn: 245337
2015-08-18 19:55:20 +00:00
Aaron Ballman 7596bcf726 Switching from an explicit loop to DeleteContainerSeconds; NFC.
llvm-svn: 244802
2015-08-12 20:05:18 +00:00
Aaron Ballman 001f168e94 RangRangify some more for loops; NFC.
llvm-svn: 244792
2015-08-12 19:00:39 +00:00
Aaron Ballman 6f6d0b6c5a Add a polymorphic AST matcher for testing whether a constructor or a conversion declaration is marked as explicit or not.
llvm-svn: 244666
2015-08-11 21:09:52 +00:00
Aaron Ballman ed455d4062 Add an AST matcher to match member intializers of a CXXCtorInitializer.
llvm-svn: 244662
2015-08-11 20:42:00 +00:00
Aaron Ballman 1ca258e6a8 Add AST matchers for narrowing constructors that are default, copy, or move constructors, as well as functionality to determine whether a ctor initializer is a base initializer.
llvm-svn: 244036
2015-08-05 12:11:30 +00:00
Aaron Ballman 41143bb573 Add an AST matcher, isFinal(), for testing whether a method or class declaration are marked final.
llvm-svn: 243107
2015-07-24 12:35:41 +00:00
Samuel Benzaquen b063f5c7e1 [ASTMatchers] Use provided target NodeKind instead of inferring it from the 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
2015-07-17 16:05:27 +00:00
Aaron Ballman 3991846c33 Add the ability to AST match a variable declaration that is an exception variable.
llvm-svn: 242303
2015-07-15 17:11:21 +00:00
Hans Wennborg b27f249601 AST Matchers: pass ast_type_traits::DynTypedNode by const-ref
(Broken out from http://reviews.llvm.org/D11168)

llvm-svn: 242161
2015-07-14 16:50:14 +00:00
Yaron Keren 5b816061ba Replace some const std::string & with llvm::StringRef or std::string
and std::move to avoid implicit std::string construction.

Patch by Eugene Kosov.

llvm-svn: 241433
2015-07-06 08:47:15 +00:00
Yaron Keren 40178c352e Revert r241330. It compiled with Visual C++ 2013 and gcc 4.9.1 (mingw) but now fails the bots.
llvm-svn: 241335
2015-07-03 09:30:33 +00:00
Yaron Keren 452670165c Replace some const std::string & with llvm::StringRef or std::string
and std::move to avoid implicit std::string construction.

Patch by Eugene Kosov.

llvm-svn: 241330
2015-07-03 09:16:20 +00:00
Yaron Keren d30f5ffddc Revert r241319, investigating.
llvm-svn: 241321
2015-07-03 05:31:54 +00:00
Yaron Keren 25bb2e4709 Replace some const std::string & with llvm::StringRef or std::string
and std::move to avoid implicit std::string construction.

Part 1/2.

Patch by Eugene Kosov.

llvm-svn: 241319
2015-07-03 05:09:59 +00:00
Aaron Ballman 8f4699a8c6 When testing for anyOf(), the test should not be for an exact type match for all members of the set. Instead, test that all members are convertible to the common type.
llvm-svn: 241263
2015-07-02 14:02:41 +00:00
Aaron Ballman 9b869aa4a1 Implement an AST matcher for C++ exception catch handlers that can catch any exception type (...).
llvm-svn: 241256
2015-07-02 12:53:22 +00:00
David Majnemer 8423df927e Move a test from static-assert.cpp to DeclPrinterTest
It's better not to rely on the diagnostics engine to pretty print the
argument to decltype.  Instead, exercise the functionality in
DeclPrinterTest.

llvm-svn: 239197
2015-06-05 22:40:53 +00:00
Benjamin Kramer 3204b152b5 Replace push_back(Constructor(foo)) with emplace_back(foo) for non-trivial types
If the type isn't trivially moveable emplace can skip a potentially
expensive move. It also saves a couple of characters.


Call sites were found with the ASTMatcher + some semi-automated cleanup.

memberCallExpr(
    argumentCountIs(1), callee(methodDecl(hasName("push_back"))),
    on(hasType(recordDecl(has(namedDecl(hasName("emplace_back")))))),
    hasArgument(0, bindTemporaryExpr(
                       hasType(recordDecl(hasNonTrivialDestructor())),
                       has(constructExpr()))),
    unless(isInTemplateInstantiation()))

No functional change intended.

llvm-svn: 238601
2015-05-29 19:42:19 +00:00
Samuel Benzaquen 025f6b1981 Add conversionDecl matcher for node CXXConversionDecl.
llvm-svn: 235348
2015-04-20 20:58:50 +00:00
Alexander Kornienko 34eb20725d Use 'override/final' instead of 'virtual' for overridden methods
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
2015-04-11 02:00:23 +00:00
Benjamin Kramer b5356e7fcd ASTMatchers: Add an explicit dependency on libclangBasic.
In a static build the dependency is picked up implictly, but not in a shared
library build. This is needed for the new ObjC matchers that reference Selector.

llvm-svn: 232055
2015-03-12 16:25:19 +00:00
Manuel Klimek bfa4357271 Add support for a few Objective-C matchers.
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
2015-03-12 15:48:15 +00:00
Aaron Ballman e9f931f974 Reverting r232034, as it broke one of the bots with link errors. Details at: http://bb.pgr.jp/builders/ninja-clang-x64-mingw64-RA/builds/6352/steps/build/logs/stdio
llvm-svn: 232038
2015-03-12 14:14:48 +00:00
Aaron Ballman 12865302b7 Added 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, reviewed by Manuel Klimek. From http://reviews.llvm.org/D7710

llvm-svn: 232034
2015-03-12 13:21:19 +00:00
Benjamin Kramer 82f6e433ac Roll functions back into namespaces, msvc has problems with name lookup outside of it.
llvm-svn: 231671
2015-03-09 17:00:48 +00:00
Benjamin Kramer 8407df72a3 Make helper functions static. NFC.
Found by -Wmissing-prototypes.

llvm-svn: 231668
2015-03-09 16:47:52 +00:00
Samuel Benzaquen ef621f43ff Add translationUnitDecl matcher.
Summary: Add translationUnitDecl matcher.

Reviewers: alexfh

Subscribers: klimek, cfe-commits

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

llvm-svn: 228694
2015-02-10 14:46:45 +00:00
Samuel Benzaquen b405c08bdb Add voidType() matcher.
Summary: Add voidType() matcher.

Reviewers: klimek

Subscribers: klimek, cfe-commits

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

llvm-svn: 224250
2014-12-15 15:09:22 +00:00
Samuel Benzaquen 95636e565a Make the function pointer a template argument instead of a runtime value.
Summary:
Speed up the variadic matchers by removing one indirect call.
Making the function pointer a template arguments allows the compiler to
inline the call instead of doing an runtime call by pointer.
Also, optimize the allOf() case to avoid redundant kind checks.
This speeds up our clang-tidy benchmark by ~2%

Reviewers: klimek

Subscribers: klimek, cfe-commits

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

llvm-svn: 223029
2014-12-01 14:46:14 +00:00
Manuel Klimek d3aa1f4a63 Re-apply r222646 (was reverted in r222667). Adding 4 ASTMatchers: 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
2014-11-25 17:01:06 +00:00
Samuel Benzaquen 074bbb698d Filter the toplevel matchers by kind.
Summary:
Filter the toplevel matchers by kind.
Decl and Stmt matchers are tied to a specific node kind and trying to
match incompatible nodes is a waste.
Precalculate a filtered list of matchers that have a chance of matching
the node and ignore the rest.
Speeds up our clang-tidy benchmark by ~10%

Reviewers: klimek

Subscribers: klimek, cfe-commits

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

llvm-svn: 222688
2014-11-24 21:21:09 +00:00
Aaron Ballman 6265102c17 Reverting r222646; the tests do not pass on Windows. Also reverts r222664, which was required for r222646 to compile with Visual Studio 2012.
llvm-svn: 222667
2014-11-24 17:39:44 +00:00
Manuel Klimek da50ff8e4a Adding 4 ASTMatchers: typedefDecl, isInMainFile, isInSystemFile, 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
2014-11-24 09:10:56 +00:00
Samuel Benzaquen 2c15e8ccce Replace variadic operator function pointer with an enum value.
Summary:
Replace variadic operator function pointer with an enum value.
Hiding the implementation of the variadic matcher will allow to specialize them for the operation performed.
In particular, it will allow for a more efficient allOf() matcher.

Reviewers: klimek

Subscribers: klimek, cfe-commits

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

llvm-svn: 222432
2014-11-20 15:45:53 +00:00
Samuel Benzaquen 9743c9d88c Remove VariadicOperatorMatcherInterface as it is redundant with logic from DynTypedMatcher.
Summary:
The generic variadic matcher is faster (one less virtual function call
per match) and doesn't require template instantiations which reduces
compile time and binary size.
Registry.cpp.o generates ~14% less symbols and compiles ~7.5% faster.
The change also speeds up our clang-tidy benchmark by ~2%.

Reviewers: klimek

Subscribers: klimek, cfe-commits

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

llvm-svn: 222131
2014-11-17 14:55:49 +00:00
Samuel Benzaquen c640ef5634 Add valueDecl() matcher.
Summary: Add valueDecl() matcher.

Reviewers: klimek

Subscribers: klimek, cfe-commits

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

llvm-svn: 220776
2014-10-28 13:33:58 +00:00
Samuel Benzaquen 7af8800095 Speed up clang-tidy when profiling in on.
Summary:
Speed up clang-tidy when profiling in on.
It makes profiling runs twice as fast by reusing the time samples between the
different actions.
It also joins together the sampling of different matchers of the same check.

Reviewers: alexfh

Subscribers: klimek, cfe-commits

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

llvm-svn: 220682
2014-10-27 15:22:59 +00:00
Benjamin Kramer 967c079082 ASTMatchers: Peel off a layer of indirection from true matcher. NFC.
llvm-svn: 220560
2014-10-24 13:29:21 +00:00
Benjamin Kramer 79f1590ef4 ASTMatchers: for-rangify loops. No functionality change.
llvm-svn: 220559
2014-10-24 13:29:15 +00:00
Samuel Benzaquen 43dcf2172a Add support for profiling the matchers used.
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
2014-10-22 20:31:05 +00:00
Samuel Benzaquen b6f73bc510 Fix code to follow the "Don’t use else after a return" rule.
Summary:
Fix code to follow the "Don’t use else after a return" rule.
This is a followup from rL219792.

Reviewers: alexfh

Subscribers: klimek, cfe-commits

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

llvm-svn: 219939
2014-10-16 17:50:19 +00:00
Samuel Benzaquen 8513d6234d Speed up hasName() matcher.
Summary:
Speed up hasName() matcher by skipping the expensive generation of the
fully qualified name unless we need it.
In the common case of matching an unqualified name, we don't need to
generate the full name. We might not even need to copy any string at
all.
This change speeds up our clang-tidy benchmark by ~10%

Reviewers: klimek

Subscribers: klimek, cfe-commits

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

llvm-svn: 219792
2014-10-15 14:58:46 +00:00
Samuel Benzaquen 193d87fd8c Fix order of evaluation bug in DynTypedMatcher::constructVariadic().
Fix order of evaluation bug in DynTypedMatcher::constructVariadic().
If it evaluates right-to-left, the vector gets moved before we read the
kind from it.

llvm-svn: 219624
2014-10-13 18:17:11 +00:00
Samuel Benzaquen 2009960ea3 Fix bug in DynTypedMatcher::constructVariadic() that would cause false 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
2014-10-13 17:38:12 +00:00
Samuel Benzaquen b63c251894 Fix completion logic to allow for heterogeneous argument types in matcher overloads.
Summary:
There was an assumption that there were no matchers that were overloaded
on matchers and other types of arguments.
This assumption was broken recently with the addition of new matcher
overloads.

Fixes http://llvm.org/PR21226

Reviewers: pcc

Subscribers: klimek, cfe-commits

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

llvm-svn: 219450
2014-10-09 22:08:52 +00:00
Samuel Benzaquen 96039d727b Special case 0 and 1 matcher in makeAllOfComposite().
Summary:
Remove unnecessary wrapping for the 0 and 1 matcher cases of
makeAllOfComposite(). We don't need a variadic wrapper for those cases.
Refactor TrueMatcher to take advandage of the new conversions between
DynTypedMatcher and Matcher<T>. Also, make it a singleton.
This change improves our clang-tidy related benchmarks by ~12%.

Reviewers: klimek

Subscribers: klimek, cfe-commits

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

llvm-svn: 219431
2014-10-09 19:28:18 +00:00
Manuel Klimek 7735e40a87 Implement various matchers around template argument handling.
llvm-svn: 219408
2014-10-09 13:06:22 +00:00