summaryrefslogtreecommitdiffstats
path: root/clang/lib/ASTMatchers/ASTMatchersInternal.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [ASTMatchers] HasNameMatcher handles `extern "C"`Nathan James2020-02-271-1/+7
| | | | | | | | | | | | | | | | Summary: Fixes [[ https://bugs.llvm.org/show_bug.cgi?id=42193 | hasName AST matcher is confused by extern "C" in namespace. ]] Reviewers: klimek, aaron.ballman, gribozavr2 Reviewed By: aaron.ballman Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D75202 (cherry picked from commit 16cabf278fc8c14d415e677ce0bc40d46a6de30d)
* Add a new AST matcher 'optionally'.Rihan Yang2020-01-081-0/+27
| | | | | | | | This matcher matches any node and at the same time executes all its inner matchers to produce any possbile result bindings. This is useful when a user wants certain supplementary information that's not always present along with the main match result.
* Allow using traverse() with bindingsStephen Kelly2020-01-051-0/+5
|
* Make it possible control matcher traversal kind with ASTContextStephen Kelly2019-12-061-4/+22
| | | | | | | | | | | | | | | | Summary: This will eventually allow traversal of an AST while ignoring invisible AST nodes. Currently it depends on the available enum values for TraversalKinds. That can be extended to ignore all invisible nodes in the future. Reviewers: klimek, aaron.ballman Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D61837
* Revert "[clang] Fixing windows buildbot after D61552"Gauthier Harnisch2019-06-201-2/+0
| | | | | | | | This reverts commit 5d5d2ca69e2b29b36db1a7dd1993ead7b7d2680f. has already been fixed by c230eea2f349533468e14672eee94c2016476784 llvm-svn: 363920
* [clang] Fixing windows buildbot after D61552Gauthier Harnisch2019-06-201-0/+2
| | | | | | | | | | | | | | | | Summary: original review : https://reviews.llvm.org/D61552 build bot faillure : http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/110 this adds a missing definition of cxxDeductionGuideDecl. surprisingly it was still working on linux with out it. Reviewers: aaron.ballman Differential Revision: https://reviews.llvm.org/D63592 llvm-svn: 363919
* [clang][ASTMatchers] Add definition for cxxDeductionGuideDecl introduced in ↵Kadir Cetinkaya2019-06-201-0/+2
| | | | | | rL363855 llvm-svn: 363917
* [ASTTypeTraits][ASTMatchers][OpenMP] OMPClause handlingRoman Lebedev2019-03-211-0/+2
| | | | | | | | | | | | | | | | | | | Summary: `OMPClause` is the base class, it is not descendant from **any** other class, therefore for it to work with e.g. `VariadicDynCastAllOfMatcher<>`, it needs to be handled here. Reviewers: sbenza, bkramer, pcc, klimek, hokein, gribozavr, aaron.ballman, george.karpenkov Reviewed By: gribozavr, aaron.ballman Subscribers: guansong, jdoerfert, alexfh, ABataev, cfe-commits Tags: #openmp, #clang Differential Revision: https://reviews.llvm.org/D57112 llvm-svn: 356675
* [ASTMatchers][OpenMP] Add base ompExecutableDirective() matcher.Roman Lebedev2019-03-211-0/+3
| | | | | | | | | | | | | | | | | | Summary: A simple matcher for `OMPExecutableDirective` Stmt type. Split off from D57113. Reviewers: gribozavr, aaron.ballman, JonasToth, george.karpenkov Reviewed By: gribozavr, aaron.ballman Subscribers: guansong, jdoerfert, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D59453 llvm-svn: 356674
* [ASTImporter] Add support for importing ChooseExpr AST nodes.Tom Roeder2019-02-261-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This allows ASTs to be merged when they contain ChooseExpr (the GNU __builtin_choose_expr construction). This is needed, for example, for cross-CTU analysis of C code that makes use of __builtin_choose_expr. The node is already supported in the AST, but it didn't have a matcher in ASTMatchers. So, this change adds the matcher and adds support to ASTImporter. This was originally reviewed and approved in https://reviews.llvm.org/D58292 and submitted as r354832. It was reverted in r354839 due to failures on the Windows CI builds. This version fixes the test failures on Windows, which were caused by differences in template expansion between versions of clang on different OSes. The version of clang built with MSVC and running on Windows never expands the template in the C++ test in ImportExpr.ImportChooseExpr in clang/unittests/AST/ASTImporter.cpp, but the version on Linux does for the empty arguments and -fms-compatibility. So, this version of the patch drops the C++ test for __builtin_choose_expr, since that version was written to catch regressions of the logic for isConditionTrue() in the AST import code for ChooseExpr, and those regressions are also caught by ASTImporterOptionSpecificTestBase.ImportChooseExpr, which does work on Windows. Reviewers: shafik, a_sidorin, martong, aaron.ballman, rnk, a.sidorin Subscribers: cfe-commits, jdoerfert, rnkovacs, aaron.ballman Tags: #clang Differential Revision: https://reviews.llvm.org/D58663 llvm-svn: 354916
* Revert r354832 "[ASTImporter] Add support for importing ChooseExpr AST nodes."Reid Kleckner2019-02-261-1/+0
| | | | | | Test does not pass on Windows llvm-svn: 354839
* [ASTImporter] Add support for importing ChooseExpr AST nodes.Tom Roeder2019-02-251-0/+1
| | | | | | | | | | | | | | | | | | | | | Summary: This allows ASTs to be merged when they contain ChooseExpr (the GNU __builtin_choose_expr construction). This is needed, for example, for cross-CTU analysis of C code that makes use of __builtin_choose_expr. The node is already supported in the AST, but it didn't have a matcher in ASTMatchers. So, this change adds the matcher and adds support to ASTImporter. Reviewers: shafik, a_sidorin, martong, aaron.ballman Subscribers: aaron.ballman, rnkovacs, jdoerfert, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D58292 llvm-svn: 354832
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-191-4/+3
| | | | | | | | | | | | | | | | | to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
* [ASTImporter] Fix redecl chain of classes and class templatesGabor Marton2018-12-171-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | Summary: The crux of the issue that is being fixed is that lookup could not find previous decls of a friend class. The solution involves making the friend declarations visible in their decl context (i.e. adding them to the lookup table). Also, we simplify `VisitRecordDecl` greatly. This fix involves two other repairs (without these the unittests fail): (1) We could not handle the addition of injected class types properly when a redecl chain was involved, now this is fixed. (2) DeclContext::removeDecl failed if the lookup table in Vector form did not contain the to be removed element. This caused troubles in ASTImporter::ImportDeclContext. This is also fixed. Reviewers: a_sidorin, balazske, a.sidorin Subscribers: rnkovacs, dkrupp, Szelethus, cfe-commits Differential Revision: https://reviews.llvm.org/D53655 llvm-svn: 349349
* [clang] Add AST matcher for block expressions 🔍Stephane Moore2018-12-131-0/+1
| | | | | | | | | | | | | | | | | | Summary: This change adds a new AST matcher for block expressions. Test Notes: Ran the clang unit tests. Reviewers: aaron.ballman Reviewed By: aaron.ballman Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D55546 llvm-svn: 349004
* Compound literals, enums, et al require const exprBill Wendling2018-11-091-0/+1
| | | | | | | | | | | | | | | | | | Summary: Compound literals, enums, file-scoped arrays, etc. require their initializers and size specifiers to be constant. Wrap the initializer expressions in a ConstantExpr so that we can easily check for this later on. Reviewers: rsmith, shafik Reviewed By: rsmith Subscribers: cfe-commits, jyknight, nickdesaulniers Differential Revision: https://reviews.llvm.org/D53921 llvm-svn: 346455
* Use llvm::{all,any,none}_of instead std::{all,any,none}_of. NFCFangrui Song2018-10-201-5/+5
| | | | llvm-svn: 344859
* Fix import of class templates partial specializationGabor Marton2018-08-221-0/+3
| | | | | | | | | | | | | | | | | | | Summary: Currently there are several issues with the import of class template specializations. (1) Different TUs may have class template specializations with the same template arguments, but with different set of instantiated MethodDecls and FieldDecls. In this patch we provide a fix to merge these methods and fields. (2) Currently, we search the partial template specializations in the set of simple specializations and we add partial specializations as simple specializations. This is bad, this patch fixes it. Reviewers: a_sidorin, xazax.hun, r.stahl Subscribers: rnkovacs, dkrupp, cfe-commits Differential Revision: https://reviews.llvm.org/D50451 llvm-svn: 340402
* [ASTMatchers] Add matchers unresolvedMemberExpr, cxxDependentScopeMemberExprShuai Wang2018-08-121-0/+4
| | | | | | | | Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D50606 llvm-svn: 339522
* Add support for importing imaginary literalsGabor Marton2018-08-091-0/+1
| | | | | | | | | | Reviewers: a_sidorin, r.stahl, xazax.hun Subscribers: rnkovacs, dkrupp, cfe-commits Differential Revision: https://reviews.llvm.org/D50428 llvm-svn: 339334
* [ASTMatchers] Introduce a matcher for `ObjCIvarExpr`, support getting it's ↵George Karpenkov2018-07-271-0/+1
| | | | | | | | | | | | | 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
* [ASTMatchers] add matcher for decltypeType and its underlyingTypeJonas Toth2018-07-231-0/+1
| | | | | | | | | | | | | | | | Summary: This patch introduces a new matcher for `DecltypeType` and its underlying type in order to fix a bug in clang-tidy, see https://reviews.llvm.org/D48717 for more. Reviewers: aaron.ballman, alexfh, NoQ, dcoughlin Reviewed By: aaron.ballman Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D48759 llvm-svn: 337703
* [ASTMatchers] A matcher for Objective-C @autoreleasepoolGeorge Karpenkov2018-07-061-0/+2
| | | | | | Differential Revision: https://reviews.llvm.org/D48910 llvm-svn: 336468
* [ASTMatchers] Introduce a blockDecl matcher for matching block declarationsGeorge Karpenkov2018-05-161-0/+2
| | | | | | | | Blocks can be matched just as well as functions or Objective-C methods. Differential Revision: https://reviews.llvm.org/D46980 llvm-svn: 332545
* Remove \brief commands from doxygen comments.Adrian Prantl2018-05-091-1/+1
| | | | | | | | | | | | | | | | | | | This is similar to the LLVM change https://reviews.llvm.org/D46290. We've been running doxygen with the autobrief option for a couple of years now. This makes the \brief markers into our comments redundant. Since they are a visual distraction and we don't want to encourage more \brief markers in new code either, this patch removes them all. Patch produced by for i in $(git grep -l '\@brief'); do perl -pi -e 's/\@brief //g' $i & done for i in $(git grep -l '\\brief'); do perl -pi -e 's/\\brief //g' $i & done Differential Revision: https://reviews.llvm.org/D46320 llvm-svn: 331834
* [astmatchers] Fix linking issueGeorge Karpenkov2018-03-291-0/+3
| | | | llvm-svn: 328754
* [astmatchers] Move a matcher out of internal namespace: blind debugging of ↵George Karpenkov2018-03-291-9/+10
| | | | | | MSVC issues llvm-svn: 328750
* [ASTMatchers] Introduce a matcher for matching any given Objective-C selectorGeorge Karpenkov2018-03-291-4/+24
| | | | | | | | Incudes a tiny related refactoring. Differential Revision: https://reviews.llvm.org/D44858 llvm-svn: 328747
* ASTMatchers{,Macros}.h: Add some extra macros to use for decl/def of matchersDavid Blaikie2017-11-211-0/+9
| | | | | | | Fix ODR violations caused by using internal linkage variables in non-internal inline functions. (also removes duplicate definitions, etc) llvm-svn: 318720
* ASTMatchers.h: Fix ODR violations by avoiding internal linkage variables in ↵David Blaikie2017-11-151-0/+268
| | | | | | | | | | | | | | headers Internal linkage variables ODR referenced from inline functions create ODR violations (the same inline function ends up having different definitions in each TU, since it references different variables - rather than one definition). This also happens to break modular code generation - so this is the last fix to allow clang to compile with modular code generation. llvm-svn: 318304
* [ASTMatchers] Fix some Clang-tidy modernize and Include What You Use ↵Eugene Zelenko2017-11-011-15/+37
| | | | | | warnings; other minor fixes (NFC). llvm-svn: 317137
* Move some IntrusiveRefCntPtrs instead of copying.Benjamin Kramer2016-07-211-6/+7
| | | | | | No functionality change intended. llvm-svn: 276292
* Fix a -Wunused-variable diagnostic.Alexander Kornienko2016-02-231-0/+2
| | | | llvm-svn: 261626
* Fix Visual Studio build after r261574Hans Wennborg2016-02-221-3/+3
| | | | llvm-svn: 261583
* [ASTMatchers] Add matcher hasAnyName.Samuel Benzaquen2016-02-221-51/+107
| | | | | | | | | | | | 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
* Reduce the number of implicit StringRef->std::string conversions by ↵Benjamin Kramer2016-02-131-2/+3
| | | | | | | | threading StringRef through more APIs. No functionality change intended. llvm-svn: 260815
* [ASTMatchers] Allow hasName() to look through inline namespacesSamuel Benzaquen2016-02-051-21/+125
| | | | | | | | | | | | | | | | | Summary: Allow hasName() to look through inline namespaces. This will fix the interaction between some clang-tidy checks and libc++. libc++ defines names in an inline namespace named std::<version_#>. When we try to match a name using hasName("std::xxx") it fails to match and the clang-tidy check does not work. Reviewers: klimek Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D15506 llvm-svn: 259898
* [ASTMatchers] Use provided target NodeKind instead of inferring it from the ↵Samuel Benzaquen2015-07-171-5/+5
| | | | | | | | | | 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
* 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
* 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
* 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
* Filter the toplevel matchers by kind.Samuel Benzaquen2014-11-241-0/+19
| | | | | | | | | | | | | | | | | | 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
* Replace variadic operator function pointer with an enum value.Samuel Benzaquen2014-11-201-5/+45
| | | | | | | | | | | | | | | 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-171-3/+4
| | | | | | | | | | | | | | | | | | | 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
* ASTMatchers: Peel off a layer of indirection from true matcher. NFC.Benjamin Kramer2014-10-241-12/+10
| | | | llvm-svn: 220560
* ASTMatchers: for-rangify loops. No functionality change.Benjamin Kramer2014-10-241-11/+9
| | | | llvm-svn: 220559
* Fix code to follow the "Don’t use else after a return" rule.Samuel Benzaquen2014-10-161-7/+8
| | | | | | | | | | | | | | 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
* Speed up hasName() matcher.Samuel Benzaquen2014-10-151-0/+46
| | | | | | | | | | | | | | | | | | 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
* Fix order of evaluation bug in DynTypedMatcher::constructVariadic().Samuel Benzaquen2014-10-131-2/+2
| | | | | | | | 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
* Fix bug in DynTypedMatcher::constructVariadic() that would cause false ↵Samuel Benzaquen2014-10-131-12/+13
| | | | | | | | | | | | | | | | | | | 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
OpenPOWER on IntegriCloud