aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Tooling/JSONCompilationDatabase.cpp
AgeCommit message (Collapse)AuthorFilesLines
2016-12-01Extend CompilationDatabase by a field for the output filenameJoerg Sonnenberger1-2/+8
In bigger projects like an Operating System, the same source code is often compiled in slightly different ways. This could be the difference between PIC and non-PIC code for static vs dynamic libraries, it could also be the difference between size optimised versions of tools for ramdisk images. At the moment, the compilation database has no way to distinguish such cases. As first step, add a field in the JSON format for it and process it accordingly. Differential Revision: https://reviews.llvm.org/D27138 llvm-svn: 288436
2016-08-18Fix json compilation database syntax on non-Windows.Zachary Turner1-4/+2
llvm-svn: 279122
2016-08-18Resubmit "[Tooling] Parse compilation database command lines on Windows."Zachary Turner1-12/+42
This patch introduced the ability to decide at runtime whether to parse JSON compilation database command lines using Gnu syntax or Windows syntax. However, there were many existing unit tests written that hardcoded Gnu-specific paths. These tests were now failing because the auto-detection logic was choosing to parse them using Windows rules. This resubmission of the patch fixes this by introducing an enum which defines the syntax mode, which defaults to auto-detect, but for which the unit tests force Gnu style parsing. Reviewed By: alexfh Differential Revision: https://reviews.llvm.org/D23628 llvm-svn: 279120
2016-08-17Revert "[Tooling] Parse compilation database command lines on Windows."Zachary Turner1-18/+0
This reverts commit 27a874790fc79f6391ad3703d7c790f51ac6ae1f. After the introduction of windows command line parsing, some unit tests began failing that expect to test gnu style command line quirks. The fix is mechanical but time consuming, so revert this for now. llvm-svn: 278976
2016-08-17[Tooling] Parse compilation database command lines on Windows.Zachary Turner1-0/+18
When a compilation database is used on Windows, the command lines cannot be parsed using the standard GNU style syntax. LLVM provides functions for parsing Windows style command lines, so use them where appropriate. After this patch, clang-tidy runs correctly on Windows. Reviewed by: alexfh Differential Revision: https://reviews.llvm.org/D23455 llvm-svn: 278964
2015-09-22[tooling] Provide the compile commands of the JSON database in the order ↵Argyrios Kyrtzidis1-7/+4
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-11[tooling] In CompileCommand, Expose the 'file' that was associated with the ↵Argyrios Kyrtzidis1-3/+6
command. llvm-svn: 247468
2015-09-08Fix performance regression when running clang tools.Manuel Klimek1-22/+30
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-08-14Add structed way to express command line options in the compilation database.Manuel Klimek1-27/+42
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-05-29Replace push_back(Constructor(foo)) with emplace_back(foo) for non-trivial typesBenjamin Kramer1-4/+4
If the type isn't trivially moveable emplace can skip a potentially expensive move. It also saves a couple of characters. Call sites were found with the ASTMatcher + some semi-automated cleanup. memberCallExpr( argumentCountIs(1), callee(methodDecl(hasName("push_back"))), on(hasType(recordDecl(has(namedDecl(hasName("emplace_back")))))), hasArgument(0, bindTemporaryExpr( hasType(recordDecl(hasNonTrivialDestructor())), has(constructExpr()))), unless(isInTemplateInstantiation())) No functional change intended. llvm-svn: 238601
2015-03-18Remove many superfluous SmallString::str() calls.Yaron Keren1-3/+3
Now that SmallString is a first-class citizen, most SmallString::str() calls are not required. This patch removes a whole bunch of them, yet there are lots more. There are two use cases where str() is really needed: 1) To use one of StringRef member functions which is not available in SmallString. 2) To convert to std::string, as StringRef implicitly converts while SmallString do not. We may wish to change this, but it may introduce ambiguity. llvm-svn: 232622
2014-08-08Sure-up MemoryBuffer ownership in JSONCompilationDatabase's ctor.David Blaikie1-2/+2
llvm-svn: 215246
2014-08-08CompilationDatabase: Sure-up ownership of compilation databases using ↵David Blaikie1-7/+7
std::unique_ptr Diving into the memory leaks fixed by r213851 there was one case of a memory leak of a CompilationDatabase due to not properly taking ownership of the result of "CompilationDatabase::autoDetectFromSource". Given that both implementations and callers have been using unique_ptr to own CompilationDatabase objects - make this explicit in the API to reduce the risk of further leaks. llvm-svn: 215215
2014-07-06Update for llvm api change.Rafael Espindola1-5/+4
llvm-svn: 212408
2014-06-12Include system_error directly.Rafael Espindola1-1/+1
llvm-svn: 210802
2014-06-12Replace llvm::error_code with std::error_code.Rafael Espindola1-2/+2
llvm-svn: 210780
2014-06-01Don't compare an error_code with nullptr.Rafael Espindola1-1/+1
llvm-svn: 209993
2014-05-20[C++11] Use 'nullptr'. Tooling edition.Craig Topper1-14/+14
llvm-svn: 209192
2014-03-15[C++11] Add 'override' keyword to virtual methods that override their base ↵Craig Topper1-2/+2
class. llvm-svn: 203999
2014-03-07Replace OwningPtr with std::unique_ptr.Ahmed Charles1-5/+5
This compiles cleanly with lldb/lld/clang-tools-extra/llvm. llvm-svn: 203279
2014-03-07Change OwningPtr::take() to OwningPtr::release().Ahmed Charles1-5/+5
This is a precursor to moving to std::unique_ptr. llvm-svn: 203275
2013-11-27Remove a whole lot of unused variablesAlp Toker1-1/+1
There are about 30 removed in this patch, generated by a new FixIt I haven't got round to submitting yet. llvm-svn: 195814
2013-07-01Put helper class in anonymous namespace.Craig Topper1-2/+2
llvm-svn: 185306
2013-03-02CommandLineArgumentParser: handle single quotes.Peter Collingbourne1-3/+14
Differential Revision: http://llvm-reviews.chandlerc.com/D482 llvm-svn: 176404
2013-01-12Remove useless 'llvm::' qualifier from names like StringRef and others that areDmitri Gribenko1-21/+19
brought into 'clang' namespace by clang/Basic/LLVM.h llvm-svn: 172323
2013-01-12Fix spurious output in JSONCompilationDatabaseArnaud A. de Grandmaison1-5/+1
llvm-svn: 172321
2012-12-04Sort all of Clang's files under 'lib', and fix up the broken headersChandler Carruth1-1/+0
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-04Introduce CompilationDatabase::getAllCompileCommands() that returns allArgyrios Kyrtzidis1-9/+25
compile commands of the database and expose it via the libclang API. llvm-svn: 169226
2012-10-08Support symlinks and relative paths in complilation databases.Daniel Jasper1-3/+23
Review: http://llvm-reviews.chandlerc.com/D30 llvm-svn: 165392
2012-08-24Fix the definition of JSONAnchorSource. MSVC mangles variable symbols, and ↵NAKAMURA Takumi1-1/+1
"volatile" affects. llvm-svn: 162550
2012-08-24Use LLVM's plugin registry to enable registering new compilationDaniel Jasper1-0/+283
databases. Move JSONCompilationDatabase.h to its own files and register it as plugin. llvm-svn: 162541