Commit Graph

250 Commits

Author SHA1 Message Date
Richard Smith 57443fce3f When forming a fully-qualified type name, put any qualifiers outside/before the
nested-name-specifier. Patch by Sterling Augustine!

llvm-svn: 268988
2016-05-09 23:06:14 +00:00
Chaoren Lin e6f04f3553 [Tooling] Fix getting fully qualified names of template alias types.
Reviewers: rsmith, rnk

Subscribers: cfe-commits, klimek

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

llvm-svn: 266925
2016-04-20 22:12:07 +00:00
Eric Liu 4c1ef97adb Added formatAndApplyAllReplacements that works on multiple files in libTooling.
Summary:
formatAndApplyAllReplacements takes a set of Replacements, applies them on a
Rewriter, and reformats the changed code.

Reviewers: klimek, djasper

Subscribers: ioeric, klimek, cfe-commits

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

llvm-svn: 264745
2016-03-29 16:31:53 +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
Manuel Klimek b12e5a5ccd Add functions to apply replacements and reformat them.
This is a commonly useful feature to have, and we have implemented it
multiple times with different kinds of bugs. This implementation
centralizes the idea in a set of functions that we can then use from the various
tools.

Reverts r262234, which is a revert of r262232, and puts the functions
into FOrmat.h, as they are closely coupled to clang-format, and we
otherwise introduce a cyclic dependency between libFormat and
libTooling.

Patch by Eric Liu.

llvm-svn: 262323
2016-03-01 12:37:30 +00:00
Manuel Klimek 06d5af4c9d Revert "Implement new interfaces for code-formatting when applying replacements."
This reverts commit r262232.

llvm-svn: 262234
2016-02-29 16:44:16 +00:00
Manuel Klimek 4823631af4 Implement new interfaces for code-formatting when applying replacements.
Patch by Eric Liu.

llvm-svn: 262232
2016-02-29 16:27:41 +00:00
Reid Kleckner 94f127e84a Stop using "template" when printing qualtype names
Summary:
The keyword "template" isn't necessary when
printing a fully-qualified qualtype name, and, in fact,
results in a syntax error if one tries to use it. So stop
printing it.

Reviewers: rsmith, rnk

Subscribers: rnk, klimek, cfe-commits

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

llvm-svn: 261005
2016-02-16 20:34:27 +00:00
Richard Smith 0dd191a5c4 Add Tooling functionality to get a name for a QualType that can be used to name
that type from the global scope.

Patch by Sterling Augustine, derived (with permission) from code from Cling by
Vassil Vassilev and Philippe Canal.

llvm-svn: 260278
2016-02-09 21:04:04 +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
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 5fe4122348 Replace some tabs with spaces.
llvm-svn: 258500
2016-01-22 14:12:44 +00:00
Daniel Jasper 3fed94525c Fix calculation of shifted cursor/code positions. Specifically support
the case where a specific range is replaced by new text. Previously,
the calculation would shift any position from within a replaced region
to the first character after the region. This is undersirable, e.g. for
clang-format's include sorting.

llvm-svn: 253859
2015-11-23 08:33:48 +00:00
Alexander Kornienko 857b10f471 Make ArgumentAdjuster aware of the current file being processed.
Summary:
This is needed to handle per-project configurations when adding extra
arguments in clang-tidy for example.

Reviewers: klimek, djasper

Subscribers: djasper, cfe-commits, klimek

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

llvm-svn: 252134
2015-11-05 02:19:53 +00:00
Benjamin Kramer 9bccaa158a [Tooling] Add a utility function to replace one nested name with another.
One problem in clang-tidy and other clang tools face is that there is no
way to lookup an arbitrary name in the AST, that's buried deep inside Sema
and might not even be what the user wants as the new name may be freshly
inserted and not available in the AST.

A common use case for lookups is replacing one nested name with another
while minimizing namespace qualifications, so replacing 'ns::foo' with
'ns::bar' will use just 'bar' if we happen to be inside the namespace 'ns'.
This adds a little helper utility for exactly that use case.

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

llvm-svn: 251022
2015-10-22 15:04:10 +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
Benjamin Kramer b993613800 Revert accidental commit. This isn't ready yet.
llvm-svn: 250804
2015-10-20 07:53:14 +00:00
Benjamin Kramer 1b7dd8d7e3 Put back dead code that's used out-of-tree.
Partially reverts r250418.

llvm-svn: 250803
2015-10-20 07:50:21 +00:00
Benjamin Kramer c4cb3b10dc [VFS] Port tooling to use the in-memory file system.
This means file remappings can now be managed by ClangTool (or a
ToolInvocation user) instead of by ToolInvocation itself. The
ToolInvocation remapping is still in place so users can migrate.

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

llvm-svn: 249815
2015-10-09 09:54:37 +00:00
NAKAMURA Takumi fe2e64249b ToolingTests: Tweak getAnyTarget() to match "x86_64".
Both "x86" and "x86-64" are incompatible to triple's arch.

llvm-svn: 249403
2015-10-06 13:58:13 +00:00
Manuel Klimek 9b30e2b50b Adds a way for tools to deduce the target config from a compiler name.
Adds `addTargetAndModeForProgramName`, a utility function that will add
appropriate `-target foo` and `--driver-mode=g++` tokens to a command
line for driver invocations of the form `a/b/foo-g++`. It is intended to
support tooling: for example, should a compilation database record some
invocation of `foo-g++` without these implicit flags, a Clang tool may
use this function to add them back.

Patch by Luke Zarko.

llvm-svn: 249391
2015-10-06 10:45:03 +00:00
Benjamin Kramer a25dcfd906 [VFS] Add an in-memory file system implementation.
This is a simple file system tree of memory buffers that can be filled by a
client. In conjunction with an OverlayFS it can be used to make virtual
files accessible right next to physical files. This can be used as a
replacement for the virtual file handling in FileManager and which I intend
to remove eventually.

llvm-svn: 249315
2015-10-05 13:55:14 +00:00
Daniel Jasper d89ae9d3ac clang-format: Add initial #include sorting capabilities.
To implement this nicely, add a function that merges two sets of
replacements that are meant to be done in sequence. This functionality
will also be useful for other applications, e.g. formatting the result
of clang-tidy fixes.

llvm-svn: 248367
2015-09-23 08:30:47 +00:00
Argyrios Kyrtzidis 64f67be319 [tooling] Provide the compile commands of the JSON database in the order that they were provided in the JSON file.
This is useful for debugging of issues and reduction of test cases.
For example, an issue may show up due to the order that some commands were processed.
It is convenient to be able to remove commands from the file and still preserve the order
that they are returned, instead of getting a completely different order when removing a few commands.

llvm-svn: 248292
2015-09-22 17:22:33 +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
Argyrios Kyrtzidis 6d0a767685 [tooling] Add unit tests for change in r247468.
llvm-svn: 247832
2015-09-16 18:28:42 +00:00
Manuel Klimek 3ecd8c0aab Fix performance regression when running clang tools.
Brings tool start time for a large synthetic test case down from (on my
machine) 4 seconds to 0.5 seconds.

llvm-svn: 247018
2015-09-08 15:14:06 +00:00
Manuel Klimek 54042e743c Add structed way to express command line options in the compilation database.
Currently, arguments are passed via the string attribute 'command',
assuming a shell-escaped / quoted command line to extract the original
arguments. This works well enough on Unix systems, but turns out to be
problematic for Windows tools to generate.

This CL adds a new attribute 'arguments', an array of strings, which
specifies the exact command line arguments. If 'arguments' is available
in the compilation database, it is preferred to 'commands'.

Currently there is no plan to retire 'commands': there are enough
different use cases where users want to create their own mechanism for
creating compilation databases, that it doesn't make sense to force them
all to implement shell command line parsing.

Patch by Daniel Dilts.

llvm-svn: 245036
2015-08-14 09:55:36 +00:00
David Blaikie e438127b91 Wdeprecated: CommentVerifiers are returned by value, make sure they're correctly copy/moveable
llvm-svn: 244958
2015-08-13 21:24:08 +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
Daniel Jasper 34688f2f7e Avoid using set::emplace as it is apparently not supported by gcc 4.7.
llvm-svn: 239816
2015-06-16 13:15:54 +00:00
Daniel Jasper 0f29127636 Tooling: When applying a set of replacements, do deletions before
insertions. It is unlikely to be the intention to delete parts of newly
inserted code. To do so, changed sorting Replacements at the same offset
to have decreasing length.

llvm-svn: 239809
2015-06-16 10:22:10 +00:00
Manuel Klimek 94a89231f6 Allow replacements created from token ranges to specify language options.
The default language options will lead to incorrect replacements in C++
code, for example when trying to replace nested name specifiers ending
in "::".

llvm-svn: 238922
2015-06-03 13:10:41 +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
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
Alexander Kornienko 74e1c46a50 Make ArgumentsAdjuster an std::function.
Reviewers: klimek

Reviewed By: klimek

Subscribers: klimek, cfe-commits

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

llvm-svn: 223248
2014-12-03 17:53:02 +00:00
David Blaikie 13156b689e Standardize on StringMap::insert, removing uses of StringMap::GetOrCreateValue.
llvm-svn: 222306
2014-11-19 03:06:06 +00:00
NAKAMURA Takumi dc872ed908 [CMake] Add dependencies on clangToolingCore.
llvm-svn: 220890
2014-10-30 00:44:01 +00:00
Daniel Jasper cb3e6188bc Refactor libTooling to reduce required dependencies.
This moves classes for storing and applying replacements to separate
files. These classes specifically are used by clang-format which doesn't
have any other dependencies on clangAST. Thereby, the size of
clang-format's binary can be cut roughly in half and its build time sped
up.

llvm-svn: 220867
2014-10-29 18:55:09 +00:00
Benjamin Kramer a885796d5f Make VFS and FileManager match the current MemoryBuffer API.
This eliminates converting back and forth between the 3 formats and
gives us a more homogeneous interface.

llvm-svn: 220657
2014-10-26 22:44:13 +00:00
Olivier Goffart df6d7b1564 Fix initializing TypeOfTypeLoc
This fixes a crash in the RecursiveASTVisitor on such code
 __typeof__(struct F*) var[invalid];

The UnderlyingTInfo of a TypeOfTypeLoc was left uninitialized when
created from ASTContext::getTrivialTypeSourceInfo
This lead to a crash in RecursiveASTVisitor when trying to access it.

llvm-svn: 220562
2014-10-24 13:52:55 +00:00
Manuel Klimek 20c1c890b3 Separated RecursiveASTVisitorTest into multiple files.
Patch by Marek Kurdej.

llvm-svn: 219410
2014-10-09 15:02:06 +00:00
Fariborz Jahanian 5afc869f96 Adds 'override' to overriding methods. NFC.
These were uncoveredby my yet undelivered patch.

llvm-svn: 218774
2014-10-01 16:56:40 +00:00
Benjamin Kramer efffbee024 Tooling: Ignore file names in tooling::deduplicate.
This was horribly broken due to how the sort predicate works. We would
report a conflict for files with a replacement in the same position but
different names if the length differed. Just ignore paths as this is often
what the user wants. Files can occur with different names (due to symlinks
or relative paths) and we don't ever want to do the same edit in one file
twice.

llvm-svn: 217439
2014-09-09 13:53:29 +00:00
David Blaikie 49cc3181a2 Overload SourceManager::overrideFileContents so that unconditionally passing ownership is explicitly done using unique_ptr.
Only those callers who are dynamically passing ownership should need the
3 argument form. Those accepting the default ("do pass ownership")
should do so explicitly with a unique_ptr now.

llvm-svn: 216614
2014-08-27 20:54:45 +00:00
Rafael Espindola d87f8d76e0 Update for LLVM api change.
llvm-svn: 216585
2014-08-27 20:03:29 +00:00
Benjamin Kramer 2f5db8b3db Header guard canonicalization, clang part.
Modifications made by clang-tidy with minor tweaks.

llvm-svn: 215557
2014-08-13 16:25:19 +00:00
David Blaikie 6beb6aa8f0 Recommit 213307: unique_ptr-ify ownership of ASTConsumers (reverted in r213325)
After post-commit review and community discussion, this seems like a
reasonable direction to continue, making ownership semantics explicit in
the source using the type system.

llvm-svn: 215323
2014-08-10 19:56:51 +00:00
David Blaikie 62a56f39b7 Revert "unique_ptr-ify ownership of ASTConsumers"
This reverts commit r213307.

Reverting to have some on-list discussion/confirmation about the ongoing
direction of smart pointer usage in the LLVM project.

llvm-svn: 213325
2014-07-17 22:34:12 +00:00
David Blaikie a51666a4d6 unique_ptr-ify ownership of ASTConsumers
(after fixing a bug in MultiplexConsumer I noticed the ownership of the
nested consumers was implemented with raw pointers - so this fixes
that... and follows the source back to its origin pushing unique_ptr
ownership up through there too)

llvm-svn: 213307
2014-07-17 20:40:36 +00:00
Alp Toker 0621cb2e7d Make clang's rewrite engine a core feature
The rewrite facility's footprint is small so it's not worth going to these
lengths to support disabling at configure time, particularly since key compiler
features now depend on it.

Meanwhile the Objective-C rewriters have been moved under the
ENABLE_CLANG_ARCMT umbrella for now as they're comparatively heavy and still
potentially worth excluding from lightweight builds.

Tests are now passing with any combination of feature flags. The flags
historically haven't been tested by LLVM's build servers so caveat emptor.

llvm-svn: 213171
2014-07-16 16:48:33 +00:00
Alp Toker f994cef836 Track IntrusiveRefCntPtr::get() changes from LLVM r212366
llvm-svn: 212369
2014-07-05 03:08:06 +00:00
David Blaikie 66cc07b4f7 Remove 'const' from MemoryBuffers used through the SourceManager
This removes a const_cast added in r211884 that occurred due to an
inconsistency in how MemoryBuffers are handled between some parts of
clang and LLVM.

MemoryBuffers are immutable and the general convention in the LLVM
project is to omit const from immutable types as it's simply
redundant/verbose (see llvm::Type, for example). While this change
doesn't remove "const" from /every/ MemoryBuffer, it at least makes this
chain of ownership/usage consistent.

llvm-svn: 211915
2014-06-27 17:40:03 +00:00
Alp Toker 0843bff137 Make test from r211758 portable
It turns out the -fblocks option is determined by the default tooling target
and not implied by the other two flags.

llvm-svn: 211761
2014-06-26 02:07:06 +00:00
Alp Toker e3ad531afb RAV: visit copy expressions of captured variables in blocks (ObjC++11)
Patch by Mathieu Baudet.

llvm-svn: 211758
2014-06-26 01:42:24 +00:00
Rafael Espindola c080917ec2 Replace llvm::error_code with std::error_code.
llvm-svn: 210780
2014-06-12 14:02:15 +00:00
Craig Topper 416fa34b87 [C++11] Use 'nullptr'. Unittests edition.
llvm-svn: 210423
2014-06-08 08:38:12 +00:00
Alp Toker 62438dab83 Fix RecursiveASTVisitor to visit types in ObjCPropertyDecl
Patch by Mathieu Baudet!

llvm-svn: 210339
2014-06-06 15:05:09 +00:00
Alp Toker 1d257e1d0a Remove the last remaining llvm/Config/config.h includes
This corrects long-standing misuses of LLVM's internal config.h.

In most cases the public llvm-config.h header was intended and we can now
remove the old hacks thanks to LLVM r210144.

The config.h header is private, won't be installed and should no longer be
included by clang or other modules.

llvm-svn: 210145
2014-06-04 03:28:55 +00:00
Richard Smith 1be902c02f [modules] Fix ODR violation: there's another clang::TypeLocVisitor elsewhere.
llvm-svn: 209169
2014-05-19 22:34:38 +00:00
David Blaikie 103a2de0b4 Push unique_ptr ownership of ASTUnits further back into their factories.
llvm-svn: 207237
2014-04-25 17:01:33 +00:00
David Blaikie 39808ff901 Improve ownership of ASTUnits in libTooling by using std::unique_ptr.
llvm-svn: 207229
2014-04-25 14:49:37 +00:00
Kostya Serebryany d0f841ce4a fix a test-only leak found by lsan, PR19521
llvm-svn: 207223
2014-04-25 12:58:42 +00:00
Nico Weber dbd07fadae Fix two leaks found by LSan (one is test-only).
The result of llvm::MemoryBuffer::getMemBuffer() needs to be freed. Don't
pass "don't free" flag to overrideFileContents() to fix.

llvm-svn: 207075
2014-04-24 04:58:41 +00:00
Nico Weber 4fcf0c7b29 Fix two test-only leaks found by LSan.
The result of getBufferForFile() must be freed.
(Should we change functions that expect the caller to assume ownership so
that they return unique_ptrs instead? Then the type system makes sure we get
this right.)

llvm-svn: 207074
2014-04-24 04:26:18 +00:00
Nico Weber 52fbbb16a1 Fix four more test-only leaks found by LSan.
Tool::run() doesn't take ownership of the passed action.

llvm-svn: 207071
2014-04-24 03:48:09 +00:00
Hans Wennborg 501eadb429 Check for LLVM_ON_WIN32 instead of _WIN32.
This is a follow-up to r203624 to address Anton's comment.

llvm-svn: 203668
2014-03-12 16:07:46 +00:00
Ahmed Charles b89843299a Replace OwningPtr with std::unique_ptr.
This compiles cleanly with lldb/lld/clang-tools-extra/llvm.

llvm-svn: 203279
2014-03-07 20:03:18 +00:00
Ahmed Charles d72a5f103d Replace OwningPtr::isValid() with conversion to bool.
This is a precursor to moving to std::unique_ptr.

llvm-svn: 203277
2014-03-07 19:51:06 +00:00
Peter Collingbourne f93725459a MSVC 2012 doesn't support std::initializer_list at all, so don't rely on
that std::vector constructor.

llvm-svn: 202684
2014-03-03 08:13:06 +00:00
Peter Collingbourne 2bbb029599 MSVC cannot understand temporaries formed from initializer lists.
llvm-svn: 202682
2014-03-03 07:49:35 +00:00
Peter Collingbourne c0423b349b Disable all dependency output options when using the Tooling library.
It isn't appropriate for a tool to be stomping over the dependency files,
especially if the actual build uses a compiler other than Clang or the tool
cannot find all the headers for some reason (which would cause the existing
dependency file to be deleted).

If a tool actually needs to care about dependency files we can think about
adding a mechanism for getting to this information.

Differential Revision: http://llvm-reviews.chandlerc.com/D2912

llvm-svn: 202669
2014-03-02 23:37:26 +00:00
Craig Topper a798a9db93 Switch all uses of LLVM_OVERRIDE to just use 'override' directly.
llvm-svn: 202625
2014-03-02 09:32:10 +00:00
Saleem Abdulrasool 8a8454bc31 unittests: explicit stringify StringRefs for conversion
When clang is built outside of the LLVM tree (against a corresponding version),
there is no definition providing for operator<<(std::ostream &, StringRef) which
is required for the assertion routines in google-test tests.  Avoid the
compilation failure by explicitly stringifying the StringRef prior to use.

llvm-svn: 200096
2014-01-25 20:04:44 +00:00
Chandler Carruth 5553d0d4ca Sort all the #include lines with LLVM's utils/sort_includes.py which
encodes the canonical rules for LLVM's style. I noticed this had drifted
quite a bit when cleaning up LLVM, so wanted to clean up Clang as well.

llvm-svn: 198686
2014-01-07 11:51:46 +00:00
Alp Toker 59226f7811 Revert "ToolingTest.cpp: Fix r158592, runToolOnCode.FindsNoTopLevelDeclOnEmptyCode on msvc. LangOpts.MicrosoftExt still appends "class type_info;"."
type_info has been made an implicitly predeclared type in r198497 and will no
longer appear as a user-declared type so we can remove this old hack.

This reverts commit r158595.

llvm-svn: 198502
2014-01-04 15:58:28 +00:00
DeLesley Hutchins c4a82438a7 Update RecursiveASTVisitor so that it visits attributes. This is currently
important for thread safety attributes, which contain expressions that were
not being visited, and were thus invisible to various tools.  There are now
Visit*Attr methods that can be overridden for every attribute.

llvm-svn: 198224
2013-12-30 17:24:36 +00:00
NAKAMURA Takumi ac85179219 [CMake] Update target_link_libraries() and LLVM_LINK_COMPONENTS for each CMakeLists.txt.
llvm-svn: 196916
2013-12-10 12:40:37 +00:00
Edwin Vane eb56f4fe2f Relax some preconditions for using FixedCompilationDatabase.
FixedCompilationDatabase (FCD) requires that the arguments it consumes after
'--' must not include positional parameters or the argv[0] of the tool. This
patch relaxes those restrictions.

llvm-svn: 194968
2013-11-17 16:08:04 +00:00
NAKAMURA Takumi d3b07c6569 unittests/Tooling/ToolingTest.cpp: Suppress new tests on win32, due to handling of virtual file, such "/a.cc".
llvm-svn: 194534
2013-11-13 00:18:50 +00:00
Manuel Klimek 31cd3fc088 Add test for injecting diagnostic consumers into a ClangTool.
As suggested by pcc on 194226.

llvm-svn: 194494
2013-11-12 17:53:18 +00:00
Manuel Klimek 6408301421 Adds the ability to inject a DiagnosticConsumer into ClangTools.
llvm-svn: 194226
2013-11-07 23:18:05 +00:00
Peter Collingbourne 671a1e4b37 Disable a tooling test on Windows.
llvm-svn: 194178
2013-11-06 23:02:51 +00:00
Peter Collingbourne c689ee76d4 Introduce ClangTool::buildASTs, and buildASTFromCode.
These allow clients to retrieve persistent AST objects (ASTUnits) which
can be used in an ad-hoc manner after parsing.

To accommodate this change, the code for processing a CompilerInvocation
using a FrontendAction has been factored out to FrontendActionFactory, and
a new base class, ToolAction, has been introduced, allowing the tool to do
arbitrary things with each CompilerInvocation.  This change was necessary
because ASTUnit does not use the FrontendAction interface directly.

This change also causes the FileManager in ClangTool to use shared ownership.
This will become necessary because ASTUnit takes shared ownership of
FileManager (ClangTool's FileManager is currently unused by ASTUnit; this
is a FIXME).  As shown in the tests, any client of ToolInvocation will
need to be modified to use shared ownership for FileManager.

Differential Revision: http://llvm-reviews.chandlerc.com/D2097

llvm-svn: 194164
2013-11-06 20:12:45 +00:00
Manuel Klimek 1f76c4e810 Use the same SourceManager for ModuleMaps and compilations.
This allows using virtual file mappings on the original SourceManager to
map in virtual module.map files. Without this patch, the ModuleMap
search will find a module.map file (as the FileEntry exists in the
FileManager), but will be unable to get the content from the
SourceManager (as ModuleMap previously created its own SourceManager).

Two problems needed to be fixed which this patch exposed:

1. Storing the inferred module map
When writing out a module, the ASTWriter stores the names of the files
in the main source manager; when loading the AST again, the ASTReader
errs out if such a file is found missing, unless it is overridden.
Previously CompilerInstance's compileModule method would store the
inferred module map to a temporary file; the problem with this approach
is that now that the module map is handled by the main source manager,
the ASTWriter stores the name of the temporary module map as source to
the compilation; later, when the module is loaded, the temporary file
has already been deleted, which leads to a compilation error. This patch
changes the inferred module map to instead inject a virtual file into
the source manager. This both saves some disk IO, and works with how the
ASTWriter/ASTReader handle overridden source files.

2. Changing test input in test/Modules/Inputs/*
Now that the module map file is handled by the main source manager, the
VerifyDiagnosticConsumer will not ignore diagnostics created while
parsing the module map file. The module test test/Modules/renamed.m uses
-I test/Modules/Inputs and triggers recursive loading of all module maps
in test/Modules/Inputs, some of which had conflicting names, thus
leading errors while parsing the module maps. Those diagnostics already
occur on trunk, but before this patch they would not break the test, as
they were ignored by the VerifyDiagnosticConsumer. This patch thus
changes the module maps that have been recently introduced which broke
the invariant of compatible modules maps in test/Modules/Inputs.

llvm-svn: 193314
2013-10-24 07:51:24 +00:00
Ariel J. Bernal 3255134ac5 Reverted r192992 broke windows and freebsd builds.
llvm-svn: 192997
2013-10-18 19:48:31 +00:00
Ariel J. Bernal 4dc53c20fc This patch fixes replacements that are not applied when relative paths are
specified.

In particular it makes sure that  relative paths for non-virtual files aren't
made absolute.
Added unittest.

llvm-svn: 192992
2013-10-18 18:38:24 +00:00
Ariel J. Bernal e7288fe233 Revert commit r192299 until find a way to account for simlinks in OS X.
llvm-svn: 192313
2013-10-09 18:27:27 +00:00
Ariel J. Bernal ee863cedc2 This patch fixes replacements that are not applied when relative paths are
specified.

In particular it makes sure that relative paths for non-virtual files aren't
made absolute.
Added unittest test.

llvm-svn: 192299
2013-10-09 16:09:23 +00:00
Michael Han 6ca01b4b6c Add a test case to test RAV visits parameters of implicit copy constructor.
llvm-svn: 190632
2013-09-12 20:59:33 +00:00
Michael Han c90d12d1df Teach RAV to visit parameter variable declarations of implicit functions. Fixes PR16182.
Normally RAV visits parameter variable declarations of a function by traversing the TypeLoc of
the parameter declarations. However, for implicit functions, their parameters don't have any
TypeLoc, because they are implicit.

So for implicit functions, we visit their parameter variable declarations by traversing them through
the function declaration, and visit them accordingly.

Reviewed by Richard Smith and Manuel Klimek.

llvm-svn: 190528
2013-09-11 15:53:29 +00:00