summaryrefslogtreecommitdiffstats
path: root/clang/lib/Tooling
Commit message (Collapse)AuthorAgeFilesLines
...
* Revert "[LibTooling] Add Transformer, a library for source-to-source ↵Alexey Bataev2019-04-032-205/+0
| | | | | | | | | transformations." This reverts commit r357576 to fix the problem with the cyclic dependencies between libTooling and libToolingRefactor. llvm-svn: 357612
* [LibTooling] Add Transformer, a library for source-to-source transformations.Yitzhak Mandelbaum2019-04-032-0/+205
| | | | | | | | | | | | | | | | Summary: Adds a basic version of Transformer, a library supporting the concise specification of clang-based source-to-source transformations. A full discussion of the end goal can be found on the cfe-dev list with subject "[RFC] Easier source-to-source transformations with clang tooling". Reviewers: ilya-biryukov Reviewed By: ilya-biryukov Subscribers: mgorny, jfb, jdoerfert, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D59376 llvm-svn: 357576
* 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
* [Tooling] Avoid working-dir races in AllTUsToolExecutorIlya Biryukov2019-03-221-14/+7
| | | | | | | | | | | | | | Reviewers: ioeric Reviewed By: ioeric Subscribers: jdoerfert, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D59683 llvm-svn: 356743
* [Tooling] Add more scope specifiers until spelling is not ambiguous.Eric Liu2019-03-191-27/+47
| | | | | | | | | | | | | | | | | | Summary: Previously, when the renamed spelling is ambiguous, we simply use the full-qualfied name (with leading "::"). This patch makes it try adding additional specifiers one at a time until name is no longer ambiguous, which allows us to find better disambuguated spelling. Reviewers: kadircet, gribozavr Subscribers: jdoerfert, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D59487 llvm-svn: 356446
* [LibTooling] Add retrieval of extended AST-node source to FixIt libraryYitzhak Mandelbaum2019-03-131-4/+12
| | | | | | | | | | | | | | | | | | | | | Summary: Introduces variants of `getText` and `getSourceRange` that extract the source text of an AST node potentially with a trailing token. Some of the new functions manipulate `CharSourceRange`s, rather than `SourceRange`s, because they document and dynamically enforce their type. So, this revision also updates the corresponding existing FixIt functions to manipulate `CharSourceRange`s. This change is not strictly necessary, but seems like the correct choice, to keep the API self-consistent. This revision is the first in a series intended to improve the abstractions available to users for writing source-to-source transformations. A full discussion of the end goal can be found on the cfe-dev list with subject "[RFC] Easier source-to-source transformations with clang tooling". Reviewers: ilya-biryukov Reviewed By: ilya-biryukov Subscribers: kimgr, riccibruno, JonasToth, jdoerfert, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D58556 llvm-svn: 356095
* [clang][Tooling] Delete dots and dotdots when generating absolute pathsKadir Cetinkaya2019-03-081-0/+1
| | | | | | | | | | | | | | | | Summary: GetAllFiles interface returns absolute paths, but keeps dots and dot dots. This patch makes those paths canonical by deleting them. Reviewers: hokein Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D59079 llvm-svn: 355678
* Switch to cantFail(), since it does the same assertion.Stephen Hines2019-02-061-6/+5
| | | | | | | | | | | | Reviewers: cfe-commits, lhames Reviewed By: lhames Subscribers: hintonda, klimek, pirama Differential Revision: https://reviews.llvm.org/D36806 llvm-svn: 353318
* [AST] Update the comments of the various Expr::Ignore* + Related cleanupsBruno Ricci2019-02-031-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The description of what the various Expr::Ignore* do has drifted from the actual implementation. Inspection reveals that IgnoreParenImpCasts() is not equivalent to doing IgnoreParens() + IgnoreImpCasts() until reaching a fixed point, but IgnoreParenCasts() is equivalent to doing IgnoreParens() + IgnoreCasts() until reaching a fixed point. There is also a fair amount of duplication in the various Expr::Ignore* functions which increase the chance of further future inconsistencies. In preparation for the next patch which will factor out the implementation of the various Expr::Ignore*, do the following cleanups: Remove Stmt::IgnoreImplicit, in favor of Expr::IgnoreImplicit. IgnoreImplicit is the only function among all of the Expr::Ignore* which is available in Stmt. There are only a few users of Stmt::IgnoreImplicit. They can just use instead Expr::IgnoreImplicit like they have to do for the other Ignore*. Move Expr::IgnoreImpCasts() from Expr.h to Expr.cpp. This made no difference in the run-time with my usual benchmark (-fsyntax-only on all of Boost). While we are at it, make IgnoreParenNoopCasts take a const reference to the ASTContext for const correctness. Update the comments to match what the Expr::Ignore* are actually doing. I am not sure that listing exactly what each Expr::Ignore* do is optimal, but it certainly looks better than the current state which is in my opinion between misleading and just plain wrong. The whole patch is NFC (if you count removing Stmt::IgnoreImplicit as NFC). Differential Revision: https://reviews.llvm.org/D57266 Reviewed By: aaron.ballman llvm-svn: 353006
* [Tooling] Handle #pragma once header guard in include insertion.Eric Liu2019-01-291-18/+44
| | | | | | | | | | Reviewers: ilya-biryukov Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D57223 llvm-svn: 352503
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-1931-124/+93
| | | | | | | | | | | | | | | | | 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
* [tooling] Add a new argument adjuster for deleting plugin related command ↵Kadir Cetinkaya2019-01-181-0/+22
| | | | | | | | | | | | | | | | line args Summary: Currently both clangd and clang-tidy makes use of this mechanism so putting it into tooling so that all tools can make use of it. Reviewers: ilya-biryukov, sammccall Subscribers: ioeric, cfe-commits Differential Revision: https://reviews.llvm.org/D56856 llvm-svn: 351531
* Reapply [Tooling] Make clang-tool find libc++ dir on mac when running on a ↵Sam McCall2019-01-161-4/+15
| | | | | | | | | file without compilation database. This reverts commit r351282, and re-lands r351222 and r351229 with the use-after-free fixed. llvm-svn: 351316
* Revert "[Tooling] Make clang-tool find libc++ dir on mac when running on a ↵Vlad Tsyrklevich2019-01-161-14/+4
| | | | | | | | | file without compilation database." This reverts commits r351222 and r351229, they were causing ASan/MSan failures on the sanitizer bots. llvm-svn: 351282
* [Tooling] Make clang-tool find libc++ dir on mac when running on a file ↵Haojian Wu2019-01-151-4/+14
| | | | | | | | | | | | | | | | | | | | | | without compilation database. Summary: This is a regression of r348365. When clang-tools run on a file without a complation database (`clang-check /tmp/t.cc`), we will use fixed compilation database as a fallback. However the actual compiler path in the fallback complation command is just `clang-tool` which is insufficient to detect the libc++ dir. Reviewers: ilya-biryukov, EricWF Reviewed By: ilya-biryukov Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D56680 llvm-svn: 351222
* 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
* PR40096: Forwards-compatible with C++20 rule regarding aggregates not having ↵David Blaikie2018-12-191-2/+0
| | | | | | | | | | user-declared ctors Looks like these were in place to make these types move-only. That's generally not a feature that the type should prescribe (unless it's an inherent limitation) - instead leaving it up to the users of a type. llvm-svn: 349669
* Add explicit dependency on clangSerialization for a bunch of components to ↵Fangrui Song2018-12-121-0/+1
| | | | | | | | | | | | | | | fix -DBUILD_SHARED_LIBS=on build This is a more thorough fix of rC348911. The story about -DBUILD_SHARED_LIBS=on build after rC348907 (Move PCHContainerOperations from Frontend to Serialization) is: 1. libclangSerialization.so defines PCHContainerReader dtor, ... 2. clangFrontend and clangTooling define classes inheriting from PCHContainerReader, thus their DSOs have undefined references on PCHContainerReader dtor 3. Components depending on either clangFrontend or clangTooling cannot be linked unless they have explicit dependency on clangSerialization due to the default linker option -z defs. The explicit dependency could be avoided if libclang{Frontend,Tooling}.so had these undefined references. This patch adds the explicit dependency on clangSerialization to make them build. llvm-svn: 348915
* clang::tooling::Diagnostic: Don't store offset in the scratch space.Alexander Kornienko2018-11-211-2/+7
| | | | | | | | These offsets are useless (and even harmful in certain cases) in exported diagnostics. The test will be added to clang-tidy, since it's the main user of the clang::tooling::Diagnostic class. llvm-svn: 347372
* 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
* [Tooling] Correct the total number of files being processed when `filter` is ↵Haojian Wu2018-11-051-4/+6
| | | | | | | | | | | | provided. Reviewers: ioeric Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D54104 llvm-svn: 346135
* [Tooling] Add "-filter" option to AllTUsExecutionHaojian Wu2018-11-051-1/+11
| | | | | | | | | | | | Summary: We can run the tools on a subset files of compilation database. Reviewers: ioeric Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D54092 llvm-svn: 346131
* NFC: Remove the ObjC1/ObjC2 distinction from clang (and related projects)Erik Pilkington2018-10-301-2/+1
| | | | | | | | | | We haven't supported compiling ObjC1 for a long time (and never will again), so there isn't any reason to keep these separate. This patch replaces LangOpts::ObjC1 and LangOpts::ObjC2 with LangOpts::ObjC. Differential revision: https://reviews.llvm.org/D53547 llvm-svn: 345637
* Use llvm::{all,any,none}_of instead std::{all,any,none}_of. NFCFangrui Song2018-10-201-3/+2
| | | | llvm-svn: 344859
* [Tooling] Expose ExecutorName option.Eric Liu2018-10-121-1/+1
| | | | llvm-svn: 344335
* Lift VFS from clang to llvm (NFC)Jonas Devlieghere2018-10-103-22/+22
| | | | | | | | | | | | | | | | | | | 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] Get rid of uses of llvm::Twine::str which is slow. NFCEric Liu2018-09-271-4/+5
| | | | llvm-svn: 343224
* llvm::sort(C.begin(), C.end(), ...) -> llvm::sort(C, ...)Fangrui Song2018-09-263-11/+10
| | | | | | | | | | | | | | Summary: The convenience wrapper in STLExtras is available since rL342102. Reviewers: rsmith, #clang, dblaikie Reviewed By: rsmith, #clang Subscribers: mgrang, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D52576 llvm-svn: 343147
* [Tooling] JSONCompilationDatabasePlugin infers compile commands for missing ↵Sam McCall2018-09-141-1/+4
| | | | | | | | | | | | | | | | files Summary: See the existing InterpolatingCompilationDatabase for details on how this works. We've been using this in clangd for a while, the heuristics seem to work well. Reviewers: bkramer Subscribers: ilya-biryukov, ioeric, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D51729 llvm-svn: 342228
* [Tooling] Wait for all threads to finish before resetting CWD.Eric Liu2018-09-121-0/+2
| | | | llvm-svn: 342028
* [Tooling] Restore working dir in ClangTool.Ilya Biryukov2018-09-112-1/+35
| | | | | | | | | | | | | | | | | | | 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
* Fix build bots after a mistake in r341760Hamza Sood2018-09-091-1/+1
| | | | llvm-svn: 341761
* [Tooling] Improve handling of CL-style optionsHamza Sood2018-09-091-34/+119
| | | | | | | | | | | | | | | | | | This patch fixes the handling of clang-cl options in InterpolatingCompilationDatabase. They were previously ignored completely, which led to a lot of bugs: Additional options were being added with the wrong syntax. E.g. a file was specified as C++ by adding -x c++, which causes an error in CL mode. The args were parsed and then rendered, which means that the aliasing information was lost. E.g. /W4 was rendered to -Wall, which in CL mode means -Weverything. CL options were ignored when checking things like -std=, so a lot of logic was being bypassed. Differential Revision: https://reviews.llvm.org/D51321 llvm-svn: 341760
* [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
* Parse compile commands lazily in InterpolatingCompilationDatabaseIlya Biryukov2018-08-281-57/+61
| | | | | | | | | | | | | | | | | Summary: This greatly reduces the time to read 'compile_commands.json'. For Chromium on my machine it's now 0.7 seconds vs 30 seconds before the change. Reviewers: sammccall, jfb Reviewed By: sammccall Subscribers: mgrang, jfb, cfe-commits Differential Revision: https://reviews.llvm.org/D51314 llvm-svn: 340838
* [Tooling] Allow -flto flags and filter out -Wa, flagsChih-Hung Hsieh2018-08-221-6/+14
| | | | | | | | | | | | | This change fixes the problem in https://bugs.llvm.org/show_bug.cgi?id=38332 by allowing driver::Action::BackendJobClass to run with the analyzer. Otherwise, such jobs will look up the non-existing compilation database and then run without flags. Also filter out the -Wa,* flags that could be passed to and ignored by the clang compiler. Clang-tidy gives warnings about unused -Wa,* flags. Differential Revision: http://reviews.llvm.org/D51002 llvm-svn: 340421
* Port getLocEnd -> getEndLocStephen Kelly2018-08-093-4/+4
| | | | | | | | | | Reviewers: teemperor! Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D50351 llvm-svn: 339386
* Port getLocStart -> getBeginLocStephen Kelly2018-08-093-6/+6
| | | | | | | | | | Reviewers: teemperor! Subscribers: jholewinski, whisperity, jfb, cfe-commits Differential Revision: https://reviews.llvm.org/D50350 llvm-svn: 339385
* Fully qualify the renamed symbol if the shortened name is ambiguous.Eric Liu2018-08-031-2/+42
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: For example, when renaming `a::b::x::foo` to `y::foo` below, replacing `x::foo()` with `y::foo()` can cause ambiguity. In such cases, we simply fully qualify the name with leading `::`. ``` namespace a { namespace b { namespace x { void foo() {} } namespace y { void foo() {} } } } namespace a { namespace b { void f() { x::foo(); } } } ``` Reviewers: ilya-biryukov, hokein Reviewed By: ilya-biryukov Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D50189 llvm-svn: 338832
* [Tooling] Use UniqueStringSaver. NFCSam McCall2018-07-231-10/+1
| | | | llvm-svn: 337682
* [Tooling] Make standalone executor support user-provided vfs.Eric Liu2018-07-121-3/+5
| | | | llvm-svn: 336928
* [Tooling] Get working directory properly without assuming real file system.Eric Liu2018-07-121-3/+7
| | | | llvm-svn: 336910
* Reland "Move #include manipulation code to new lib/Tooling/Inclusions."Eric Liu2018-06-045-5/+15
| | | | | | | | This reverts commit r333534 (i.e. reland r332720) after fixing module build. Differential Revision: https://reviews.llvm.org/D47068 llvm-svn: 333874
* Revert "Reland "Move #include manipulation code to new lib/Tooling/Inclusions.""Eric Liu2018-05-305-15/+5
| | | | | | This reverts commit r333532. Revert for now to fix an internal bot issue. llvm-svn: 333534
* Reland "Move #include manipulation code to new lib/Tooling/Inclusions."Eric Liu2018-05-305-5/+15
| | | | | | | | | This reverts commit r332751 (i.e. reland r332720) after fixing module build. Differential Revision: https://reviews.llvm.org/D47068 llvm-svn: 333532
* Revert "Move #include manipulation code to new lib/Tooling/Inclusions."Eric Liu2018-05-185-15/+5
| | | | | | | This reverts commit r332720. This break build bot with modules. Need to investigate. Revert the change to unbreak bots. llvm-svn: 332751
OpenPOWER on IntegriCloud