summaryrefslogtreecommitdiffstats
path: root/clang/lib/Tooling/CompilationDatabase.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Remove \brief commands from doxygen comments.Adrian Prantl2018-05-091-1/+1
| | | | | | | | | | | | | | | | | | | This is similar to the LLVM change https://reviews.llvm.org/D46290. We've been running doxygen with the autobrief option for a couple of years now. This makes the \brief markers into our comments redundant. Since they are a visual distraction and we don't want to encourage more \brief markers in new code either, this patch removes them all. Patch produced by for i in $(git grep -l '\@brief'); do perl -pi -e 's/\@brief //g' $i & done for i in $(git grep -l '\\brief'); do perl -pi -e 's/\\brief //g' $i & done Differential Revision: https://reviews.llvm.org/D46320 llvm-svn: 331834
* [Tooling] Fix some Clang-tidy modernize and Include What You Use warnings; ↵Eugene Zelenko2018-03-141-16/+39
| | | | | | other minor fixes (NFC). llvm-svn: 327573
* [Tooling] Acknowledge that many CompilationDatabases don't support enumeration.Sam McCall2017-11-241-10/+9
| | | | | | | | | | | | Summary: Provide default implementations so that only getCompileCommands() is mandatory. Reviewers: ioeric Subscribers: cfe-commits, bkramer, klimek Differential Revision: https://reviews.llvm.org/D40409 llvm-svn: 318943
* [Tooling] Use FixedCompilationDatabase when `compile_flags.txt` is found.Sam McCall2017-11-091-2/+36
| | | | | | | | | | | | | | | | | | | | | Summary: This is an alternative to JSONCompilationDatabase for simple projects that don't use a build system such as CMake. (You can also drop one in ~, to make your tools use e.g. C++11 by default) There's no facility for varying flags per-source-file or per-machine. Possibly this could be accommodated backwards-compatibly using cpp, but even if not the simplicity seems worthwhile for the cases that are addressed. Tested with clangd, works great! (requires clangd restart) Reviewers: klimek Subscribers: ilya-biryukov, cfe-commits Differential Revision: https://reviews.llvm.org/D39799 llvm-svn: 317777
* Revert "[ADT] Make Twine's copy constructor private."Zachary Turner2017-10-111-3/+3
| | | | | | | | | | This reverts commit 4e4ee1c507e2707bb3c208e1e1b6551c3015cbf5. This is failing due to some code that isn't built on MSVC so I didn't catch. Not immediately obvious how to fix this at first glance, so I'm reverting for now. llvm-svn: 315536
* [ADT] Make Twine's copy constructor private.Zachary Turner2017-10-111-3/+3
| | | | | | | | | | | | | | | | | There's a lot of misuse of Twine scattered around LLVM. This ranges in severity from benign (returning a Twine from a function by value that is just a string literal) to pretty sketchy (storing a Twine by value in a class). While there are some uses for copying Twines, most of the very compelling ones are confined to the Twine class implementation itself, and other uses are either dubious or easily worked around. This patch makes Twine's copy constructor private, and fixes up all callsites. Differential Revision: https://reviews.llvm.org/D38767 llvm-svn: 315530
* [Tooling] FixedCompilationDatabase should be able to strip positionalAlex Lorenz2017-06-291-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
* Method loadFromCommandLine should be able to report errorsSerge Pavlov2017-05-241-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
* Extend CompilationDatabase by a field for the output filenameJoerg Sonnenberger2016-12-011-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
* Use llvm::raw_string_ostream instead of std::stringstream (NFC)Mehdi Amini2016-10-061-3/+2
| | | | | | As a side effect, this avoid having to call .data() on the StringRef. llvm-svn: 283416
* Use StringRef in Registry API (NFC)Mehdi Amini2016-10-011-1/+1
| | | | llvm-svn: 283039
* Reapply r276973 "Adjust Registry interface to not require plugins to export ↵John Brawn2016-08-051-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
* Revert r276973 "Adjust Registry interface to not require plugins to export a ↵John Brawn2016-07-281-2/+0
| | | | | | | | | registry" Buildbot failures when building with clang -Werror. Reverting while I try to figure this out. llvm-svn: 277008
* Reapply r276856 "Adjust Registry interface to not require plugins to export ↵John Brawn2016-07-281-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
* Revert r276856 "Adjust Registry interface to not require plugins to export a ↵John Brawn2016-07-271-2/+0
| | | | | | | | registry" This is causing a huge pile of buildbot failures. llvm-svn: 276857
* Adjust Registry interface to not require plugins to export a registryJohn Brawn2016-07-271-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
* Rename Action::begin() to Action::input_begin().Nico Weber2016-02-231-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
* Roll-back r250822.Angel Garcia Gomez2015-10-201-2/+2
| | | | | | | | | | Summary: It breaks the build for the ASTMatchers Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D13893 llvm-svn: 250827
* Apply modernize-use-default to clang.Angel Garcia Gomez2015-10-201-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
* [tooling] In CompileCommand, Expose the 'file' that was associated with the ↵Argyrios Kyrtzidis2015-09-111-1/+3
| | | | | | command. llvm-svn: 247468
* Use LLVM_ATTRIBUTE_UNUSED to hide gcc 5.1 unused variable warning.Yaron Keren2015-08-071-1/+1
| | | | | | Suggestion by David Blaikie! llvm-svn: 244326
* Silence tools/clang/lib/Tooling/CompilationDatabase.cpp:328:12: warning:Yaron Keren2015-08-071-1/+1
| | | | | | | ‘clang::tooling::JSONAnchorDest’ defined but not used [-Wunused-variable] from gcc 5.1. llvm-svn: 244312
* Driver: Remove the Job class. NFCJustin Bogner2015-07-021-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
* Replace push_back(Constructor(foo)) with emplace_back(foo) for non-trivial typesBenjamin Kramer2015-05-291-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
* Improve const-nessDavid Blaikie2015-04-171-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
* Use 'override/final' instead of 'virtual' for overridden methodsAlexander Kornienko2015-04-111-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
* Tooling: Hide implementation detailsBenjamin Kramer2015-03-091-3/+7
| | | | | | NFC. llvm-svn: 231656
* Driver: Use pointee_iterator rather than iterating over unique_ptrsJustin Bogner2014-10-031-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
* unique_ptrify JobList::JobsDavid Blaikie2014-09-041-3/+3
| | | | llvm-svn: 217168
* CompilationDatabase: Sure-up ownership of compilation databases using ↵David Blaikie2014-08-081-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
* Include system_error directly.Rafael Espindola2014-06-121-1/+1
| | | | llvm-svn: 210802
* [C++11] Use 'nullptr'. Tooling edition.Craig Topper2014-05-201-5/+5
| | | | llvm-svn: 209192
* Eliminate DefaultImageName from the Driver constructorAlp Toker2014-05-151-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
* Decouple ExprCXX.h and DeclCXX.h and clean up includes a bit.Benjamin Kramer2014-05-101-0/+1
| | | | | | | Required pulling LambdaExpr::Capture into its own header. No functionality change. llvm-svn: 208470
* PR19601: std::remove_if does not really remove the elements.Arnaud A. de Grandmaison2014-04-301-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
* [C++11] Avoid implicit conversion of ArrayRef to std::vector and use move ↵Benjamin Kramer2014-03-101-1/+2
| | | | | | semantics where appropriate. llvm-svn: 203477
* Replace OwningPtr with std::unique_ptr.Ahmed Charles2014-03-071-3/+3
| | | | | | This compiles cleanly with lldb/lld/clang-tools-extra/llvm. llvm-svn: 203279
* Switch all uses of LLVM_OVERRIDE to just use 'override' directly.Craig Topper2014-03-021-1/+1
| | | | llvm-svn: 202625
* Sort all the #include lines with LLVM's utils/sort_includes.py whichChandler Carruth2014-01-071-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
* CompilationDatabase.cpp:stripPositionalArgs(): Match not "no-integrated-as" ↵NAKAMURA Takumi2013-12-141-1/+2
| | | | | | but "-no-integrated-as", it really fixes r197229. llvm-svn: 197309
* clang-check to ignore -no-integrated-as because certain drivers can't handle itArtyom Skrobov2013-12-131-2/+6
| | | | llvm-svn: 197229
* Fixed a bad assert from r194968. r194969 removed the assert.Richard Trieu2013-12-051-0/+1
| | | | llvm-svn: 196463
* Tooling/CompilationDatabase.cpp: Use \return here instead of \param[out]. ↵NAKAMURA Takumi2013-11-171-3/+2
| | | | | | [-Wdocumentation] llvm-svn: 194971
* Remove a bad string compare from r194968Alp Toker2013-11-171-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
* Relax some preconditions for using FixedCompilationDatabase.Edwin Vane2013-11-171-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
* Remove useless 'llvm::' qualifier from names like StringRef and others that areDmitri Gribenko2013-01-121-2/+2
| | | | | | brought into 'clang' namespace by clang/Basic/LLVM.h llvm-svn: 172323
* Sort all of Clang's files under 'lib', and fix up the broken headersChandler Carruth2012-12-041-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
* Introduce CompilationDatabase::getAllCompileCommands() that returns allArgyrios Kyrtzidis2012-12-041-0/+5
| | | | | | compile commands of the database and expose it via the libclang API. llvm-svn: 169226
* Only report first error when no compilation database is found.Daniel Jasper2012-10-151-2/+7
| | | | | Review: http://llvm-reviews.chandlerc.com/D62 llvm-svn: 165933
* Use LLVM's plugin registry to enable registering new compilationDaniel Jasper2012-08-241-256/+36
| | | | | | | databases. Move JSONCompilationDatabase.h to its own files and register it as plugin. llvm-svn: 162541
OpenPOWER on IntegriCloud