summaryrefslogtreecommitdiffstats
path: root/clang/unittests/ASTMatchers
Commit message (Collapse)AuthorAgeFilesLines
...
* Add tests for assorted `CXXMemberCallExpr` matchers.Yitzhak Mandelbaum2019-02-151-0/+89
| | | | | | | | | | Summary: Add tests for matchers `on`, `onImplicitObjectArgument` and `hasObjectExpression`. Reviewers: alexfh, steveire, aaron.ballman Differential Revision: https://reviews.llvm.org/D56850 llvm-svn: 354133
* [CUDA] add support for the new kernel launch API in CUDA-9.2+.Artem Belevich2019-01-311-1/+3
| | | | | | | | | | | | | Instead of calling CUDA runtime to arrange function arguments, the new API constructs arguments in a local array and the kernels are launched with __cudaLaunchKernel(). The old API has been deprecated and is expected to go away in the next CUDA release. Differential Revision: https://reviews.llvm.org/D57488 llvm-svn: 352799
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-198-32/+24
| | | | | | | | | | | | | | | | | 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
* [clang] Add AST matcher for initializer list membersHyrum Wright2019-01-071-0/+12
| | | | | | | | | | | | | Summary: Much like hasArg for various call expressions, this allows LibTooling users to match against a member of an initializer list. This is currently being used as part of the abseil-duration-scale clang-tidy check. Differential Revision: https://reviews.llvm.org/D56090 llvm-svn: 350523
* [clang] Add AST matcher for block expressions 🔍Stephane Moore2018-12-131-0/+4
| | | | | | | | | | | | | | | | | | 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
* [AST] Store "UsesADL" information in CallExpr.Eric Fiselier2018-12-121-0/+34
| | | | | | | | | | | | | | | | | | | | | Summary: Currently the Clang AST doesn't store information about how the callee of a CallExpr was found. Specifically if it was found using ADL. However, this information is invaluable to tooling. Consider a tool which renames usages of a function. If the originally CallExpr was formed using ADL, then the tooling may need to additionally qualify the replacement. Without information about how the callee was found, the tooling is left scratching it's head. Additionally, we want to be able to match ADL calls as quickly as possible, which means avoiding computing the answer on the fly. This patch changes `CallExpr` to store whether it's callee was found using ADL. It does not change the size of any AST nodes. Reviewers: fowles, rsmith, klimek, shafik Reviewed By: rsmith Subscribers: aaron.ballman, riccibruno, calabrese, titus, cfe-commits Differential Revision: https://reviews.llvm.org/D55534 llvm-svn: 348977
* Add explicit dependency on clangSerialization for a bunch of components to ↵Fangrui Song2018-12-122-0/+2
| | | | | | | | | | | | | | | fix -DBUILD_SHARED_LIBS=on build This is a more thorough fix of rC348911. The story about -DBUILD_SHARED_LIBS=on build after rC348907 (Move PCHContainerOperations from Frontend to Serialization) is: 1. libclangSerialization.so defines PCHContainerReader dtor, ... 2. clangFrontend and clangTooling define classes inheriting from PCHContainerReader, thus their DSOs have undefined references on PCHContainerReader dtor 3. Components depending on either clangFrontend or clangTooling cannot be linked unless they have explicit dependency on clangSerialization due to the default linker option -z defs. The explicit dependency could be avoided if libclang{Frontend,Tooling}.so had these undefined references. This patch adds the explicit dependency on clangSerialization to make them build. llvm-svn: 348915
* Revert rL347462 "[ASTMatchers] Add hasSideEffect() matcher."Clement Courbet2018-11-221-16/+0
| | | | | | Breaks some buildbots. llvm-svn: 347463
* [ASTMatchers] Add hasSideEffect() matcher.Clement Courbet2018-11-221-0/+16
| | | | | | | | | | | | Summary: Exposes Expr::HasSideEffects. Reviewers: aaron.ballman Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D54830 llvm-svn: 347462
* [ASTMatchers] overload ignoringParens for ExprJonas Toth2018-11-091-0/+8
| | | | | | | | | | | | | | | | Summary: This patch allows fixing PR39583. Reviewers: aaron.ballman, sbenza, klimek Reviewed By: aaron.ballman Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D54307 llvm-svn: 346554
* Compound literals, enums, et al require const exprBill Wendling2018-11-092-9/+12
| | | | | | | | | | | | | | | | | | 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
* Add the isStaticLocal() AST matcher for matching on local static variables.Aaron Ballman2018-10-291-0/+8
| | | | | | Patch by Joe Ranieri. llvm-svn: 345502
* Revert "[ASTMatchers] Fix DynamicASTMatchersTests again"Fangrui Song2018-10-031-0/+1
| | | | | | | | This reverts commit 8a6631a983ec9c1d22cc77c5f55a524a651740f0. The last fix seems good in Debug mode. llvm-svn: 343738
* [ASTMatchers] Fix DynamicASTMatchersTests againFangrui Song2018-10-031-1/+0
| | | | llvm-svn: 343722
* [test] Fix -Wunused-variable in rC343665Fangrui Song2018-10-031-1/+1
| | | | llvm-svn: 343721
* Allow comments with '#' in dynamic AST MatchersStephen Kelly2018-10-031-2/+17
| | | | | | | | | | | | | | Summary: This is necessary for clang-query to be able to handle comments. Reviewers: aaron.ballman Reviewed By: aaron.ballman Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D52751 llvm-svn: 343665
* [ASTMatchers] Let isArrow also support UnresolvedMemberExpr, ↵Shuai Wang2018-09-173-2/+16
| | | | | | | | | | | | CXXDependentScopeMemberExpr Reviewers: aaron.ballman Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D52157 llvm-svn: 342407
* [ASTMatchers] add three matchers for dependent expressionsJonas Toth2018-09-111-0/+42
| | | | | | | | | | | | | | | | | | | Summary: The new matchers can be used to check if an expression is type-, value- or instantiation-dependent in a templated context. These matchers are used in a clang-tidy check and generally useful as the problem of unresolved templates occurs more often in clang-tidy and they provide an easy way to check for this issue. Reviewers: aaron.ballman, alexfh, klimek Reviewed By: aaron.ballman Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D51880 llvm-svn: 341958
* Allow binding to NamedValue resulting from let expressionStephen Kelly2018-08-301-0/+38
| | | | | | | | Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D51259 llvm-svn: 341142
* [ASTMatchers] Let hasObjectExpression also support UnresolvedMemberExpr, ↵Shuai Wang2018-08-231-0/+20
| | | | | | | | | | | | CXXDependentScopeMemberExpr Reviewers: aaron.ballman Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D50617 llvm-svn: 340547
* Fix ASTMatchersTraversalTest testcase compile on older compilersDavid Green2018-08-151-3/+3
| | | | | | | | Some versions of gcc, especially when invoked through ccache (-E), can have trouble with raw string literals inside macros. This moves the string out of the macro. llvm-svn: 339759
* Fix Stmt::ignoreImplicitStephen Kelly2018-08-141-0/+39
| | | | | | | | | | | | | | | | Summary: A CXXBindTemporaryExpr can appear inside an ImplicitCastExpr, and was not ignored previously. Fixes the case reported in PR37327. Reviewers: rsmith, dblaikie, klimek Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D50666 llvm-svn: 339730
* [ASTMatchers] Let hasAnyArgument also support CXXUnresolvedConstructExprShuai Wang2018-08-121-0/+19
| | | | | | | | Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D50605 llvm-svn: 339530
* [ASTMatchers] Add matchers unresolvedMemberExpr, cxxDependentScopeMemberExprShuai Wang2018-08-121-0/+14
| | | | | | | | Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D50606 llvm-svn: 339522
* [ASTMatchers] Introduce a matcher for `ObjCIvarExpr`, support getting it's ↵George Karpenkov2018-07-271-0/+10
| | | | | | | | | | | | | 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 an isMain() matcherGeorge Karpenkov2018-07-231-0/+8
| | | | | | Differential Revision: https://reviews.llvm.org/D49615 llvm-svn: 337761
* [ASTMatchers] add matcher for decltypeType and its underlyingTypeJonas Toth2018-07-231-0/+6
| | | | | | | | | | | | | | | | 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] Quickfix for tests.George Karpenkov2018-07-161-6/+6
| | | | llvm-svn: 337214
* [ASTMatchers] Introduce Objective-C matchers `hasReceiver` and ↵George Karpenkov2018-07-161-0/+29
| | | | | | | | `isInstanceMessage` for ObjCMessageExpr Differential Revision: https://reviews.llvm.org/D49333 llvm-svn: 337209
* [ASTMatchers] A matcher for Objective-C @autoreleasepoolGeorge Karpenkov2018-07-061-0/+12
| | | | | | Differential Revision: https://reviews.llvm.org/D48910 llvm-svn: 336468
* [ASTMatchers] Add support for matching the type of a friend decl.David L. Jones2018-06-181-0/+10
| | | | | | | | | | | | | | | | | This allows matchers like: friendDecl(hasType(cxxRecordDecl(...))) friendDecl(hasType(asString(...))) It seems that hasType is probably the most reasonable narrowing matcher to overload, since it is already used to narrow to other declaration kinds. Differential Revision: https://reviews.llvm.org/D48242 Reviewers: klimek, aaron.ballman Subscribers: cfe-commits llvm-svn: 334930
* [ASTMatchers] Don't assert-fail in specifiesTypeLoc().David L. Jones2018-06-181-0/+4
| | | | | | | | The specifiesTypeLoc() matcher narrows a nestedNameSpecifier matcher based on a typeloc within the NNS. However, the matcher does not guard against NNS which are a namespace, and cause getTypeLoc to assert-fail. llvm-svn: 334929
* [ASTMatchers] Introduce a blockDecl matcher for matching block declarationsGeorge Karpenkov2018-05-162-1/+5
| | | | | | | | Blocks can be matched just as well as functions or Objective-C methods. Differential Revision: https://reviews.llvm.org/D46980 llvm-svn: 332545
* [ASTMatchers] Overload isConstexpr for ifStmtsGabor Horvath2018-05-081-0/+4
| | | | | | Differential Revision: https://reviews.llvm.org/D46233 llvm-svn: 331759
* s/LLVM_ON_WIN32/_WIN32/, clangNico Weber2018-04-271-2/+2
| | | | | | | | | | | LLVM_ON_WIN32 is set exactly with MSVC and MinGW (but not Cygwin) in HandleLLVMOptions.cmake, which is where _WIN32 defined too. Just use the default macro instead of a reinvented one. See thread "Replacing LLVM_ON_WIN32 with just _WIN32" on llvm-dev and cfe-dev. No intended behavior change. llvm-svn: 331069
* Make add_clang_unittest formatting a bit more consistent.Nico Weber2018-04-252-2/+4
| | | | llvm-svn: 330839
* [ASTMatchers] Introduce a matcher for matching any given Objective-C selectorGeorge Karpenkov2018-03-292-0/+22
| | | | | | | | Incudes a tiny related refactoring. Differential Revision: https://reviews.llvm.org/D44858 llvm-svn: 328747
* [ASTMatchers] Extend hasParameter and hasAnyParameter matches to handle ↵George Karpenkov2018-03-292-7/+12
| | | | | | | | Objective-C methods Differential Revision: https://reviews.llvm.org/D44707 llvm-svn: 328746
* [ASTMatchers] Add isAssignmentOperator matcherPeter Szecsi2018-03-271-0/+15
| | | | | | | | | | | Adding a matcher for BinaryOperator and cxxOperatorCallExpr to be able to decide whether it is any kind of assignment operator or not. This would be useful since allows us to easily detect assignments via matchers for static analysis (Tidy, SA) purposes. Differential Revision: https://reviews.llvm.org/D44893 llvm-svn: 328618
* [ASTMatcher] Extend hasAnyArgument to ObjCMessageExprGeorge Karpenkov2018-03-071-3/+10
| | | | | | | | | | | | | | | Currently hasArgument works with both ObjC messages and function calls, but not hasAnyArgument. This patch fixes that discrepancy, as it's often more convenient to use hasAnyArgument. On a more general note, it would be great to have a common superclass for objc-call and function call, and a matcher matching that, but that's probably a job for another commit. Differential Revision: https://reviews.llvm.org/D44169 llvm-svn: 326865
* [ASTMatchers] isTemplateInstantiation: also match explicit instantiation ↵Eric Liu2018-02-211-0/+8
| | | | | | | | | | | | | | | | | | declaration. Summary: Example: template <typename T> class X {}; class A {}; // Explicit instantiation declaration. extern template class X<A>; Reviewers: bkramer Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D43567 llvm-svn: 325678
* Add hasTrailingReturn AST matcherJulie Hockett2018-01-221-0/+19
| | | | | | | | Adds AST matcher for a FunctionDecl that has a trailing return type. Differential Revision: https://reviews.llvm.org/D42273 llvm-svn: 323158
* [ASTMatcher] Add isScoped matcher for enumDecl.Haojian Wu2018-01-181-0/+5
| | | | | | | | | | | | Summary: Reviewers: bkramer, aaron.ballman Subscribers: aaron.ballman, cfe-commits, klimek Differential Revision: https://reviews.llvm.org/D42185 llvm-svn: 322826
* [ASTMatchers] Add isNoReturn() match narrower for FunctionDeclarationsRoman Lebedev2018-01-171-0/+78
| | | | | | | | | | | | | | Reviewers: aaron.ballman Reviewed By: aaron.ballman Subscribers: dblaikie, klimek, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D41455 llvm-svn: 322746
* [CMake] Use PRIVATE in target_link_libraries for executablesShoaib Meenai2017-12-052-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We currently use target_link_libraries without an explicit scope specifier (INTERFACE, PRIVATE or PUBLIC) when linking executables. Dependencies added in this way apply to both the target and its dependencies, i.e. they become part of the executable's link interface and are transitive. Transitive dependencies generally don't make sense for executables, since you wouldn't normally be linking against an executable. This also causes issues for generating install export files when using LLVM_DISTRIBUTION_COMPONENTS. For example, clang has a lot of LLVM library dependencies, which are currently added as interface dependencies. If clang is in the distribution components but the LLVM libraries it depends on aren't (which is a perfectly legitimate use case if the LLVM libraries are being built static and there are therefore no run-time dependencies on them), CMake will complain about the LLVM libraries not being in export set when attempting to generate the install export file for clang. This is reasonable behavior on CMake's part, and the right thing is for LLVM's build system to explicitly use PRIVATE dependencies for executables. Unfortunately, CMake doesn't allow you to mix and match the keyword and non-keyword target_link_libraries signatures for a single target; i.e., if a single call to target_link_libraries for a particular target uses one of the INTERFACE, PRIVATE, or PUBLIC keywords, all other calls must also be updated to use those keywords. This means we must do this change in a single shot. I also fully expect to have missed some instances; I tested by enabling all the projects in the monorepo (except dragonegg), and configuring both with and without shared libraries, on both Darwin and Linux, but I'm planning to rely on the buildbots for other configurations (since it should be pretty easy to fix those). Even after this change, we still have a lot of target_link_libraries calls that don't specify a scope keyword, mostly for shared libraries. I'm thinking about addressing those in a follow-up, but that's a separate change IMO. Differential Revision: https://reviews.llvm.org/D40823 llvm-svn: 319840
* Add the hasDefinition() AST matcher to match class declarations that also ↵Aaron Ballman2017-11-291-0/+21
| | | | | | | | have a definition. Patch by Julie Hockett. llvm-svn: 319360
* [ASTMatchers] Matchers for new[] operatorsAdam Balogh2017-11-231-0/+10
| | | | | | | | Two new matchers for `CXXNewExpr` are added which may be useful e.g. in `clang-tidy` checkers. One of them is `isArray` which matches `new[]` but not plain `new`. The other one, `hasArraySize` matches `new[]` for a given size. llvm-svn: 318909
* Add an AST matcher for hasDefaultArgument() to match on parameter ↵Aaron Ballman2017-11-211-0/+7
| | | | | | | | declarations that have a default value. Patch by Julie Hockett. llvm-svn: 318794
* Make isDefinition matcher support ObjCMethodDeclDave Lee2017-11-141-0/+8
| | | | | | | | | | | | | | | | | Summary: Allow the `isDefinition()` matcher to apply to `ObjCMethodDecl` nodes, in addition to those it already supports. For whatever reason, `ObjCMethodDecl` does not inherit from `FunctionDecl` and so this is specialization is necessary. Reviewers: aaron.ballman, malcolm.parsons, alexshap Reviewed By: aaron.ballman Subscribers: cfe-commits, klimek Differential Revision: https://reviews.llvm.org/D39948 llvm-svn: 318152
* Add ObjC exception statement AST matchersDave Lee2017-11-111-0/+23
| | | | | | | | | | | | | | Summary: Add AST matchers for Objective-C @throw, @try, @catch and @finally. Reviewers: aaron.ballman, malcolm.parsons, alexshap, compnerd Reviewed By: aaron.ballman Subscribers: cfe-commits, klimek Differential Revision: https://reviews.llvm.org/D39940 llvm-svn: 317992
OpenPOWER on IntegriCloud