Commit Graph

62 Commits

Author SHA1 Message Date
Arnaud A. de Grandmaison 3128a11ee8 Fix spurious output in JSONCompilationDatabase
llvm-svn: 172321
2013-01-12 18:37:52 +00:00
Edwin Vane 5038ac0fb8 Allow RefactoringTool to write to memory instead of always to disk
RefactoringTool::run() always writes the result of rewrites to disk.
Instead, make this optional and provide a method for getting the
refactoring results in a memory buffer instead.

Also made ClangTool polymorphic so RefactoringTool could inherit from it
to properly express the IS-A relationship. This change also provides
access to ClangTool's public interface, e.g. mapVirtualFile() which is
important once refactored buffers start living in memory instead of on
disk.

Reviewers: klimek
llvm-svn: 172219
2013-01-11 17:04:55 +00:00
Edwin Vane 524741fbbd Style and Doc fix for CommonOptionsParser
- Renaming GetCompilations() and GetSourcePathList() to follow LLVM
  style.
- Updating docs to reflect name change.
- Also updating help text to not mention clang-check since this class
  can be used by any tool.

Reviewed By: Alexander Kornienko

llvm-svn: 170229
2012-12-14 18:58:25 +00:00
Chandler Carruth 3a02247dc9 Sort all of Clang's files under 'lib', and fix up the broken headers
uncovered.

This required manually correcting all of the incorrect main-module
headers I could find, and running the new llvm/utils/sort_includes.py
script over the files.

I also manually added quite a few missing headers that were uncovered by
shuffling the order or moving headers up to be main-module-headers.

llvm-svn: 169237
2012-12-04 09:13:33 +00:00
Argyrios Kyrtzidis 251ad5e06b Introduce CompilationDatabase::getAllCompileCommands() that returns all
compile commands of the database and expose it via the libclang API.

llvm-svn: 169226
2012-12-04 07:26:44 +00:00
Rafael Espindola b0448cd52a Remove some dead code. CLANG_IS_PRODUCTION is now just a build flag and
is not used in any #ifdef.

llvm-svn: 168703
2012-11-27 16:10:37 +00:00
Douglas Gregor 811db4eac4 Make DiagnosticOptions intrusively reference-counted, and make sure
the various stakeholders bump up the reference count. In particular,
the diagnostics engine now keeps the DiagnosticOptions object alive.

llvm-svn: 166508
2012-10-23 22:26:28 +00:00
Daniel Jasper 74351ff4ac Only report first error when no compilation database is found.
Review: http://llvm-reviews.chandlerc.com/D62
llvm-svn: 165933
2012-10-15 13:12:24 +00:00
Daniel Jasper 8c059026c0 Hopefully appease Windows buildbot with Japanese (?) error message.
llvm-svn: 165414
2012-10-08 18:37:21 +00:00
Daniel Jasper fddb32c3d6 FileNameMatchTrie: Use StringRef instead of Twines where possible.
llvm-svn: 165412
2012-10-08 18:31:54 +00:00
Daniel Jasper 26cf9c4379 Support symlinks and relative paths in complilation databases.
Review: http://llvm-reviews.chandlerc.com/D30
llvm-svn: 165392
2012-10-08 16:08:15 +00:00
Ted Kremenek cdf814900d Split library clangRewrite into clangRewriteCore and clangRewriteFrontend.
This is similar to how we divide up the StaticAnalyzer libraries to separate
core functionality to what is clearly associated with Frontend actions.

llvm-svn: 163050
2012-09-01 05:09:24 +00:00
Nico Weber 077a53e5ab Tooling: Add a runToolOnCodeWithArgs() function that allows
passing additional parameters to a tool.

Use this to fix a FIXME in testing code.

llvm-svn: 162889
2012-08-30 02:02:19 +00:00
Alexander Kornienko 9ed8c4e941 Only add common tool options when CommonOptionsParser is used.
Summary: Subj.

Reviewers: chandlerc, klimek, djasper

Reviewed By: klimek

CC: cfe-commits

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

llvm-svn: 162798
2012-08-28 22:15:41 +00:00
NAKAMURA Takumi d574ac2f4d Fix the definition of JSONAnchorSource. MSVC mangles variable symbols, and "volatile" affects.
llvm-svn: 162550
2012-08-24 10:39:28 +00:00
Daniel Jasper 6ed1f85c24 Use LLVM's plugin registry to enable registering new compilation
databases. Move JSONCompilationDatabase.h to its own files and
register it as plugin.

llvm-svn: 162541
2012-08-24 05:50:27 +00:00
Alexander Kornienko 4bcd58b87d Updated LibTooling.html, minor improvements in CommonOptionsParser
llvm-svn: 162521
2012-08-24 00:39:14 +00:00
Alexander Kornienko 01387267c7 Reverted clang-check to fully supported CommandLine Library use-case: global
static variables.

llvm-svn: 162391
2012-08-22 20:52:52 +00:00
Manuel Klimek 3aad855a89 Fixes a segfault in Tooling when using pch's:
Clear the FileManager's stat cache in between running
translation units, as the stat cache loaded from a pch
is only valid for one compiler invocation.

llvm-svn: 161047
2012-07-31 13:56:54 +00:00
NAKAMURA Takumi 836926dbdf clang/lib: [CMake] Update tblgen'd dependencies.
llvm-svn: 160851
2012-07-27 06:18:33 +00:00
NAKAMURA Takumi 075c89bc06 clang/lib: [CMake] Reformat, alphabetize lists.
llvm-svn: 160850
2012-07-27 06:18:12 +00:00
Alexander Kornienko df36746d52 Reverted custom init hook from r160369.
llvm-svn: 160432
2012-07-18 12:24:51 +00:00
Alexander Kornienko 11330dc726 Add a custom initialize hook for clang tools + minor fixes in CustomCompilationDatabase.h
llvm-svn: 160369
2012-07-17 16:11:17 +00:00
Daniel Jasper 6389dd145d Finishing the move of RefactoringCallbacks and fixing the corresponding
buildbot failures.

llvm-svn: 160355
2012-07-17 08:37:03 +00:00
Daniel Jasper 1975e03494 Move RefactoringCallbacks to Tooling to avoid dependency from
ASTMatchers (lower level abstraction) to Tooling (higher level
abstraction).

llvm-svn: 160351
2012-07-17 08:03:01 +00:00
Ted Kremenek 816255dc39 Fix copy-paste mistake for CMake dependency.
llvm-svn: 160315
2012-07-16 20:22:15 +00:00
Ted Kremenek 42bff962b6 Looks like libTooling might also depend on ClangDiagnosticCommon.
llvm-svn: 160313
2012-07-16 19:44:15 +00:00
Alexander Kornienko f2f82550fd The new clang-ast-dump tool for selective AST dumping. Moved common command-line tool stuff to CommandLineClangTool
llvm-svn: 160265
2012-07-16 12:46:48 +00:00
Manuel Klimek 60b8016197 Allows retrieving all files in a CompilationDatabase.
Patch by Tobias Koenig, some test changes by myself.

llvm-svn: 160167
2012-07-13 12:31:45 +00:00
Daniel Jasper bb89ae9392 Add a hook to supply a custom CompilationDatabase. To add a custom CompilationDatabase, make it implement findCompilationDatabaseForDirectory in CustomCompilationDatabase.h and set USE_COSTUM_COMPILATION_DATABASE.
Differential Revision: http://llvm-reviews.chandlerc.com/D4

llvm-svn: 160061
2012-07-11 19:13:13 +00:00
Arnaud A. de Grandmaison 617f5269c3 Adds support for auto-detection of compilation databases, looking in a directory and all its parents.
llvm-svn: 159998
2012-07-10 16:56:35 +00:00
Manuel Klimek 65fd0e1fd3 Adds support for auto-detection of compilation databases
from a source file and changes clang-check to make use of this.

This makes clang-check just work on in-tree builds, and allows
easy setup via a symlink per source directory to make clang-check
work without any extra configuration.

llvm-svn: 159990
2012-07-10 13:10:51 +00:00
Manuel Klimek 5da9dcb275 Adapts the FrontendAction convenience functions so that it can be
used with classes that generate ASTConsumers; this allows decoupling
the ASTConsumer generation from the Frontend library (like, for example,
the MatchFinder in the upcoming ASTMatcher patch).

llvm-svn: 159760
2012-07-05 18:13:01 +00:00
Chandler Carruth 28969b4139 Remove a goofy CMake hack and use the standard CMake facilities to
express library-level dependencies within Clang.

This is no more verbose really, and plays nicer with the rest of the
CMake facilities. It should also have no change in functionality.

llvm-svn: 158888
2012-06-21 01:30:21 +00:00
Alexander Kornienko 8388d24701 Fixed a problem related to resolution of built-in headers in case a path of tool's binary contains sym-links.
llvm-svn: 157944
2012-06-04 19:02:59 +00:00
NAKAMURA Takumi 4de31654bb ToolInvocation::mapVirtualFile(): Tweak for Win32. Handle the key as native path.
llvm-svn: 157889
2012-06-02 15:34:21 +00:00
Alexander Kornienko 21d6ec9224 Fix an object lifetime issue in clang/Tooling.
llvm-svn: 157759
2012-05-31 17:58:43 +00:00
Manuel Klimek 8b1c60220d Adds a toString method to Replacement, which helps debugging.
Adds missing header guards to Refactoring.h.

llvm-svn: 157694
2012-05-30 16:04:29 +00:00
Alexander Kornienko 9e8d22896c Fixed a memory leak in clang/Tooling.
llvm-svn: 157687
2012-05-30 12:10:28 +00:00
NAKAMURA Takumi 9b2d17c613 Tooling: Canonicalize Key in IndexByFile[]. llvm::sys::path::native() may be used here.
It fixes test/Tooling on Win32 hosts.

llvm-svn: 157350
2012-05-23 22:24:20 +00:00
Manuel Klimek 3f00134c05 Adds the Refactoring library, which is a layer on top of the Tooling library
that allows easy refactoring across translation units.

llvm-svn: 157331
2012-05-23 16:29:20 +00:00
Manuel Klimek fdbe4f9dc2 Fixes crasher bug in JSONCompilationDatabase for invalid input.
llvm-svn: 156814
2012-05-15 11:46:07 +00:00
David Blaikie c9bd941f1f Fix -Wdelete-non-virtual-dtor in Tooling code.
Also, add an anchor as per http://llvm.org/docs/CodingStandards.html#ll_virtual_anch

llvm-svn: 156495
2012-05-09 18:31:50 +00:00
Simon Atanasyan 32df72db66 Declare abstract class ArgumentsAdjuster. This abstract interface describes
a command line argument adjuster, which is responsible for command line
arguments modification before the arguments are used to run a frontend action.

Define class ClangSyntaxOnlyAdjuster implements ArgumentsAdjuster interface.
This class converts input command line arguments to the "syntax check only"
variant.

Reviewed by Manuel Klimek.

llvm-svn: 156478
2012-05-09 16:18:30 +00:00
Manuel Klimek f33dcb0449 Fix includes for unices that don't have chdir declared transitively.
llvm-svn: 156302
2012-05-07 10:02:55 +00:00
Manuel Klimek 74cec54b80 Includes direct.h for windows compilation.
llvm-svn: 156301
2012-05-07 09:45:46 +00:00
Manuel Klimek 805d8dc52a Fixes resolution of relative paths when running clang tools.
The chdir is not the perfect fix, as it is thread hostile. The
real fix will be to make -working-dir work correctly, which will
take time to implement. Before that, the tooling library cannot
be used concurrently.

llvm-svn: 156299
2012-05-07 09:17:48 +00:00
Manuel Klimek 3778a435d1 Fixes the header search logic for tools:
The driver needs to get the correct path to the executable to deduce
the header search path.

llvm-svn: 155542
2012-04-25 09:25:41 +00:00
Manuel Klimek ff26efceb4 Adds a FixedCompilationDatabase to be able to specify tool parameters
at the command line.

llvm-svn: 154989
2012-04-18 07:41:50 +00:00
Manuel Klimek 40636c9986 Switches the JSONCompilationDatabase to use the YAML parser.
This will allow us to delete the JSON parser from llvm.

The biggest change is a general change of strategy - instead
of storing StringRef's to the values for the command line and
directory in the input buffer, we store ScalarNode*'s. The
reason is that the YAML parser's getRawValue on ScalarNodes
returns a string that includes the quotes in case of double
quoted strings.

For the same reason we're removing the JSON parsing part of
the command line parsing - this means an extra copy for a
command line when it is requested (and only when it is requested).

llvm-svn: 154929
2012-04-17 16:54:26 +00:00