Commit Graph

305 Commits

Author SHA1 Message Date
Aaron Ballman 1978f7fe29 Clarify memory ownership semantics; NFC.
Patch by Clement Courbet

llvm-svn: 266986
2016-04-21 13:51:07 +00:00
Samuel Benzaquen d6b44aad31 [ASTMatchers] Do not try to memoize nodes we can't compare.
Summary:
Prevent hasAncestor from comparing nodes that are not supported.
hasDescendant was fixed some time ago to avoid this problem.
I'm applying the same fix to hasAncestor: if any object in the Builder map is
not comparable, skip the cache.

Reviewers: alexfh

Subscribers: klimek, cfe-commits

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

llvm-svn: 266748
2016-04-19 15:52:56 +00:00
Aaron Ballman 66eb58a756 Add typedefNameDecl() and typeAliasDecl() to the AST matchers; improves hasType() to match on TypedefNameDecl nodes.
Patch by Clement Courbet.

llvm-svn: 266331
2016-04-14 16:05:45 +00:00
Alexander Kornienko f11e099052 Reorder ASTNodeKind::AllKindInfo to match NodeKindId.
Summary:
AllKindInfo is being indexed by NodeKindId, so the order must match.
Extended ASTTypeTraits tests to cover this.

Reviewers: sbenza

Subscribers: cfe-commits, klimek

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

llvm-svn: 266268
2016-04-14 00:47:40 +00:00
Alexander Kornienko 7d20a5afdb Add AST Matchers for CXXConstructorDecl::isDelegatingConstructor and CXXMethodDecl::isUserProvided.
Summary: Added two AST matchers: isDelegatingConstructor for CXXConstructorDecl::IsDelegatingConstructor; and isUserProvided corresponding to CXXMethodDecl::isUserProvided.

Reviewers: aaron.ballman, alexfh

Subscribers: klimek, cfe-commits

Patch by Michael Miller!

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

llvm-svn: 266189
2016-04-13 11:13:08 +00:00
Matthias Gehre c27d8d8fd8 [ASTMatchers]: fix crash in hasReturnValue
Summary:
The crash was reproduced by the included test case. It was initially
found through a crash of clang-tidy's misc-misplaced-widening-cast
check.

Reviewers: klimek, alexfh

Subscribers: cfe-commits, klimek

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

llvm-svn: 266043
2016-04-12 05:43:18 +00:00
Gabor Horvath 1b654f2293 [ASTMatchers] Existing matcher hasAnyArgument fixed
Summary: A checker (will be uploaded after this patch) needs to check implicit casts. The checker needs matcher hasAnyArgument but it ignores implicit casts and parenthesized expressions which disables checking of implicit casts for arguments in the checker. However the documentation of the matcher contains a FIXME that this should be removed once separate matchers for ignoring implicit casts and parenthesized expressions are ready. Since these matchers were already there the fix could be executed. Only one Clang checker was affected which was also fixed (ignoreParenImpCasts added) and is separately uploaded. Third party checkers (not in the Clang repository) may be affected by this fix so the fix must be emphasized in the release notes.

Reviewers: klimek, sbenza, alexfh

Subscribers: alexfh, klimek, xazax.hun, cfe-commits

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

llvm-svn: 264855
2016-03-30 11:22:14 +00:00
Samuel Benzaquen c1384c138c [ASTMatchers] Add own version of VariadicFunction.
Summary:
llvm::VariadicFunction is only being used by ASTMatchers.
Having our own copy here allows us to remove the other one from llvm/ADT.
Also, we can extend the API to meet our needs without modifying the common
implementation.

Reviewers: alexfh

Subscribers: klimek, cfe-commits

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

llvm-svn: 264417
2016-03-25 16:29:30 +00:00
Alexander Kornienko 976921d4b4 [ASTMatchers] New matcher hasReturnValue added
Summary: A checker (will be uploaded after this patch) needs to check implicit casts. Existing generic matcher "has" ignores implicit casts and parenthesized expressions and no specific matcher for matching return value expression preexisted. The patch adds such a matcher (hasReturnValue).

Reviewers: klimek, sbenza

Subscribers: xazax.hun, klimek, cfe-commits

Patch by Ádám Balogh!

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

llvm-svn: 264037
2016-03-22 11:03:03 +00:00
Aaron Ballman 2648d42ecc Use an explicit instantiation to work around delayed template parsing for MSVC-built bots.
llvm-svn: 263041
2016-03-09 18:07:17 +00:00
Aaron Ballman a35b8fcef8 Adding new AST matchers for: addrLabelExpr, atomicExpr, binaryConditionalOperator, designatedInitExpr, designatorCountIs, hasSyntacticForm, implicitValueInitExpr, labelDecl, opaqueValueExpr, parenListExpr, predefinedExpr, requiresZeroInitialization, and stmtExpr.
Patch by Aleksei Sidorin.

llvm-svn: 263027
2016-03-09 17:11:51 +00:00
Aaron Ballman 6cbf4d8776 Turning on the /bigobj flag for two more files that will not link with MSVC 2015 Win64 Debug due to the section limit.
llvm-svn: 262938
2016-03-08 16:34:37 +00:00
Felix Berger 40ef42a932 [ASTMatchers] Document that isAnyPointer() matcher also matches Objective-C object pointers.
Summary: Add test for Objective-C object pointer matching.

Reviewers: aaron.ballman

Subscribers: klimek

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

llvm-svn: 262806
2016-03-06 15:27:59 +00:00
Samuel Benzaquen 922bef4f38 [ASTMatchers] Add matcher hasAnyName.
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
2016-02-22 21:13:02 +00:00
Aaron Ballman eb7e5d9074 Add an AST matcher for real floating-point types. e.g., float, double, long double, but not complex.
llvm-svn: 261221
2016-02-18 16:36:01 +00:00
Aaron Ballman cc928c80b4 Missing semicolons are kind of important. Who knew?
llvm-svn: 261009
2016-02-16 21:06:10 +00:00
Aaron Ballman 232e63d00b Add a nullPointerConstant() AST matcher to handle variations of null pointer constants in one matcher.
llvm-svn: 261008
2016-02-16 21:02:23 +00:00
Felix Berger cc9df3b9cc Add isAnyPointer() matchers. Register missing matchers.
Summary:
The isAnyPointer() matcher is useful for http://reviews.llvm.org/D15623.

Reviewers: alexfh, klimek

Subscribers: cfe-commits

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

llvm-svn: 260872
2016-02-15 04:00:39 +00:00
Nico Weber 26911c7733 Make ParentMap work with explicit specializations of function templates.
For an explicit specialization, we first build a FunctionDecl, and then
we call SubstDecl() on it to build a second FunctionDecl, which has the
first FunctionDecl as canonical decl.

The address of an explicit specialization of function template used to be the
canonical decl of the FunctionDecl.  This is different from all the other
DeduceTemplateArguments() calls in SemaOverload, and since the canonical decl
isn't visited by ParentMap while the redecl is, it also made ParentMap assert
when computing the parent of a address-of-explicit-specialization-fun-template.

To fix, remove the getCanonicalDecl() call.  No behavior difference for clang,
but it fixes an assert in ParentMap (which is e.g. used by libTooling).

llvm-svn: 260159
2016-02-08 22:23:09 +00:00
Samuel Benzaquen 8e566f3740 [ASTMatchers] Allow hasName() to look through inline namespaces
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
2016-02-05 18:29:24 +00:00
Daniel Jasper 739ae64346 Provide match function to look over an entire TU again.
llvm-svn: 259648
2016-02-03 14:29:55 +00:00
Nico Weber c097337493 Always build a new TypeSourceInfo for function templates with parameters
RecursiveASTVisitor::TraverseFunctionHelper() traverses a function's
ParmVarDecls by going to the function's getTypeSourceInfo if it exists, and
`DEF_TRAVERSE_TYPELOC(FunctionProtoType` then goes to the function's
ParmVarDecls.

For a function template that doesn't have parameters that explicitly depend on
the template parameter, we used to be clever and not build a new
TypeSourceInfo. That meant that when an instantiation of such a template is
visited, its TypeSourceInfo would point to the ParmVarDecls of the template,
not of the instantiation, which then confused clients of RecursiveASTVisitor.

So don't be clever for function templates that have parameters, even if none of
the parameters depend on the type.

Fixes PR26257.
http://reviews.llvm.org/D16478

llvm-svn: 259428
2016-02-01 22:31:51 +00:00
Aaron Ballman 7e7b7b2def Reapply r259210 with a fix for RegistryTest.cpp.
Patch by Richard Thomson.

llvm-svn: 259359
2016-02-01 14:11:47 +00:00
Hans Wennborg 2b79910d8b Revert r259210 "Extend hasType narrowing matcher for TypedefDecls, add functionProtoType matcher for FunctionProtoType nodes, extend parameterCountIs to FunctionProtoType nodes."
It didn't pass check-clang.

llvm-svn: 259218
2016-01-29 18:24:34 +00:00
Aaron Ballman fb9d0e354d Extend hasType narrowing matcher for TypedefDecls, add functionProtoType matcher for FunctionProtoType nodes, extend parameterCountIs to FunctionProtoType nodes.
Patch by Richard Thomson

llvm-svn: 259210
2016-01-29 17:03:11 +00:00
Benjamin Kramer 987a1d21e7 Add an optional ToolName argument to runToolOnCodeWithArgs/buildASTFromCodeWithArgs.
This can be used as a way to modify argv[0] for a clang tool.

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

llvm-svn: 259187
2016-01-29 11:29:02 +00:00
Nico Weber 7b837f578a Include RecordDecls from anonymous unions in the AST.
For

  void f() {
    union { int i; };
  }

clang used to omit the RecordDecl from the anonymous union from the AST.
That's because the code creating it only called PushOnScopeChains(), which adds
it to the current DeclContext, which here is the function's DeclContext. But
RecursiveASTVisitor doesn't descent into all decls in a FunctionDecl.

Instead, for DeclContexts that contain statements, return the RecordDecl so
that it can be included in the DeclStmt containing the VarDecl for the union.

Interesting bits from the AST before this change:

|-FunctionDecl
| `-CompoundStmt
|   |-DeclStmt
|   | `-VarDecl 0x589cd60 <col:3> col:3 implicit used 'union (anonymous at test.cc:3:3)' callinit

After this change:

-FunctionDecl
| `-CompoundStmt
|   |-DeclStmt
|   | |-CXXRecordDecl 0x4612e48 <col:3, col:18> col:3 union definition
|   | | |-FieldDecl 0x4612f70 <col:11, col:15> col:15 referenced i 'int'
|   | `-VarDecl 0x4613010 <col:3> col:3 implicit used 'union (anonymous at test.cc:3:3)' callinit

This is now closer to how anonymous struct and unions are represented as
members of structs.  It also enabled deleting some one-off code in the
template instantiation code.

Finally, it fixes a crash with ASTMatchers, see the included test case
(this fixes http://crbug.com/580749).

llvm-svn: 259079
2016-01-28 19:25:00 +00:00
Chris Bieneman 2bf68c6c1c Remove autoconf support
Summary:
This patch is provided in preparation for removing autoconf on 1/26. The proposal to remove autoconf on 1/26 was discussed on the llvm-dev thread here: http://lists.llvm.org/pipermail/llvm-dev/2016-January/093875.html

    "This is the way [autoconf] ends
    Not with a bang but a whimper."
    -T.S. Eliot

Reviewers: chandlerc, grosbach, bob.wilson, echristo

Subscribers: klimek, cfe-commits

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

llvm-svn: 258862
2016-01-26 21:30:40 +00:00
Aaron Ballman 31bde8762e Add am AST matcher for isMoveAssignmentOperator.
Patch by Jonathan Coe.

llvm-svn: 258573
2016-01-22 22:37:09 +00:00
Nico Weber c4acee3380 Let RecursiveASTVisitor visit array index VarDecls
An implicit copy ctor creates loop VarDecls that hang off CXXCtorInitializer.
RecursiveASTVisitor used to not visit them, so that they didn't show up in the
parent map used by ASTMatchers, causing asserts() when the implicit
DeclRefExpr() in a CXXCtorInitializer referred to one of these VarDecls.

Fixes PR26227.
http://reviews.llvm.org/D16413

llvm-svn: 258503
2016-01-22 15:11:54 +00:00
Nico Weber a415a1d0d7 Add an isVirtualAsWritten AST matcher.
http://reviews.llvm.org/D16394

llvm-svn: 258415
2016-01-21 17:56:24 +00:00
Aaron Ballman 2b6963fce9 Add AST matcher support for FunctionDecls with the hasBody matcher.
Patch by Aleksei Sidorin.

llvm-svn: 258322
2016-01-20 16:26:48 +00:00
Aaron Ballman e8295d7980 Add AST matcher for paren expressions.
Patch by Adrian Zgorzałek.

llvm-svn: 258321
2016-01-20 16:17:39 +00:00
Aaron Ballman 9e373df2f7 The destructor name should be matched to ~Foo instead of Foo.
llvm-svn: 258077
2016-01-18 20:47:02 +00:00
Aaron Ballman eb85b04c7e Add an AST matcher for checking whether a function is defaulted.
Patch by Jonathan Coe.

llvm-svn: 258072
2016-01-18 20:37:44 +00:00
Aaron Ballman d7b18b9f2f Augments r258042; changes the AST matcher tests to use matchesNot and EXPECT_TRUE instead of EXPECT_FALSE. Adds a matcher test to ensure that static member functions are properly handled. Generates the documentation from the matcher.
llvm-svn: 258070
2016-01-18 20:28:57 +00:00
Manuel Klimek ce28f9ebd3 Add forEachArgumentWithParam AST matcher.
The new matcher allows users to provide a matcher for both the argument
of a CallExpr/CxxConstructExpr a well as the ParmVarDecl of the
argument.

Patch by Felix Berger.

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

llvm-svn: 258042
2016-01-18 11:20:09 +00:00
Samuel Benzaquen bd3232af03 [ASTMatchers] Add booleanType() matcher.
llvm-svn: 256278
2015-12-22 20:06:40 +00:00
Gabor Horvath 009c5d52e3 Add a new matcher to match character types.
llvm-svn: 255627
2015-12-15 08:35:45 +00:00
Aaron Ballman a60bcdab92 Add a narrowing AST matcher that matches on a FunctionDecl with a non-throwing exception specification.
llvm-svn: 254516
2015-12-02 15:23:59 +00:00
Daniel Jasper c8f472c3a6 Traverse the NestedNameSpecifier(Loc) of NamespaceAliasDecls.
Review: http://reviews.llvm.org/D15149
llvm-svn: 254510
2015-12-02 13:57:46 +00:00
Aaron Ballman 6290fc9154 Add an AST matcher for narrowing when a type is volatile-qualified.
llvm-svn: 253882
2015-11-23 17:09:24 +00:00
Aaron Ballman f08e184815 Removing the AST matcher test for thread_local storage duration. Not all platforms support TLS, and on platforms that do not support it, use of thread_local causes an error. Since there's no way to determine whether the testing platform supports TLS, there's no way to know whether the test is safe to run or not. I will explore ways to enable this test, but this will appease at least one more build bot.
llvm-svn: 253486
2015-11-18 18:37:29 +00:00
Aaron Ballman 8e7f00b0eb Re-committing r253473 after hopefully fixing the bot breakage. There was a copy-pasta issue that my local testing did not catch.
llvm-svn: 253481
2015-11-18 17:56:55 +00:00
Aaron Ballman 81d17f2f7e Reverting r253473 while I investigate build bot failures.
llvm-svn: 253475
2015-11-18 17:16:01 +00:00
Aaron Ballman 34e0bd40e4 Adding AST matchers for VarDecl storage durations. Can now determine whether a VarDecl has automatic, static, or thread storage duration. This also updates the documentation for matchers, which appear to be missing some previous additions.
llvm-svn: 253473
2015-11-18 17:05:39 +00:00
Artem Belevich 8601733c1c [CUDA] Make CUDA compilation usable by default.
Currently clang requires several additional command
line options in order to enable new features needed
during CUDA compilation. This patch makes these
options default.

* Automatically include cuda_runtime.h if we've found
  a valid CUDA installation.
* Disable automatic CUDA header inclusion during unit tests.
* Added test case for command line construction.
* Enabled target overloads and relaxed call checks that are
  needed in order to include CUDA headers.
* Added CUDA-7.5 installation path to the CUDA installation search list.
* Define __CUDA__ macro to indicate CUDA compilation.

llvm-svn: 253389
2015-11-17 22:28:55 +00:00
Alexander Kornienko e39993eb86 Make hasLHS and hasRHS matchers available for ArraySubscriptExpr
Summary:
The hasBase and hasIndex don't tell anything about the position of the
base and the index in the code, so we need hasLHS and hasRHS in some cases.

Reviewers: klimek

Subscribers: klimek, cfe-commits

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

llvm-svn: 251842
2015-11-02 22:23:21 +00:00
Angel Garcia Gomez 4647ed74ac Add "equalsNode" for types and "isCopyAssignmentOperator" matchers.
Summary: This matchers are going to be used in modernize-use-default, but are generic enough to be placed in ASTMatchers.h.

Reviewers: klimek

Subscribers: alexfh, cfe-commits, klimek

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

llvm-svn: 251693
2015-10-30 09:35:51 +00:00
Benjamin Kramer 94355aeff8 [AST] Re-add TypeLocs and NestedNameSpecifierLocs to the ParentMap.
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
2015-10-23 09:04:55 +00:00