summaryrefslogtreecommitdiffstats
path: root/clang/lib/Tooling
Commit message (Collapse)AuthorAgeFilesLines
* [Tooling] Inject -resource-dir instead of overwriting argv[0].Benjamin Kramer2016-04-211-8/+23
| | | | | | | | | This allows using a different standard library (the one from argv[0] in the compilation database) with the correct builtins. Differential Revision: http://reviews.llvm.org/D19356 llvm-svn: 266973
* [Tooling] Fix getting fully qualified names of template alias types.Chaoren Lin2016-04-201-0/+2
| | | | | | | | | | Reviewers: rsmith, rnk Subscribers: cfe-commits, klimek Differential Revision: http://reviews.llvm.org/D19253 llvm-svn: 266925
* Added formatAndApplyAllReplacements that works on multiple files in libTooling.Eric Liu2016-03-293-9/+40
| | | | | | | | | | | | | | Summary: formatAndApplyAllReplacements takes a set of Replacements, applies them on a Rewriter, and reformats the changed code. Reviewers: klimek, djasper Subscribers: ioeric, klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D17852 llvm-svn: 264745
* Add functions to apply replacements and reformat them.Manuel Klimek2016-03-011-2/+15
| | | | | | | | | | | | | | | | This is a commonly useful feature to have, and we have implemented it multiple times with different kinds of bugs. This implementation centralizes the idea in a set of functions that we can then use from the various tools. Reverts r262234, which is a revert of r262232, and puts the functions into FOrmat.h, as they are closely coupled to clang-format, and we otherwise introduce a cyclic dependency between libFormat and libTooling. Patch by Eric Liu. llvm-svn: 262323
* Revert "Implement new interfaces for code-formatting when applying ↵Manuel Klimek2016-02-291-43/+2
| | | | | | | | replacements." This reverts commit r262232. llvm-svn: 262234
* Implement new interfaces for code-formatting when applying replacements.Manuel Klimek2016-02-291-2/+43
| | | | | | Patch by Eric Liu. llvm-svn: 262232
* 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
* Print options, if requested.Alexander Kornienko2016-02-231-0/+2
| | | | llvm-svn: 261625
* Stop using "template" when printing qualtype namesReid Kleckner2016-02-161-1/+2
| | | | | | | | | | | | | | | | Summary: The keyword "template" isn't necessary when printing a fully-qualified qualtype name, and, in fact, results in a syntax error if one tries to use it. So stop printing it. Reviewers: rsmith, rnk Subscribers: rnk, klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D17214 llvm-svn: 261005
* Remove unused includesDavid Majnemer2016-02-111-2/+0
| | | | llvm-svn: 260552
* Silence some MSVC false positive warnings about integer zexts and falling ↵Reid Kleckner2016-02-101-0/+1
| | | | | | off the end of a covered switch llvm-svn: 260411
* Add Tooling functionality to get a name for a QualType that can be used to nameRichard Smith2016-02-092-0/+433
| | | | | | | | | that type from the global scope. Patch by Sterling Augustine, derived (with permission) from code from Cling by Vassil Vassilev and Philippe Canal. llvm-svn: 260278
* Add an optional ToolName argument to ↵Benjamin Kramer2016-01-291-8/+10
| | | | | | | | | | runToolOnCodeWithArgs/buildASTFromCodeWithArgs. This can be used as a way to modify argv[0] for a clang tool. Differential Revision: http://reviews.llvm.org/D16718 llvm-svn: 259187
* Remove autoconf supportChris Bieneman2016-01-262-27/+0
| | | | | | | | | | | | | | | | | Summary: This patch is provided in preparation for removing autoconf on 1/26. The proposal to remove autoconf on 1/26 was discussed on the llvm-dev thread here: http://lists.llvm.org/pipermail/llvm-dev/2016-January/093875.html "This is the way [autoconf] ends Not with a bang but a whimper." -T.S. Eliot Reviewers: chandlerc, grosbach, bob.wilson, echristo Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D16472 llvm-svn: 258862
* Add fall-back mode for clang tools.Manuel Klimek2015-12-031-4/+7
| | | | | | | | | Run without flags if we cannot load a compilation database. This matches the behavior of clang itself when simply called with a source file. Based on a patch by Russell Wallace. llvm-svn: 254599
* Fix calculation of shifted cursor/code positions. Specifically supportDaniel Jasper2015-11-231-21/+19
| | | | | | | | | the case where a specific range is replaced by new text. Previously, the calculation would shift any position from within a replaced region to the first character after the region. This is undersirable, e.g. for clang-format's include sorting. llvm-svn: 253859
* Make ArgumentAdjuster aware of the current file being processed.Alexander Kornienko2015-11-053-9/+7
| | | | | | | | | | | | | | Summary: This is needed to handle per-project configurations when adding extra arguments in clang-tidy for example. Reviewers: klimek, djasper Subscribers: djasper, cfe-commits, klimek Differential Revision: http://reviews.llvm.org/D14191 llvm-svn: 252134
* Unbreak the shared cmake build. libToolingCore now depends on libAST.Benjamin Kramer2015-10-221-0/+1
| | | | llvm-svn: 251026
* [Tooling] Add a utility function to replace one nested name with another.Benjamin Kramer2015-10-222-0/+114
| | | | | | | | | | | | | | | | One problem in clang-tidy and other clang tools face is that there is no way to lookup an arbitrary name in the AST, that's buried deep inside Sema and might not even be what the user wants as the new name may be freshly inserted and not available in the AST. A common use case for lookups is replacing one nested name with another while minimizing namespace qualifications, so replacing 'ns::foo' with 'ns::bar' will use just 'bar' if we happen to be inside the namespace 'ns'. This adds a little helper utility for exactly that use case. Differential Revision: http://reviews.llvm.org/D13931 llvm-svn: 251022
* Roll-back r250822.Angel Garcia Gomez2015-10-202-5/+5
| | | | | | | | | | 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-202-5/+5
| | | | | | | | | | | | 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
* Revert accidental commit. This isn't ready yet.Benjamin Kramer2015-10-201-1/+0
| | | | llvm-svn: 250804
* Put back dead code that's used out-of-tree.Benjamin Kramer2015-10-201-0/+1
| | | | | | Partially reverts r250418. llvm-svn: 250803
* [VFS] Wire up driver VFS through tooling.Benjamin Kramer2015-10-091-4/+5
| | | | | | | | Sadly I don't currently have a way to tests this as the driver is always initialized with the default triple and finding system headers is system specific. llvm-svn: 249831
* [VFS] Port tooling to use the in-memory file system.Benjamin Kramer2015-10-091-20/+52
| | | | | | | | | | This means file remappings can now be managed by ClangTool (or a ToolInvocation user) instead of by ToolInvocation itself. The ToolInvocation remapping is still in place so users can migrate. Differential Revision: http://reviews.llvm.org/D13474 llvm-svn: 249815
* [Tooling] Don't run a tool invocation without a FileManager.Benjamin Kramer2015-10-061-1/+3
| | | | | | Fixes a crash regression from r249410. llvm-svn: 249413
* [Tooling] Reuse FileManager in ASTUnit.Benjamin Kramer2015-10-061-2/+2
| | | | | | | | ASTUnit was creating multiple FileManagers and throwing them away. Reuse the one from Tooling. No functionality change now but necessary for VFSifying tooling. llvm-svn: 249410
* [Tooling] Remove dead code.Benjamin Kramer2015-10-061-9/+1
| | | | | | | | | | It took me some time to figure out why this is not working as expected: std:error_code converts to true if there is an error. This means we never ever took the generated absolute path, which happens to be the right thing anyways as it properly works with virtual files. Just remove the whole thing, relative paths are covered by existing tooling tests. llvm-svn: 249408
* Adds a way for tools to deduce the target config from a compiler name.Manuel Klimek2015-10-061-0/+26
| | | | | | | | | | | | | Adds `addTargetAndModeForProgramName`, a utility function that will add appropriate `-target foo` and `--driver-mode=g++` tokens to a command line for driver invocations of the form `a/b/foo-g++`. It is intended to support tooling: for example, should a compilation database record some invocation of `foo-g++` without these implicit flags, a Clang tool may use this function to add them back. Patch by Luke Zarko. llvm-svn: 249391
* [VFS] Port applyAllReplacements to InMemoryFileSystem.Benjamin Kramer2015-10-061-8/+7
| | | | llvm-svn: 249388
* Fix bad iterator access.Daniel Jasper2015-09-231-1/+2
| | | | llvm-svn: 248375
* clang-format: Add initial #include sorting capabilities.Daniel Jasper2015-09-231-0/+132
| | | | | | | | | To implement this nicely, add a function that merges two sets of replacements that are meant to be done in sequence. This functionality will also be useful for other applications, e.g. formatting the result of clang-tidy fixes. llvm-svn: 248367
* [tooling] Provide the compile commands of the JSON database in the order ↵Argyrios Kyrtzidis2015-09-221-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
* [tooling] In CompileCommand, Expose the 'file' that was associated with the ↵Argyrios Kyrtzidis2015-09-112-4/+9
| | | | | | command. llvm-svn: 247468
* Fix performance regression when running clang tools.Manuel Klimek2015-09-081-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
* [clang-tidy] Make NumOccurrenceFlag for SourcePaths configurable.Alexander Kornienko2015-08-171-4/+7
| | | | | | | | | | | | Added an additional ctor that takes a NumOccurrenceFlag parameter for the SourcePaths option. This frees applications from always having to pass at least one source file, e.g., -list-checks. http://reviews.llvm.org/D12069 Patch by Don Hinton! llvm-svn: 245204
* Add structed way to express command line options in the compilation database.Manuel Klimek2015-08-141-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
* 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
* Revert r240270 ("Fixed/added namespace ending comments using clang-tidy").Alexander Kornienko2015-06-221-2/+2
| | | | llvm-svn: 240353
* Fixed/added namespace ending comments using clang-tidy. NFCAlexander Kornienko2015-06-221-2/+2
| | | | | | | | | | | | The patch is generated using this command: $ tools/extra/clang-tidy/tool/run-clang-tidy.py -fix \ -checks=-*,llvm-namespace-comment -header-filter='llvm/.*|clang/.*' \ work/llvm/tools/clang To reduce churn, not touching namespaces spanning less than 10 lines. llvm-svn: 240270
* Introduce a PCHContainerOperations interface (NFC).Adrian Prantl2015-06-202-46/+56
| | | | | | | | | | | | | | | | A PCHContainerOperations abstract interface provides operations for creating and unwrapping containers for serialized ASTs (precompiled headers and clang modules). The default implementation is RawPCHContainerOperations, which uses a flat file for the output. The main application for this interface will be an ObjectFilePCHContainerOperations implementation that uses LLVM to wrap the module in an ELF/Mach-O/COFF container to store debug info alongside the AST. rdar://problem/20091852 llvm-svn: 240225
* Tooling: When applying a set of replacements, do deletions beforeDaniel Jasper2015-06-161-1/+6
| | | | | | | | insertions. It is unlikely to be the intention to delete parts of newly inserted code. To do so, changed sorting Replacements at the same offset to have decreasing length. llvm-svn: 239809
* Allow replacements created from token ranges to specify language options.Manuel Klimek2015-06-031-7/+10
| | | | | | | | The default language options will lead to incorrect replacements in C++ code, for example when trying to replace nested name specifiers ending in "::". llvm-svn: 238922
* Replace push_back(Constructor(foo)) with emplace_back(foo) for non-trivial typesBenjamin Kramer2015-05-292-6/+5
| | | | | | | | | | | | | | | | | | | | 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
* Fix bug in Replacement's toString on Windows (missing flush).Manuel Klimek2015-04-201-4/+4
| | | | | | Adapt function to LLVM coding style. llvm-svn: 235286
* 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
* Make the clang-fuzzer use the CompilerInstance directly.Manuel Klimek2015-03-281-1/+1
| | | | | | Going through the driver is too slow. llvm-svn: 233459
OpenPOWER on IntegriCloud