Commit Graph

194 Commits

Author SHA1 Message Date
Malcolm Parsons a3220ce6a3 Tracking exception specification source locations
Summary:
We do not currently track the source locations for exception specifications such
that their source range can be queried through the AST. This leads to trying to
write more complex code to determine the source range for uses like FixItHints
(see D18575 for an example). In addition to use within tools like clang-tidy, I
think this information may become more important to track as exception
specifications become more integrated into the type system.

Patch by Don Hinton.

Reviewers: rsmith

Subscribers: malcolm.parsons, sbarzowski, alexfh, hintonda, cfe-commits

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

llvm-svn: 291771
2017-01-12 16:11:28 +00:00
David Blaikie ea4395ebcd Reapply "IntrusiveRefCntPtr -> std::shared_ptr for CompilerInvocationBase and CodeCompleteConsumer"
Aleksey Shlypanikov pointed out my mistake in migrating an explicit
unique_ptr to auto - I was expecting the function returned a unique_ptr,
but instead it returned a raw pointer - introducing a leak.

Thanks Aleksey!

This reapplies r291184, reverted in r291249.

llvm-svn: 291270
2017-01-06 19:49:01 +00:00
David Blaikie 81d0829438 Revert "IntrusiveRefCntPtr -> std::shared_ptr for CompilerInvocationBase and CodeCompleteConsumer"
Caused a memory leak reported by asan. Reverting while I investigate.

This reverts commit r291184.

llvm-svn: 291249
2017-01-06 17:47:10 +00:00
David Blaikie 9280a857bc IntrusiveRefCntPtr -> std::shared_ptr for CompilerInvocationBase and CodeCompleteConsumer
llvm-svn: 291184
2017-01-05 22:19:11 +00:00
Alexander Kornienko 7cdc705b03 Remove deprecated methods ast_matchers::BoundNodes::{getStmtAs,getDeclAs}
llvm-svn: 289543
2016-12-13 16:19:34 +00:00
Malcolm Parsons a29d98fcb5 [RecursiveASTVisitor] Improve post-order traversal unit test
llvm-svn: 288976
2016-12-07 20:38:20 +00:00
Malcolm Parsons b2b0cb7ca8 [RecursiveASTVisitor] Fix post-order traversal of UnaryOperator
Reviewers: aaron.ballman, klimek, doug.gregor, teemperor, rsmith

Subscribers: cfe-commits

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

llvm-svn: 288923
2016-12-07 17:39:04 +00:00
Gabor Horvath 0866c2f5d4 [ASTImporter] Added ability to import AtomicType nodes
Patch by: Kareem Khazem

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

llvm-svn: 287763
2016-11-23 15:24:23 +00:00
Serge Pavlov a67a4d2f3c Make output of -ast-print a valid C++ code.
Output generated by option -ast-print looks like C/C++ code, and it
really is for plain C. For C++ the produced output was not valid C++
code, but the differences were small. With this change the output
is fixed and can be compiled. Tests are changed so that output produced
by -ast-print is compiled again with the same flags and both outputs are
compared.

Option -ast-print is extensively used in clang tests but it itself
was tested poorly, existing tests only checked that compiler did not
crash. There are unit tests in file DeclPrinterTest.cpp, but they test
only terse output mode.

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

llvm-svn: 286439
2016-11-10 08:49:37 +00:00
Malcolm Parsons f76f6507c2 Fix Clang-tidy readability-redundant-string-cstr warnings
Reviewers: aaron.ballman, mehdi_amini, dblaikie

Subscribers: cfe-commits

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

llvm-svn: 285799
2016-11-02 10:39:27 +00:00
Malcolm Parsons 57c09c8e23 [Sema] Store a SourceRange for multi-token builtin types
Summary:
clang-tidy's modernize-use-auto check uses the SourceRange of a
TypeLoc when replacing the type with auto.
This was producing the wrong result for multi-token builtin types
like long long:

-long long *ll = new long long();
+auto long *ll = new long long();

Reviewers: alexfh, hokein, rsmith, Prazek, aaron.ballman

Subscribers: cfe-commits

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

llvm-svn: 284885
2016-10-21 21:13:56 +00:00
Aleksei Sidorin a693b37e14 [ASTImporter] Implement some expression-related AST node import (part 2)
* Some code cleanup
* Add tests not present in http://reviews.llvm.org/D14286
* Integrate a test suite from Serge Pavlov (http://reviews.llvm.org/D14224)
* ArrayTypeTraitExpr: serialize sub-expression to avoid keeping it undefined
* Implement import of some nodes:
  - ArrayTypeTraitExpr
  - ExpressionTraitExpr
  - OpaqueValueExpr
  - ArraySubscriptExpr
  - ExplicitCastExpr
  - ImplicitValueInitExpr
  - OffsetOfExpr
  - CXXThisExpr
  - CXXThrowExpr
  - CXXNoexceptExpr
  - CXXDefaultArgExpr
  - CXXScalarValueInitExpr
  - CXXBindTemporaryExpr
  - CXXTemporaryObjectExpr
  - MaterializeTemporaryExpr
  - ExprWithCleanups

  - StaticAssertDecl
  - FriendDecl

  - DecayedType

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

llvm-svn: 282572
2016-09-28 10:16:56 +00:00
Mehdi Amini 9670f847b8 [NFC] Header cleanup
Summary: Removed unused headers, replaced some headers with forward class declarations

Patch by: Eugene <claprix@yandex.ru>

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

llvm-svn: 275882
2016-07-18 19:02:11 +00:00
Vassil Vassilev 7baef47065 Recommit r274348 and r274349. The Windows failures should be fixed.
Original commit message:
"Add postorder traversal support to the RecursiveASTVisitor.

This feature needs to be explicitly enabled by overriding shouldTraversePostOrder()
as it has performance drawbacks for the iterative Stmt-traversal.

Patch by Raphael Isemann!

Reviewed by Richard Smith and Benjamin Kramer."

llvm-svn: 274830
2016-07-08 08:33:56 +00:00
Vassil Vassilev ccfadeb20f Revert r274348 and r274349 until the Windows failures are fixed.
llvm-svn: 274359
2016-07-01 16:07:57 +00:00
Vassil Vassilev 5acb3f2352 Add forgotten test to r274348.
llvm-svn: 274349
2016-07-01 13:30:08 +00:00
Vassil Vassilev 29abe10af9 Add postorder traversal support to the RecursiveASTVisitor.
This feature needs to be explicitly enabled by overriding shouldTraversePostOrder()
as it has performance drawbacks for the iterative Stmt-traversal.

Patch by Raphael Isemann!

Reviewed by Richard Smith and Benjamin Kramer.

llvm-svn: 274348
2016-07-01 13:28:31 +00:00
Benjamin Kramer cf236ec299 Prune away some unused using decls. NFC.
Found by clang's misc-unused-using-decls.

llvm-svn: 272156
2016-06-08 15:34:36 +00:00
Piotr Padlewski cfed2bf588 [ASTMatchers] Breaking change of `has` matcher
has matcher can now match to implicit and paren casts

http://reviews.llvm.org/D20801

llvm-svn: 271288
2016-05-31 15:25:05 +00:00
Artem Dergachev 4e7c6fdeeb [ASTImporter] Implement some expression-related AST node import.
Introduce ASTImporter unit test framework.

Fix a memory leak introduced in cf8ccff5: an array is allocated
in ImportArray and never freed.

Support new node kinds:

- GCCAsmStmt

- AddrLabelExpr
- AtomicExpr
- CompoundLiteralExpr
- CXXBoolLiteralExpr
- CXXNullPtrLiteralExpr
- CXXThisExpr
- DesignatedInitExpr
- GNUNullExpr
- ImplicitValueInitExpr
- InitListExpr
- OpaqueValueExpr
- PredefinedExpr
- ParenListExpr
- StmtExpr
- VAArgExpr

- BinaryConditionalOperator
- ConditionalOperator

- FloatingLiteral
- StringLiteral

- InjectedClassNameType
- TemplateTypeParmType

- LabelDecl

Patch by Aleksei Sidorin!

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

llvm-svn: 266292
2016-04-14 11:51:27 +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
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
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 580ccaf827 Properly track the end location of an exception specification.
Patch by Adrian Zgorzałek

llvm-svn: 257521
2016-01-12 21:04:22 +00:00
Richard Trieu 031406fab0 Add a test for r255875 & r255929, comparisons on DynTypeNode wrapped QualType.
llvm-svn: 255937
2015-12-17 23:20:57 +00:00
Alexander Kornienko 4f35532dbe Adjust printQualifiedName to handle unscoped enums in a way similar to anonymous namespaces.
Patch by Sterling Augustine!

Differential revision: http://reviews.llvm.org/D14459

llvm-svn: 252488
2015-11-09 16:45:17 +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
Benjamin Kramer e8c51fdbd6 Revert "[AST] Put TypeLocs and NestedNameSpecifierLocs into the ParentMap."
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
2015-10-21 10:07:26 +00:00
Benjamin Kramer 36307ffa1b [AST] Put TypeLocs and NestedNameSpecifierLocs into the ParentMap.
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
2015-10-20 15:08:46 +00:00
Angel Garcia Gomez 637d1e6694 Roll-back r250822.
Summary: It breaks the build for the ASTMatchers

Subscribers: klimek, cfe-commits

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

llvm-svn: 250827
2015-10-20 13:23:58 +00:00
Angel Garcia Gomez b5250d3448 Apply modernize-use-default to clang.
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
2015-10-20 12:52:55 +00:00
Aaron Ballman 512fb64765 Rename AST node matchers to match the AST node names directly. Part of this 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
2015-09-17 13:30:52 +00:00
Alexander Kornienko ab9db51042 Revert r240270 ("Fixed/added namespace ending comments using clang-tidy").
llvm-svn: 240353
2015-06-22 23:07:51 +00:00
Alexander Kornienko 3d9d929e42 Fixed/added namespace ending comments using clang-tidy. NFC
The patch is generated using this command:

  $ tools/extra/clang-tidy/tool/run-clang-tidy.py -fix \
      -checks=-*,llvm-namespace-comment -header-filter='llvm/.*|clang/.*' \
      work/llvm/tools/clang

To reduce churn, not touching namespaces spanning less than 10 lines.

llvm-svn: 240270
2015-06-22 09:47:44 +00:00
David Majnemer 8423df927e Move a test from static-assert.cpp to DeclPrinterTest
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
2015-06-05 22:40:53 +00:00
Yunzhong Gao eba323ab44 Fix a few line endings. NFC.
llvm-svn: 236301
2015-05-01 02:04:32 +00:00
Alexander Kornienko 34eb20725d Use 'override/final' instead of 'virtual' for overridden methods
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
2015-04-11 02:00:23 +00:00
Aaron Ballman f4cb2be05a Track the source location of the dot or arrow operator in a MemberExpr.
Patch by Joe Ranieri!

llvm-svn: 233085
2015-03-24 15:07:53 +00:00
Eli Bendersky 5f4d76efd3 Record correct source range for defaulted/deleted members.
Fixes https://llvm.org/bugs/show_bug.cgi?id=20744

struct A {

A() = default;
};

Previously the source range of the declaration of A ended at the ')'. It should
include the '= default' part as well. The same for '= delete'.

Note: this will break one of the clang-tidy fixers, which is going to be
addessed in a follow-up patch.

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

llvm-svn: 233028
2015-03-23 21:43:28 +00:00
Adrian Prantl cbc368c5b5 Revert "Wrap clang module files in a Mach-O, ELF, or COFF container."
llvm-svn: 230454
2015-02-25 02:44:04 +00:00
Adrian Prantl 8bf7af3de8 Wrap clang module files in a Mach-O, ELF, or COFF container.
This is a necessary prerequisite for debugging with modules.
The .pcm files become containers that hold the serialized AST which allows
us to store debug information in the module file that can be shared by all
object files that were built importing the module.

This reapplies r230044 with a fixed configure+make build and updated
dependencies and testcase requirements. Over the last iteration this
version adds
- missing target requirements for testcases that specify an x86 triple,
- a missing clangCodeGen.a dependency to libClang.a in the make build.

rdar://problem/19104245

llvm-svn: 230423
2015-02-25 01:31:45 +00:00
Adrian Prantl a39924a1f8 Revert "Wrap clang module files in a Mach-O, ELF, or COFF container."
This reverts commit r230305.
Off to fix another round of missing dependencies on various platforms.

llvm-svn: 230309
2015-02-24 05:14:17 +00:00
Adrian Prantl fc360dc30b Wrap clang module files in a Mach-O, ELF, or COFF container.
This is a necessary prerequisite for debugging with modules.
The .pcm files become containers that hold the serialized AST which allows
us to store debug information in the module file that can be shared by all
object files that were built importing the module.

rdar://problem/19104245

This reapplies r230044 with a fixed configure+make build and updated
dependencies. Take 3.

llvm-svn: 230305
2015-02-24 04:25:59 +00:00
Adrian Prantl 67fbfa3773 Revert "Wrap clang module files in a Mach-O, ELF, or COFF container."
This reverts commit 230099.

The Linux configure+make build variant still needs some work.

llvm-svn: 230103
2015-02-21 00:29:14 +00:00
Adrian Prantl f2b0cd91eb Wrap clang module files in a Mach-O, ELF, or COFF container.
This is a necessary prerequisite for debugging with modules.
The .pcm files become containers that hold the serialized AST which allows
us to store debug information in the module file that can be shared by all
object files that were built importing the module.

rdar://problem/19104245

This reapplies r230044 with a fixed configure+make build and updated
dependencies. Take 2.

llvm-svn: 230089
2015-02-20 23:34:26 +00:00
Adrian Prantl 690b2f7746 Revert "Wrap clang module files in a Mach-O, ELF, or COFF container."
This reverts commit r230067.

Investigating another batch of problems found by the bots.

llvm-svn: 230073
2015-02-20 22:12:19 +00:00
Adrian Prantl b59bc1a528 Wrap clang module files in a Mach-O, ELF, or COFF container.
This is a necessary prerequisite for debugging with modules.
The .pcm files become containers that hold the serialized AST which allows
us to store debug information in the module file that can be shared by all
object files that were built importing the module.

rdar://problem/19104245

This reapplies r230044 with a fixed configure+make build and updated
dependencies.

llvm-svn: 230067
2015-02-20 21:53:12 +00:00
Chandler Carruth 575bc3ba62 [cleanup] Re-sort the #include lines using llvm/utils/sort_includes.py
No functionality changed, this is a purely mechanical cleanup to ensure
the #include order remains consistent across the project.

llvm-svn: 225975
2015-01-14 11:23:58 +00:00
Samuel Benzaquen a117002d93 Fix bug in DynTypedMatcher::constructVariadic() that would cause false negatives.
Summary:
DynTypedMatcher::constructVariadic() where the restrict kind of the
different matchers are not related causes the matcher to have a "None"
restrict kind. This causes false negatives for anyOf and eachOf.
Change the logic to get a common ancestor if there is one.
Also added regression tests that fail without the fix.

Reviewers: klimek

Subscribers: klimek, cfe-commits

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

llvm-svn: 219118
2014-10-06 13:14:30 +00:00
David Blaikie 50a5f97e82 unique_ptrify SourceManager::createFileID
llvm-svn: 216715
2014-08-29 07:59:55 +00:00