summaryrefslogtreecommitdiffstats
path: root/clang/lib/ASTMatchers
Commit message (Collapse)AuthorAgeFilesLines
* [AST] Re-add TypeLocs and NestedNameSpecifierLocs to the ParentMap.Benjamin Kramer2015-10-231-3/+4
| | | | | | | | | | | | | | | | | | | | This relands r250831 after some fixes to shrink the ParentMap overall with one addtional tweak: nodes with pointer identity (e.g. Decl* and friends) can be store more efficiently so I put them in a separate map. All other nodes (so far only TypeLoc and NNSLoc) go in a different map keyed on DynTypedNode. This further uglifies the code but significantly reduces memory overhead. Overall this change still make ParentMap significantly larger but it's nowhere as bad as before. I see about 25 MB over baseline (pre-r251008) on X86ISelLowering.cpp. If this becomes an issue we could consider splitting the maps further as DynTypedNode is still larger (32 bytes) than a single TypeLoc (16 bytes) but I didn't want to introduce even more complexity now. Differential Revision: http://reviews.llvm.org/D14011 llvm-svn: 251101
* Revert "[AST] Put TypeLocs and NestedNameSpecifierLocs into the ParentMap."Benjamin Kramer2015-10-211-4/+3
| | | | | | | | | | | | Putting DynTypedNode in the ParentMap bloats its memory foot print. Before the void* key had 8 bytes, now we're at 40 bytes per key which can mean multiple gigabytes increase for large ASTs and this count doesn't even include all the added TypeLoc nodes. Revert until I come up with a better data structure. This reverts commit r250831. llvm-svn: 250889
* [AST] Put TypeLocs and NestedNameSpecifierLocs into the ParentMap.Benjamin Kramer2015-10-201-3/+4
| | | | | | | | | | | | | | | | Firstly this changes the type of parent map to be keyed on DynTypedNode to simplify the following changes. This comes with a DenseMapInfo for DynTypedNode, which is a bit incomplete still and will probably only work for parentmap right now. Then the RecursiveASTVisitor in ASTContext is updated and finally ASTMatchers hasParent and hasAncestor learn about the new functionality. Now ParentMap is only missing TemplateArgumentLocs and CXXCtorInitializers. Differential Revision: http://reviews.llvm.org/D13897 llvm-svn: 250831
* Roll-back r250822.Angel Garcia Gomez2015-10-204-9/+9
| | | | | | | | | | Summary: It breaks the build for the ASTMatchers Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D13893 llvm-svn: 250827
* Apply modernize-use-default to clang.Angel Garcia Gomez2015-10-204-9/+9
| | | | | | | | | | | | Summary: Replace empty bodies of default constructors and destructors with '= default'. Reviewers: bkramer, klimek Subscribers: klimek, alexfh, cfe-commits Differential Revision: http://reviews.llvm.org/D13890 llvm-svn: 250822
* Add decayedType and hasDecayedType AST matchersMatthias Gehre2015-10-121-0/+2
| | | | | | | | | | | | Summary: Add decayedType and hasDecayedType AST matchers Reviewers: klimek Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D13639 llvm-svn: 250114
* ASTMatchers: Keep AllCallbacks in a set instead of a vectorDaniel Jasper2015-10-071-6/+6
| | | | | | | | | | | AllCallbacks is currently only used to call onStartOfTranslationUnit and onEndOfTranslationUnit on them. In this (and any other scenario I can come up with), it is important (or at least better) not to have duplicates in this container. E.g. currently onEndOfTranslationUnit is called repeatedly on the same callback for every matcher that is registered with it. llvm-svn: 249598
* Adding a narrowing AST matcher for FunctionDecl::isVariadic(), plus tests ↵Aaron Ballman2015-10-051-0/+1
| | | | | | and documentation. llvm-svn: 249321
* SourceRanges are small and trivially copyable, don't them by reference.Craig Topper2015-10-044-18/+18
| | | | llvm-svn: 249259
* Rename AST node matchers to match the AST node names directly. Part of this ↵Aaron Ballman2015-09-171-27/+31
| | | | | | 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/+5
| | | | | | | | | | | | | | 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
* Adding an AST matcher for namespaceAliasDecl.Aaron Ballman2015-08-281-0/+1
| | | | llvm-svn: 246322
* [ASTMatchers] Add type matcher for SubstTemplateTypeParmType.Samuel Benzaquen2015-08-261-0/+1
| | | | llvm-svn: 246037
* Add AST narrowing matchers for inline and anonymous namespaces. Since the ↵Aaron Ballman2015-08-181-0/+2
| | | | | | inline keyword can also be specified on a FunctionDecl, this is a polymorphic matcher. llvm-svn: 245337
* Switching from an explicit loop to DeleteContainerSeconds; NFC.Aaron Ballman2015-08-121-2/+2
| | | | llvm-svn: 244802
* RangRangify some more for loops; NFC.Aaron Ballman2015-08-121-17/+15
| | | | llvm-svn: 244792
* Add a polymorphic AST matcher for testing whether a constructor or a ↵Aaron Ballman2015-08-111-0/+1
| | | | | | 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/+1
| | | | llvm-svn: 244662
* Add AST matchers for narrowing constructors that are default, copy, or move ↵Aaron Ballman2015-08-051-0/+4
| | | | | | 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/+1
| | | | | | declaration are marked final. llvm-svn: 243107
* [ASTMatchers] Use provided target NodeKind instead of inferring it from the ↵Samuel Benzaquen2015-07-172-6/+6
| | | | | | | | | | 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/+1
| | | | | | variable. llvm-svn: 242303
* AST Matchers: pass ast_type_traits::DynTypedNode by const-refHans Wennborg2015-07-141-9/+9
| | | | | | (Broken out from http://reviews.llvm.org/D11168) llvm-svn: 242161
* Replace some const std::string & with llvm::StringRef or std::stringYaron Keren2015-07-062-3/+3
| | | | | | | | and std::move to avoid implicit std::string construction. Patch by Eugene Kosov. llvm-svn: 241433
* Revert r241330. It compiled with Visual C++ 2013 and gcc 4.9.1 (mingw) but ↵Yaron Keren2015-07-032-3/+3
| | | | | | now fails the bots. llvm-svn: 241335
* Replace some const std::string & with llvm::StringRef or std::stringYaron Keren2015-07-032-3/+3
| | | | | | | | and std::move to avoid implicit std::string construction. Patch by Eugene Kosov. llvm-svn: 241330
* Revert r241319, investigating.Yaron Keren2015-07-032-3/+3
| | | | llvm-svn: 241321
* Replace some const std::string & with llvm::StringRef or std::stringYaron Keren2015-07-032-3/+3
| | | | | | | | | | and std::move to avoid implicit std::string construction. Part 1/2. Patch by Eugene Kosov. llvm-svn: 241319
* When testing for anyOf(), the test should not be for an exact type match for ↵Aaron Ballman2015-07-021-2/+2
| | | | | | 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/+1
| | | | | | exception type (...). llvm-svn: 241256
* Move a test from static-assert.cpp to DeclPrinterTestDavid Majnemer2015-06-051-0/+1
| | | | | | | | 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
* Replace push_back(Constructor(foo)) with emplace_back(foo) for non-trivial typesBenjamin Kramer2015-05-292-9/+9
| | | | | | | | | | | | | | | | | | | | 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
* Add conversionDecl matcher for node CXXConversionDecl.Samuel Benzaquen2015-04-201-0/+1
| | | | llvm-svn: 235348
* Use 'override/final' instead of 'virtual' for overridden methodsAlexander Kornienko2015-04-112-25/+30
| | | | | | | | | | | | | | | | | | | | 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
* ASTMatchers: Add an explicit dependency on libclangBasic.Benjamin Kramer2015-03-121-0/+1
| | | | | | | 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
* Add support for a few Objective-C matchers.Manuel Klimek2015-03-121-0/+8
| | | | | | | | | | | 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-8/+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/+8
| | | | | | | | 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
* Roll functions back into namespaces, msvc has problems with name lookup ↵Benjamin Kramer2015-03-091-4/+8
| | | | | | outside of it. llvm-svn: 231671
* Make helper functions static. NFC.Benjamin Kramer2015-03-091-13/+9
| | | | | | Found by -Wmissing-prototypes. llvm-svn: 231668
* Add translationUnitDecl matcher.Samuel Benzaquen2015-02-101-0/+1
| | | | | | | | | | | | Summary: Add translationUnitDecl matcher. Reviewers: alexfh Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D7512 llvm-svn: 228694
* Add voidType() matcher.Samuel Benzaquen2014-12-151-0/+1
| | | | | | | | | | | | Summary: Add voidType() matcher. Reviewers: klimek Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D6656 llvm-svn: 224250
* Make the function pointer a template argument instead of a runtime value.Samuel Benzaquen2014-12-011-22/+37
| | | | | | | | | | | | | | | | | 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
* Re-apply r222646 (was reverted in r222667). Adding 4 ASTMatchers: ↵Manuel Klimek2014-11-251-0/+4
| | | | | | | | | | | | | | | | | | | | | | | 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
* Filter the toplevel matchers by kind.Samuel Benzaquen2014-11-242-10/+86
| | | | | | | | | | | | | | | | | | 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
* Reverting r222646; the tests do not pass on Windows. Also reverts r222664, ↵Aaron Ballman2014-11-241-4/+0
| | | | | | which was required for r222646 to compile with Visual Studio 2012. llvm-svn: 222667
* Adding 4 ASTMatchers: typedefDecl, isInMainFile, isInSystemFile, ↵Manuel Klimek2014-11-241-0/+4
| | | | | | | | | | | | | | | | | | | | 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
* Replace variadic operator function pointer with an enum value.Samuel Benzaquen2014-11-203-19/+59
| | | | | | | | | | | | | | | 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
* Remove VariadicOperatorMatcherInterface as it is redundant with logic from ↵Samuel Benzaquen2014-11-173-8/+9
| | | | | | | | | | | | | | | | | | | 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
* Add valueDecl() matcher.Samuel Benzaquen2014-10-281-0/+1
| | | | | | | | | | | | Summary: Add valueDecl() matcher. Reviewers: klimek Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D6005 llvm-svn: 220776
OpenPOWER on IntegriCloud