summaryrefslogtreecommitdiffstats
path: root/clang/lib/Tooling/Tooling.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [libTooling] Extend `buildASTFromCodeWithArgs` to take files argument.Yitzhak Mandelbaum2019-11-191-1/+7
| | | | | | | | | | | | | | | | | Summary: Adds an optional parameter to `buildASTFromCodeWithArgs` that allows the user to pass additional files that the main code needs to compile. This change makes `buildASTFromCodeWithArgs` consistent with `runToolOnCodeWithArgs`. Patch by Alexey Eremin. Reviewers: gribozavr Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D70175
* [tooling] Relax an assert when multiple GPU targets are specified.Michael Liao2019-10-181-1/+1
| | | | llvm-svn: 375245
* [tooling] Fix assertion on MacOSX.Michael Liao2019-10-101-1/+6
| | | | llvm-svn: 374478
* [tooling] Teach Tooling to understand compilation with offloading.Michael Liao2019-10-101-1/+23
| | | | | | | | | | | | | | | | Summary: - So far, we only recognize the host compilation with offloading and skip the offloading part. Reviewers: tra, yaxunl Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D68660 llvm-svn: 374470
* [Driver] Use shared singleton instance of DriverOptTableIlya Biryukov2019-09-041-2/+1
| | | | | | | | | | | | | | | | | | | | | Summary: This significantly reduces the time required to run clangd tests, by ~10%. Should also have an effect on other tests that run command-line parsing multiple times inside a single invocation. Reviewers: gribozavr, sammccall Reviewed By: sammccall Subscribers: kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D67163 llvm-svn: 370908
* [Tooling] Migrated APIs that take ownership of objects to unique_ptrDmitri Gribenko2019-08-301-15/+14
| | | | | | | | | | Subscribers: jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D66960 llvm-svn: 370451
* [clang-scan-deps] reuse the file manager across invocations ofAlex Lorenz2019-08-291-2/+6
| | | | | | | | | | | | | | | | the dependency scanner on a single worker thread This behavior can be controlled using the new `-reuse-filemanager` clang-scan-deps option. By default the file manager is reused. The added test/ClangScanDeps/symlink.cpp is able to pass with the reused filemanager after the related FileEntryRef changes landed earlier. The test test/ClangScanDeps/subframework_header_dir_symlink.m still fails when the file manager is reused (I run the FileCheck with not to make it PASS). I will address this in a follow-up patch that improves the DirectoryEntry name modelling in the FileManager. llvm-svn: 370420
* Changed FrontendActionFactory::create to return a std::unique_ptrDmitri Gribenko2019-08-291-5/+10
| | | | | | | | | | Subscribers: jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D66947 llvm-svn: 370379
* ArrayRef'ized CompilerInvocation::CreateFromArgsDmitri Gribenko2019-08-271-3/+1
| | | | | | | | | | Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D66797 llvm-svn: 370122
* [clang-scan-deps] Introduce the DependencyScanning library with theAlex Lorenz2019-06-261-1/+6
| | | | | | | | | | | | | thread worker code and better error handling This commit extracts out the code that will powers the fast scanning worker into a new file in a new DependencyScanning library. The error and output handling is improved so that the clients can gather errors/results from the worker directly. Differential Revision: https://reviews.llvm.org/D63681 llvm-svn: 364474
* [clang-tidy] Fail gracefully upon empty database fieldsSerge Guelton2019-06-201-1/+1
| | | | | | | | Fix bz#42281 Differential Revision: https://reviews.llvm.org/D63613 llvm-svn: 363975
* Basic: Return a reference from FileManager::getVirtualFileSystem, NFCDuncan P. N. Exon Smith2019-03-261-1/+1
| | | | | | | | | | FileManager constructs a VFS in its constructor if it isn't passed one, and there's no way to reset it. Make that contract clear by returning a reference from its accessor. https://reviews.llvm.org/D59388 llvm-svn: 357038
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-191-4/+3
| | | | | | | | | | | | | | | | | to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
* Fix use-after-free bug in Tooling.Alexander Kornienko2019-01-081-12/+6
| | | | | | | | | | | | | | | | | | | Summary: `buildASTFromCodeWithArgs()` was creating a memory buffer referencing a stack-allocated string. This diff changes the implementation to copy the code string into the memory buffer so that said buffer owns the memory. Patch by Yitzhak Mandelbaum. Reviewers: alexfh Reviewed By: alexfh Subscribers: cfe-commits, EricWF Differential Revision: https://reviews.llvm.org/D55765 llvm-svn: 350638
* Remove stat cache chaining as it's no longer needed after PTH support has beenAlex Lorenz2018-12-211-1/+1
| | | | | | | | | | | | | removed Stat cache chaining was implemented for a StatListener in the PTH writer so that it could write out the stat information to PTH. r348266 removed support for PTH, and it doesn't seem like there are other uses of stat cache chaining. We can remove the chaining support. Differential Revision: https://reviews.llvm.org/D55455 llvm-svn: 349942
* Revert "Make clang-based tools find libc++ on MacOS"Jonas Devlieghere2018-11-121-3/+0
| | | | | | This breaks the LLDB bots. llvm-svn: 346675
* Make clang-based tools find libc++ on MacOSIlya Biryukov2018-11-121-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: When they read compiler args from compile_commands.json. This change allows to run clang-based tools, like clang-tidy or clangd, built from head using the compile_commands.json file produced for XCode toolchains. On MacOS clang can find the C++ standard library relative to the compiler installation dir. The logic to do this was based on resource dir as an approximation of where the compiler is installed. This broke the tools that read 'compile_commands.json' and don't ship with the compiler, as they typically change resource dir. To workaround this, we now use compiler install dir detected by the driver to better mimic the behavior of the original compiler when replaying the compilations using other tools. Reviewers: sammccall, arphaman, EricWF Reviewed By: sammccall Subscribers: ioeric, christof, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D54310 llvm-svn: 346652
* [Tooling] Avoid diagnosing missing input files in an edge-case where it's ↵Sam McCall2018-11-091-0/+6
| | | | | | incorrect. llvm-svn: 346485
* [Tooling] Produce diagnostics for missing input files.Sam McCall2018-11-081-2/+0
| | | | | | | | | | | | | | | | | | Summary: This was disabled way back in 2011, in the dark times before Driver was VFS-aware. Also, make driver more VFS-aware :-) This breaks one ClangTidy test (we improved the error message), will fix when submitting. Reviewers: ioeric Subscribers: cfe-commits, alexfh Differential Revision: https://reviews.llvm.org/D53958 llvm-svn: 346414
* Lift VFS from clang to llvm (NFC)Jonas Devlieghere2018-10-101-18/+18
| | | | | | | | | | | | | | | | | | | This patch moves the virtual file system form clang to llvm so it can be used by more projects. Concretely the patch: - Moves VirtualFileSystem.{h|cpp} from clang/Basic to llvm/Support. - Moves the corresponding unit test from clang to llvm. - Moves the vfs namespace from clang::vfs to llvm::vfs. - Formats the lines affected by this change, mostly this is the result of the added llvm namespace. RFC on the mailing list: http://lists.llvm.org/pipermail/llvm-dev/2018-October/126657.html Differential revision: https://reviews.llvm.org/D52783 llvm-svn: 344140
* [Tooling] Restore working dir in ClangTool.Ilya Biryukov2018-09-111-0/+22
| | | | | | | | | | | | | | | | | | | Summary: And add an option to disable this behavior. The option is only used in AllTUsExecutor to avoid races when running concurrently on multiple threads. This fixes PR38869 introduced by r340937. Reviewers: ioeric, steveire Reviewed By: ioeric Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D51864 llvm-svn: 341910
* [Tooling] Do not restore working dir in ClangToolIlya Biryukov2018-08-291-19/+22
| | | | | | | | | | | | | | | | | | | | | | | Summary: Resolve all relative paths before running the tool instead. This fixes the usage of ClangTool in AllTUsExecutor. The executor will try running multiple ClangTool instances in parallel with compile commands that usually have the same working directory. Changing working directory is a global operation, so we end up changing working directory in the middle of running other actions, which leads to spurious compile errors. Reviewers: ioeric, sammccall Reviewed By: ioeric Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D51407 llvm-svn: 340937
* [Tooling] Get working directory properly without assuming real file system.Eric Liu2018-07-121-3/+7
| | | | llvm-svn: 336910
* [Tooling] Add an overload of runToolOnCodeWithArgs that takes VFSEric Liu2018-05-181-10/+21
| | | | | | | | | | | | Summary: ... to support purely VFS-based tools. Reviewers: bkramer Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D47074 llvm-svn: 332731
* [clang] Update uses of DEBUG macro to LLVM_DEBUG.Nicola Zaghen2018-05-151-1/+1
| | | | | | | | | | | | | The DEBUG() macro is very generic so it might clash with other projects. The renaming was done as follows: - git grep -l 'DEBUG' | xargs sed -i 's/\bDEBUG\s\?(/LLVM_DEBUG(/g' - git diff -U0 master | ../clang/tools/clang-format/clang-format-diff.py -i -p1 -style LLVM Explicitly avoided changing the strings in the clang-format tests. Differential Revision: https://reviews.llvm.org/D44975 llvm-svn: 332350
* Remove \brief commands from doxygen comments.Adrian Prantl2018-05-091-3/+3
| | | | | | | | | | | | | | | | | | | 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
* IWYU for llvm-config.h in clang. See r331124 for details.Nico Weber2018-04-301-1/+0
| | | | llvm-svn: 331177
* Move a ref-counted pointer instead of copying it. NFC.Alexander Kornienko2018-03-271-1/+1
| | | | llvm-svn: 328623
* [Tooling] Fix some Clang-tidy modernize and Include What You Use warnings; ↵Eugene Zelenko2018-03-141-50/+82
| | | | | | other minor fixes (NFC). llvm-svn: 327573
* Revert "[Tooling] [0/1] Refactor FrontendActionFactory::create() to return ↵Roman Lebedev2018-02-271-20/+17
| | | | | | | | | | | | std::unique_ptr<>" This reverts commit rL326201 This broke gcc4.8 builds, compiler just segfaults:¬ http://lab.llvm.org:8011/builders/clang-atom-d525-fedora-rel/builds/14909¬ http://lab.llvm.org:8011/builders/clang-x86_64-linux-abi-test/builds/22673¬ llvm-svn: 326204
* [Tooling] [0/1] Refactor FrontendActionFactory::create() to return ↵Roman Lebedev2018-02-271-17/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | std::unique_ptr<> Summary: Noticed during review of D41102. I'm not sure whether there are any principal reasons why it returns raw owning pointer, or it is just a old code that was not updated post-C++11. I'm not too sure what testing i should do, because `check-all` is not error clean here for some reason, but it does not //appear// asif those failures are related to these changes. This is clang part. Clang-tools-extra part is D43780. Reviewers: klimek, bkramer, alexfh, pcc Reviewed By: alexfh Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D43779 llvm-svn: 326201
* [Tooling] Returns non-zero status code when files are skipped.Eric Liu2018-02-021-6/+3
| | | | | | | | | | | | Reviewers: hokein, bkramer Reviewed By: bkramer Subscribers: bkramer, klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D42361 llvm-svn: 324113
* [Tooling] Added a VFS parameter to ClangToolIlya Biryukov2018-01-231-2/+3
| | | | | | | | | | | | | | | | | | Summary: The parameter overrides the underlying vfs used by ClangTool for filesystem operations. Patch by Vladimir Plyashkun. Reviewers: alexfh, ilya-biryukov Reviewed By: ilya-biryukov Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D41947 llvm-svn: 323195
* [Tooling] A new framework for executing clang frontend actions.Eric Liu2017-10-261-5/+2
| | | | | | | | | | | | | | | | | | | | | | | Summary: This defines a `clang::tooling::ToolExecutor` interface that can be extended to support different execution plans including standalone execution on a given set of TUs or parallel execution on all TUs in a codebase. In order to enable multiprocessing execution, tool actions are expected to output result into a `ToolResults` interface provided by executors. The `ToolResults` interface abstracts how results are stored e.g. in-memory for standalone executions or on-disk for large-scale execution. New executors can be registered as `ToolExecutorPlugin`s via the `ToolExecutorPluginRegistry`. CLI tools can use `createExecutorFromCommandLineArgs` to create a specific registered executor according to the command-line arguments. This patch also implements `StandaloneToolExecutor` which has the same behavior as the current `ClangTool` interface, i.e. execute frontend actions on a given set of TUs. At this point, it's simply a wrapper around `ClangTool` at this point. This is still experimental but expected to replace the existing `ClangTool` interface so that specific tools would not need to worry about execution. Reviewers: klimek, arphaman, hokein, sammccall Reviewed By: klimek Subscribers: cfe-commits, djasper, mgorny, omtcyfz Differential Revision: https://reviews.llvm.org/D34272 llvm-svn: 316653
* Use class to pass information about executable nameSerge Pavlov2017-08-291-4/+5
| | | | | | | | | | | | | Information about clang executable name components, such as target and driver mode, was passes in std::pair. With this change it is passed in a special structure. It improves readability and makes access to this information more convenient. NFC. Differential Revision: https://reviews.llvm.org/D36057 llvm-svn: 311981
* Prevent ClangTools from generating dependency files.Sterling Augustine2017-07-141-0/+1
| | | | | | | | | | | | | | | | | | | | D34304 created a way for ToolInvocations to conditionally generate dependency files, and updated call sites to preserve the old behavior of not generating them by default. CompilerInvocations... Summary: ...are yet another call-path that needs updating to preserve the old behavior. Reviewers: klimek, echristo Reviewed By: echristo Subscribers: echristo, cfe-commits Differential Revision: https://reviews.llvm.org/D35131 llvm-svn: 308043
* This call-site should have been updated as part of D34304.Sterling Augustine2017-07-061-3/+5
| | | | | | | | | | Summary: Use an argument adjuster to preserve behavior inadvertantly changed by D34304. Reviewers: klimek Differential Revision: https://reviews.llvm.org/D35095 llvm-svn: 307329
* Allow CompilerInvocations to generate .d files.Sterling Augustine2017-07-061-4/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Most clang tools should ignore the -M family of options because one wouldn't want them to generate a new dependency (.d) file. However, some tools may want this dependency file. This patch creates a mechanism for them to do this. This implementation just plumbs a boolean down several layers of calls. Each of the modified calls has several call sites, and so a single member variable or new API entry point won't work. An alternative would be to write a function to filter the -M family of arguments out of CC1Args, and have each caller call that function by hand before calling newInvocation, Invocation::run, or buildAstFromCodeWithArgs. This is a more complicated and error-prone solution. Why burden all the callers to remember to use this function? But I could rewrite this patch to use that method if that is deemed more appropriate. Reviewers: klimek Reviewed By: klimek Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D34304 llvm-svn: 307315
* Method loadFromCommandLine should be able to report errorsSerge Pavlov2017-05-241-0/+2
| | | | | | | | | | | | | | | 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
* unique_ptrify createDriverOptTableDavid Blaikie2017-01-131-1/+1
| | | | llvm-svn: 291919
* Reapply "IntrusiveRefCntPtr -> std::shared_ptr for CompilerInvocationBase ↵David Blaikie2017-01-061-7/+8
| | | | | | | | | | | | | | and CodeCompleteConsumer" Aleksey Shlypanikov pointed out my mistake in migrating an explicit unique_ptr to auto - I was expecting the function returned a unique_ptr, but instead it returned a raw pointer - introducing a leak. Thanks Aleksey! This reapplies r291184, reverted in r291249. llvm-svn: 291270
* Revert "IntrusiveRefCntPtr -> std::shared_ptr for CompilerInvocationBase and ↵David Blaikie2017-01-061-8/+7
| | | | | | | | | | CodeCompleteConsumer" Caused a memory leak reported by asan. Reverting while I investigate. This reverts commit r291184. llvm-svn: 291249
* IntrusiveRefCntPtr -> std::shared_ptr for CompilerInvocationBase and ↵David Blaikie2017-01-051-7/+8
| | | | | | CodeCompleteConsumer llvm-svn: 291184
* Fix memory leak by storing returned pointer in std::unique_ptrRichard Trieu2016-08-301-4/+3
| | | | llvm-svn: 280157
* Fix colored diagnostics from toolsOlivier Goffart2016-08-301-0/+8
| | | | | | | | | | r271042 changed the way the diagnostic arguments are parsed. It assumes that the diagnostics options were already parsed by the "Driver". For tools using clang::Tooling, the diagnostics argument were not parsed. Differential Revision: https://reviews.llvm.org/D23837 llvm-svn: 280118
* [NFC] Header cleanupMehdi Amini2016-07-181-1/+2
| | | | | | | | | | Summary: Removed unused headers, replaced some headers with forward class declarations Patch by: Eugene <claprix@yandex.ru> Differential Revision: https://reviews.llvm.org/D20100 llvm-svn: 275882
* NFC. Test commit, remove a redundant empty line in Tooling.cppArtur Pilipenko2016-06-281-1/+0
| | | | llvm-svn: 274041
* Apply some suggestions from clang-tidy's performance-unnecessary-value-param.Benjamin Kramer2016-06-151-2/+3
| | | | | | No functionality change intended. llvm-svn: 272789
* Add some std::move where the value is only read otherwise.Benjamin Kramer2016-06-121-10/+13
| | | | | | This mostly affects smart pointers. No functionality change intended. llvm-svn: 272520
* Apply clang-tidy's misc-move-constructor-init throughout Clang.Benjamin Kramer2016-05-271-3/+6
| | | | | | No functionality change intended, maybe a tiny performance improvement. llvm-svn: 270996
OpenPOWER on IntegriCloud