Commit Graph

416 Commits

Author SHA1 Message Date
Artem Belevich c62214da3d [CUDA] add support for the new kernel launch API in CUDA-9.2+.
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
2019-01-31 21:34:03 +00:00
Chandler Carruth 2946cd7010 Update the file headers across all of the LLVM projects in the monorepo
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
2019-01-19 08:50:56 +00:00
Hyrum Wright 2cd40c0170 [clang] Add AST matcher for initializer list members
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
2019-01-07 14:14:36 +00:00
Stephane Moore 3897b2dca1 [clang] Add AST matcher for block expressions 🔍
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
2018-12-13 03:35:10 +00:00
Eric Fiselier 5cdc2cda28 [AST] Store "UsesADL" information in CallExpr.
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
2018-12-12 21:50:55 +00:00
Fangrui Song 5313327f61 Add explicit dependency on clangSerialization for a bunch of components to 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
2018-12-12 08:02:18 +00:00
Clement Courbet a6144db15f Revert rL347462 "[ASTMatchers] Add hasSideEffect() matcher."
Breaks some buildbots.

llvm-svn: 347463
2018-11-22 14:26:33 +00:00
Clement Courbet c022c51f89 [ASTMatchers] Add hasSideEffect() matcher.
Summary: Exposes Expr::HasSideEffects.

Reviewers: aaron.ballman

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D54830

llvm-svn: 347462
2018-11-22 14:00:56 +00:00
Jonas Toth 295aa09dd2 [ASTMatchers] overload ignoringParens for Expr
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
2018-11-09 20:54:06 +00:00
Bill Wendling 8003edc9aa Compound literals, enums, et al require const expr
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
2018-11-09 00:41:36 +00:00
Aaron Ballman 31f48c50cd Add the isStaticLocal() AST matcher for matching on local static variables.
Patch by Joe Ranieri.

llvm-svn: 345502
2018-10-29 13:47:56 +00:00
Fangrui Song f7868ec25b Revert "[ASTMatchers] Fix DynamicASTMatchersTests again"
This reverts commit 8a6631a983ec9c1d22cc77c5f55a524a651740f0.

The last fix seems good in Debug mode.

llvm-svn: 343738
2018-10-03 22:56:26 +00:00
Fangrui Song f8c4f4e6e7 [ASTMatchers] Fix DynamicASTMatchersTests again
llvm-svn: 343722
2018-10-03 21:00:44 +00:00
Fangrui Song e154d4cbf5 [test] Fix -Wunused-variable in rC343665
llvm-svn: 343721
2018-10-03 20:53:53 +00:00
Stephen Kelly 7c787b8adf Allow comments with '#' in dynamic AST Matchers
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
2018-10-03 07:56:43 +00:00
Shuai Wang e0248aecbe [ASTMatchers] Let isArrow also support UnresolvedMemberExpr, CXXDependentScopeMemberExpr
Reviewers: aaron.ballman

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D52157

llvm-svn: 342407
2018-09-17 18:48:43 +00:00
Jonas Toth 2253878a40 [ASTMatchers] add three matchers for dependent expressions
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
2018-09-11 16:09:19 +00:00
Stephen Kelly fc934cd916 Allow binding to NamedValue resulting from let expression
Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D51259

llvm-svn: 341142
2018-08-30 23:11:09 +00:00
Shuai Wang 92f9d1b8ac [ASTMatchers] Let hasObjectExpression also support UnresolvedMemberExpr, CXXDependentScopeMemberExpr
Reviewers: aaron.ballman

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D50617

llvm-svn: 340547
2018-08-23 17:16:06 +00:00
David Green db63228a5c Fix ASTMatchersTraversalTest testcase compile on older compilers
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
2018-08-15 10:39:43 +00:00
Stephen Kelly 0945c8b942 Fix Stmt::ignoreImplicit
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
2018-08-14 21:33:28 +00:00
Shuai Wang 3b2a17bd1d [ASTMatchers] Let hasAnyArgument also support CXXUnresolvedConstructExpr
Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D50605

llvm-svn: 339530
2018-08-12 23:30:05 +00:00
Shuai Wang 72b56ed6b4 [ASTMatchers] Add matchers unresolvedMemberExpr, cxxDependentScopeMemberExpr
Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D50606

llvm-svn: 339522
2018-08-12 17:34:36 +00:00
George Karpenkov 079275b4dc [ASTMatchers] Introduce a matcher for `ObjCIvarExpr`, support getting it's 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
2018-07-27 17:26:11 +00:00
George Karpenkov fc3d72eeea [ASTMatchers] Add an isMain() matcher
Differential Revision: https://reviews.llvm.org/D49615

llvm-svn: 337761
2018-07-23 22:29:35 +00:00
Jonas Toth fa1ea6977c [ASTMatchers] add matcher for decltypeType and its underlyingType
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
2018-07-23 15:59:27 +00:00
George Karpenkov 810ed5b407 [ASTMatchers] Quickfix for tests.
llvm-svn: 337214
2018-07-16 20:42:37 +00:00
George Karpenkov b5ea4df0eb [ASTMatchers] Introduce Objective-C matchers `hasReceiver` and `isInstanceMessage` for ObjCMessageExpr
Differential Revision: https://reviews.llvm.org/D49333

llvm-svn: 337209
2018-07-16 20:22:12 +00:00
George Karpenkov ba02bc5226 [ASTMatchers] A matcher for Objective-C @autoreleasepool
Differential Revision: https://reviews.llvm.org/D48910

llvm-svn: 336468
2018-07-06 21:36:04 +00:00
David L. Jones 82e08bd776 [ASTMatchers] Add support for matching the type of a friend decl.
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
2018-06-18 09:23:08 +00:00
David L. Jones 8f7adcd7fb [ASTMatchers] Don't assert-fail in specifiesTypeLoc().
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
2018-06-18 08:59:16 +00:00
George Karpenkov b4c0cbda1e [ASTMatchers] Introduce a blockDecl matcher for matching block declarations
Blocks can be matched just as well as functions or Objective-C methods.

Differential Revision: https://reviews.llvm.org/D46980

llvm-svn: 332545
2018-05-16 22:47:03 +00:00
Gabor Horvath 3cd0aa3b7e [ASTMatchers] Overload isConstexpr for ifStmts
Differential Revision: https://reviews.llvm.org/D46233

llvm-svn: 331759
2018-05-08 11:53:32 +00:00
Nico Weber 1865df4996 s/LLVM_ON_WIN32/_WIN32/, clang
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
2018-04-27 19:11:14 +00:00
Nico Weber f3e043f67b Make add_clang_unittest formatting a bit more consistent.
llvm-svn: 330839
2018-04-25 16:20:43 +00:00
George Karpenkov 88a16a0790 [ASTMatchers] Introduce a matcher for matching any given Objective-C selector
Incudes a tiny related refactoring.

Differential Revision: https://reviews.llvm.org/D44858

llvm-svn: 328747
2018-03-29 00:51:12 +00:00
George Karpenkov 9d1d0c4c57 [ASTMatchers] Extend hasParameter and hasAnyParameter matches to handle Objective-C methods
Differential Revision: https://reviews.llvm.org/D44707

llvm-svn: 328746
2018-03-29 00:51:11 +00:00
Peter Szecsi fff11dbc48 [ASTMatchers] Add isAssignmentOperator matcher
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
2018-03-27 12:11:46 +00:00
George Karpenkov a763fdfadd [ASTMatcher] Extend hasAnyArgument to ObjCMessageExpr
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
2018-03-07 02:32:44 +00:00
Eric Liu 500e126155 [ASTMatchers] isTemplateInstantiation: also match explicit instantiation 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
2018-02-21 13:51:27 +00:00
Julie Hockett 239d25a158 Add hasTrailingReturn AST matcher
Adds AST matcher for a FunctionDecl that has a trailing return type.

Differential Revision: https://reviews.llvm.org/D42273

llvm-svn: 323158
2018-01-22 22:45:23 +00:00
Haojian Wu 9c3be3a4e5 [ASTMatcher] Add isScoped matcher for enumDecl.
Summary:

Reviewers: bkramer, aaron.ballman

Subscribers: aaron.ballman, cfe-commits, klimek

Differential Revision: https://reviews.llvm.org/D42185

llvm-svn: 322826
2018-01-18 09:47:57 +00:00
Roman Lebedev 6c3871b139 [ASTMatchers] Add isNoReturn() match narrower for FunctionDeclarations
Reviewers: aaron.ballman

Reviewed By: aaron.ballman

Subscribers: dblaikie, klimek, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D41455

llvm-svn: 322746
2018-01-17 19:40:55 +00:00
Shoaib Meenai d806af3499 [CMake] Use PRIVATE in target_link_libraries for executables
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
2017-12-05 21:49:56 +00:00
Aaron Ballman 813e36c2c1 Add the hasDefinition() AST matcher to match class declarations that also have a definition.
Patch by Julie Hockett.

llvm-svn: 319360
2017-11-29 21:21:51 +00:00
Adam Balogh da488a65e2 [ASTMatchers] Matchers for new[] operators
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
2017-11-23 12:43:20 +00:00
Aaron Ballman 5f8980a995 Add an AST matcher for hasDefaultArgument() to match on parameter declarations that have a default value.
Patch by Julie Hockett.

llvm-svn: 318794
2017-11-21 19:22:34 +00:00
Dave Lee be39868bfc Make isDefinition matcher support ObjCMethodDecl
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
2017-11-14 14:17:26 +00:00
Dave Lee 0934fdc3a5 Add ObjC exception statement AST matchers
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
2017-11-11 22:46:15 +00:00
Dave Lee 55540a0ce7 Add objcCategoryImplDecl matcher
Summary:
Add `objcCategoryImplDecl` which matches ObjC category definitions
(`@implementation`). This matcher complements `objcCategoryDecl` (`@interface`)
which was added in D30854.

Reviewers: aaron.ballman, malcolm.parsons, alexshap

Reviewed By: aaron.ballman

Subscribers: klimek, cfe-commits

Differential Revision: https://reviews.llvm.org/D39293

llvm-svn: 316670
2017-10-26 15:53:37 +00:00