aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Tooling/CompilationDatabase.cpp
AgeCommit message (Collapse)AuthorFilesLines
2017-06-29[Tooling] FixedCompilationDatabase should be able to strip positionalAlex Lorenz1-3/+5
arguments when `-fsyntax-only` is used Previously, Clang failed to create a fixed compilation database when the compilation arguments use -fsyntax-only instead of -c. This commit fixes the issue by forcing Clang to look at the compilation job when stripping the positional arguments. Differential Revision: https://reviews.llvm.org/D34687 llvm-svn: 306659
2017-05-24Method loadFromCommandLine should be able to report errorsSerge Pavlov1-16/+26
Now FixedCompilationDatabase::loadFromCommandLine has no means to report which error occurred if it fails to create compilation object. This is a block for implementing D33013, because after that change driver will refuse to create compilation if command line contains erroneous options. This change adds additional argument to loadFromCommandLine, which is assigned error message text if compilation object was not created. This is the same way as other methods of CompilationDatabase report failure. Differential Revision: https://reviews.llvm.org/D33272 llvm-svn: 303741
2016-12-01Extend CompilationDatabase by a field for the output filenameJoerg Sonnenberger1-1/+2
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-10-06Use llvm::raw_string_ostream instead of std::stringstream (NFC)Mehdi Amini1-3/+2
As a side effect, this avoid having to call .data() on the StringRef. llvm-svn: 283416
2016-10-01Use StringRef in Registry API (NFC)Mehdi Amini1-1/+1
llvm-svn: 283039
2016-08-05Reapply r276973 "Adjust Registry interface to not require plugins to export ↵John Brawn1-0/+2
a registry" This differs from the previous version by being more careful about template instantiation/specialization in order to prevent errors when building with clang -Werror. Specifically: * begin is not defined in the template and is instead instantiated when Head is. I think the warning when we don't do that is wrong (PR28815) but for now at least do it this way to avoid the warning. * Instead of performing template specializations in LLVM_INSTANTIATE_REGISTRY instead provide a template definition then do explicit instantiation. No compiler I've tried has problems with doing it the other way, but strictly speaking it's not permitted by the C++ standard so better safe than sorry. Original commit message: Currently the Registry class contains the vestiges of a previous attempt to allow plugins to be used on Windows without using BUILD_SHARED_LIBS, where a plugin would have its own copy of a registry and export it to be imported by the tool that's loading the plugin. This only works if the plugin is entirely self-contained with the only interface between the plugin and tool being the registry, and in particular this conflicts with how IR pass plugins work. This patch changes things so that instead the add_node function of the registry is exported by the tool and then imported by the plugin, which solves this problem and also means that instead of every plugin having to export every registry they use instead LLVM only has to export the add_node functions. This allows plugins that use a registry to work on Windows if LLVM_EXPORT_SYMBOLS_FOR_PLUGINS is used. llvm-svn: 277806
2016-07-28Revert r276973 "Adjust Registry interface to not require plugins to export a ↵John Brawn1-2/+0
registry" Buildbot failures when building with clang -Werror. Reverting while I try to figure this out. llvm-svn: 277008
2016-07-28Reapply r276856 "Adjust Registry interface to not require plugins to export ↵John Brawn1-0/+2
a registry" This version has two fixes compared to the original: * In Registry.h the template static members are instantiated before they are used, as clang gives an error if you do it the other way around. * The use of the Registry template in clang-tidy is updated in the same way as has been done everywhere else. Original commit message: Currently the Registry class contains the vestiges of a previous attempt to allow plugins to be used on Windows without using BUILD_SHARED_LIBS, where a plugin would have its own copy of a registry and export it to be imported by the tool that's loading the plugin. This only works if the plugin is entirely self-contained with the only interface between the plugin and tool being the registry, and in particular this conflicts with how IR pass plugins work. This patch changes things so that instead the add_node function of the registry is exported by the tool and then imported by the plugin, which solves this problem and also means that instead of every plugin having to export every registry they use instead LLVM only has to export the add_node functions. This allows plugins that use a registry to work on Windows if LLVM_EXPORT_SYMBOLS_FOR_PLUGINS is used. llvm-svn: 276973
2016-07-27Revert r276856 "Adjust Registry interface to not require plugins to export a ↵John Brawn1-2/+0
registry" This is causing a huge pile of buildbot failures. llvm-svn: 276857
2016-07-27Adjust Registry interface to not require plugins to export a registryJohn Brawn1-0/+2
Currently the Registry class contains the vestiges of a previous attempt to allow plugins to be used on Windows without using BUILD_SHARED_LIBS, where a plugin would have its own copy of a registry and export it to be imported by the tool that's loading the plugin. This only works if the plugin is entirely self-contained with the only interface between the plugin and tool being the registry, and in particular this conflicts with how IR pass plugins work. This patch changes things so that instead the add_node function of the registry is exported by the tool and then imported by the plugin, which solves this problem and also means that instead of every plugin having to export every registry they use instead LLVM only has to export the add_node functions. This allows plugins that use a registry to work on Windows if LLVM_EXPORT_SYMBOLS_FOR_PLUGINS is used. Differential Revision: http://reviews.llvm.org/D21385 llvm-svn: 276856
2016-02-23Rename Action::begin() to Action::input_begin().Nico Weber1-3/+2
Also introduce inputs() that reutnrs an llvm::iterator_range. Iterating over A->inputs() is much less mysterious than iterating over *A. No intended behavior change. llvm-svn: 261674
2015-10-20Roll-back r250822.Angel Garcia Gomez1-2/+2
Summary: It breaks the build for the ASTMatchers Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D13893 llvm-svn: 250827
2015-10-20Apply modernize-use-default to clang.Angel Garcia Gomez1-2/+2
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-09-11[tooling] In CompileCommand, Expose the 'file' that was associated with the ↵Argyrios Kyrtzidis1-1/+3
command. llvm-svn: 247468
2015-08-07Use LLVM_ATTRIBUTE_UNUSED to hide gcc 5.1 unused variable warning.Yaron Keren1-1/+1
Suggestion by David Blaikie! llvm-svn: 244326
2015-08-07Silence tools/clang/lib/Tooling/CompilationDatabase.cpp:328:12: warning:Yaron Keren1-1/+1
‘clang::tooling::JSONAnchorDest’ defined but not used [-Wunused-variable] from gcc 5.1. llvm-svn: 244312
2015-07-02Driver: Remove the Job class. NFCJustin Bogner1-8/+5
We had a strange relationship here where we made a list of Jobs inherit from a single Job, but there weren't actually any places where this arbitrary nesting was used or needed. Simplify all of this by removing Job entirely and updating all of the users to either work with a JobList or a single Command. llvm-svn: 241310
2015-05-29Replace push_back(Constructor(foo)) with emplace_back(foo) for non-trivial typesBenjamin Kramer1-2/+1
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-04-17Improve const-nessDavid Blaikie1-5/+3
This allows callers to pass a char ** (such as the one coming from the standard decreed main declaration - even though everyone usually puts const on that themselves). llvm-svn: 235150
2015-04-11Use 'override/final' instead of 'virtual' for overridden methodsAlexander Kornienko1-2/+2
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-03-09Tooling: Hide implementation detailsBenjamin Kramer1-3/+7
NFC. llvm-svn: 231656
2014-10-03Driver: Use pointee_iterator rather than iterating over unique_ptrsJustin Bogner1-4/+3
There's probably never a good reason to iterate over unique_ptrs. This lets us use range-for and say Job.foo instead of (*it)->foo in a few places. llvm-svn: 218938
2014-09-04unique_ptrify JobList::JobsDavid Blaikie1-3/+3
llvm-svn: 217168
2014-08-08CompilationDatabase: Sure-up ownership of compilation databases using ↵David Blaikie1-14/+13
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-06-12Include system_error directly.Rafael Espindola1-1/+1
llvm-svn: 210802
2014-05-20[C++11] Use 'nullptr'. Tooling edition.Craig Topper1-5/+5
llvm-svn: 209192
2014-05-15Eliminate DefaultImageName from the Driver constructorAlp Toker1-3/+3
All callers were passing in "a.out" or garbage so a sensible default works fine here as a cleanup. This also brings about the possibility of adapting the value based on the driver's compatibility mode in future. The setting can still be changed via Driver::DefaultImageName as needed. llvm-svn: 208926
2014-05-10Decouple ExprCXX.h and DeclCXX.h and clean up includes a bit.Benjamin Kramer1-0/+1
Required pulling LambdaExpr::Capture into its own header. No functionality change. llvm-svn: 208470
2014-04-30PR19601: std::remove_if does not really remove the elements.Arnaud A. de Grandmaison1-2/+3
It moves them at the end of the range instead, so an extra erase is needed. It is strange that this code works without the erase. On the other hand, removing the remove_if will make fail some tests. llvm-svn: 207696
2014-03-10[C++11] Avoid implicit conversion of ArrayRef to std::vector and use move ↵Benjamin Kramer1-1/+2
semantics where appropriate. llvm-svn: 203477
2014-03-07Replace OwningPtr with std::unique_ptr.Ahmed Charles1-3/+3
This compiles cleanly with lldb/lld/clang-tools-extra/llvm. llvm-svn: 203279
2014-03-02Switch all uses of LLVM_OVERRIDE to just use 'override' directly.Craig Topper1-1/+1
llvm-svn: 202625
2014-01-07Sort all the #include lines with LLVM's utils/sort_includes.py whichChandler Carruth1-9/+8
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
2013-12-14CompilationDatabase.cpp:stripPositionalArgs(): Match not "no-integrated-as" ↵NAKAMURA Takumi1-1/+2
but "-no-integrated-as", it really fixes r197229. llvm-svn: 197309
2013-12-13clang-check to ignore -no-integrated-as because certain drivers can't handle itArtyom Skrobov1-2/+6
llvm-svn: 197229
2013-12-05Fixed a bad assert from r194968. r194969 removed the assert.Richard Trieu1-0/+1
llvm-svn: 196463
2013-11-17Tooling/CompilationDatabase.cpp: Use \return here instead of \param[out]. ↵NAKAMURA Takumi1-3/+2
[-Wdocumentation] llvm-svn: 194971
2013-11-17Remove a bad string compare from r194968Alp Toker1-1/+0
lib/Tooling/CompilationDatabase.cpp:275:34: warning: result of comparison against a string literal is unspecified (use strncmp instead) [-Wstring-compare] This assert() should probably be fixed and added back at some point. llvm-svn: 194969
2013-11-17Relax some preconditions for using FixedCompilationDatabase.Edwin Vane1-2/+185
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-01-12Remove useless 'llvm::' qualifier from names like StringRef and others that areDmitri Gribenko1-2/+2
brought into 'clang' namespace by clang/Basic/LLVM.h llvm-svn: 172323
2012-12-04Sort all of Clang's files under 'lib', and fix up the broken headersChandler Carruth1-1/+1
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-0/+5
compile commands of the database and expose it via the libclang API. llvm-svn: 169226
2012-10-15Only report first error when no compilation database is found.Daniel Jasper1-2/+7
Review: http://llvm-reviews.chandlerc.com/D62 llvm-svn: 165933
2012-08-24Use LLVM's plugin registry to enable registering new compilationDaniel Jasper1-256/+36
databases. Move JSONCompilationDatabase.h to its own files and register it as plugin. llvm-svn: 162541
2012-07-17Add a custom initialize hook for clang tools + minor fixes in ↵Alexander Kornienko1-1/+1
CustomCompilationDatabase.h llvm-svn: 160369
2012-07-13Allows retrieving all files in a CompilationDatabase.Manuel Klimek1-0/+20
Patch by Tobias Koenig, some test changes by myself. llvm-svn: 160167
2012-07-11Add a hook to supply a custom CompilationDatabase. To add a custom ↵Daniel Jasper1-0/+9
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-10Adds support for auto-detection of compilation databases, looking in a ↵Arnaud A. de Grandmaison1-9/+33
directory and all its parents. llvm-svn: 159998
2012-07-10Adds support for auto-detection of compilation databasesManuel Klimek1-1/+18
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-05-23Tooling: Canonicalize Key in IndexByFile[]. llvm::sys::path::native() may be ↵NAKAMURA Takumi1-2/+6
used here. It fixes test/Tooling on Win32 hosts. llvm-svn: 157350