summaryrefslogtreecommitdiffstats
path: root/clang/lib/Tooling
Commit message (Collapse)AuthorAgeFilesLines
...
* Try to shorten system header paths when using -MD depfilesPeter Wu2017-10-191-1/+3
| | | | | | | | | | | | | | | | | | | | | GCC tries to shorten system headers in depfiles using its real path (resolving components like ".." and following symlinks). Mimic this feature to ensure that the Ninja build tool detects the correct dependencies when a symlink changes directory levels, see https://github.com/ninja-build/ninja/issues/1330 An option to disable this feature is added in case "these changed header paths may conflict with some compilation environments", see https://gcc.gnu.org/ml/gcc-patches/2012-09/msg00287.html Note that the original feature request for GCC (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52974) also included paths preprocessed output (-E) and diagnostics. That is not implemented now since I am not sure if it breaks something else. Differential Revision: https://reviews.llvm.org/D37954 llvm-svn: 316193
* Fix a few nits in RenamingAction.Haojian Wu2017-10-191-2/+2
| | | | | | | * Add missing override keyword. * avoid unnecessary copy of std::string. llvm-svn: 316152
* [refactor] selection: new CodeRangeASTSelection represents a set of selectedAlex Lorenz2017-10-181-0/+105
| | | | | | | | | | | consecutive statements This commit adds a CodeRangeASTSelection value to the refactoring library. This value represents a set of selected statements in one body of code. Differential Revision: https://reviews.llvm.org/D38835 llvm-svn: 316104
* [clang-rename] Rename alias.Haojian Wu2017-10-181-60/+59
| | | | | | | | | | | | | | | | | | Summary: * Support rename alias. * Add unittests for renaming alias. * Don't generate fixes for the SourceLocations that are invalid or in temporary buffer, otherwise crash would be happened when generating AtomicChanges. Reviewers: ioeric Reviewed By: ioeric Subscribers: klimek, mgorny, cfe-commits Differential Revision: https://reviews.llvm.org/D39043 llvm-svn: 316074
* [clang-rename] Rename enum.Haojian Wu2017-10-171-4/+40
| | | | | | | | | | | | | | | | Summary: * Add unit tests for renaming enum. * Support unscoped enum constants in expressions. Reviewers: ioeric Reviewed By: ioeric Subscribers: klimek, mgorny, cfe-commits Differential Revision: https://reviews.llvm.org/D38989 llvm-svn: 315999
* [refactor] allow the use of refactoring diagnosticsAlex Lorenz2017-10-161-5/+4
| | | | | | | | | This commit allows the refactoring library to use its own set of refactoring-specific diagnostics to reports things like initiation errors. Differential Revision: https://reviews.llvm.org/D38772 llvm-svn: 315924
* [clang-rename] Add function unit tests.Haojian Wu2017-10-161-0/+23
| | | | | | | | | | | | | | | | | Summary: Also contain a fix: * Fix a false positive of renaming a using shadow function declaration. Reviewers: ioeric Reviewed By: ioeric Subscribers: klimek, mgorny, cfe-commits Differential Revision: https://reviews.llvm.org/D38882 llvm-svn: 315898
* Recommit r315087 "[refactor] add support for refactoring options"Alex Lorenz2017-10-131-11/+13
| | | | | | | | | | | | | | | | The recommit fixes a UB bug that occurred only on a small number of bots. Original message: This commit adds initial support for refactoring options. One can now use optional and required std::string options. This commit also adds a NewNameOption for the local-rename refactoring action to allow rename to work with custom names. Differential Revision: https://reviews.llvm.org/D37856 llvm-svn: 315661
* 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
* [clang-rename] Don't add prefix qualifiers to the declaration and definition ↵Haojian Wu2017-10-111-26/+49
| | | | | | | | | | | | | | of the renamed symbol. Reviewers: ioeric Reviewed By: ioeric Subscribers: klimek, cfe-commits, arphaman Differential Revision: https://reviews.llvm.org/D38723 llvm-svn: 315452
* Revert r315087Alex Lorenz2017-10-061-13/+11
| | | | | | clang-refactor crashes on some bots after this commit llvm-svn: 315095
* [refactor] add support for refactoring optionsAlex Lorenz2017-10-061-11/+13
| | | | | | | | | | | | This commit adds initial support for refactoring options. One can now use optional and required std::string options. This commit also adds a NewNameOption for the local-rename refactoring action to allow rename to work with custom names. Differential Revision: https://reviews.llvm.org/D37856 llvm-svn: 315087
* [refactor] Simplify the refactoring interfaceAlex Lorenz2017-10-023-57/+57
| | | | | | | | | | | | | This commit simplifies the interface for the refactoring action rules and the refactoring requirements. It merges the selection constraints and the selection requirements into one class. The refactoring actions rules must now be implemented using subclassing instead of raw function / lambda pointers. This change also removes a bunch of template-based traits and other template definitions that are now redundant. Differential Revision: https://reviews.llvm.org/D37681 llvm-svn: 314704
* [refactor] Use CommonOptionsParser in clang-refactorAlex Lorenz2017-09-141-5/+7
| | | | | | | | | This commit ensures that CommonOptionsParser works with subcommands. This allows clang-refactor to use the CommonOptionsParser. Differential Revision: https://reviews.llvm.org/D37618 llvm-svn: 313260
* [refactor] add clang-refactor tool with initial testing support andAlex Lorenz2017-09-145-0/+112
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | local-rename action This commit introduces the clang-refactor tool alongside the local-rename action which uses the existing renaming engine used by clang-rename. The tool doesn't actually perform the source transformations yet, it just provides testing support. This commit also moves only one test from clang-rename over to test/Refactor. I will continue to move the other tests throughout development of clang-refactor. The following options are supported by clang-refactor: -v: use verbose output -selection: The source range that corresponds to the portion of the source that's selected (currently only special command test:<file> is supported). Please note that a follow-up commit will migrate clang-refactor to libTooling's common option parser, so clang-refactor will be able to use the common interface with compilation database and options like -p, -extra-arg, etc. The testing support provided by clang-refactor is described below: When -selection=test:<file> is given, clang-refactor will parse the selection commands from that file. The selection commands are grouped and the specified refactoring action invoked by the tool. Each command in a group is expected to produce an identical result. The precise syntax for the selection commands is described in a comment in TestSupport.h. Differential Revision: https://reviews.llvm.org/D36574 llvm-svn: 313244
* clang-rename: let -force handle multiple renamesMiklos Vajna2017-09-112-2/+10
| | | | | | | | | | | | | | | | | | | | | | | Summary: The use case is that renaming multiple symbols in a large enough codebase is much faster if all of these can be done with a single invocation, but there will be multiple translation units where one or more symbols are not found. Old behavior was to exit with an error (default) or exit without reporting an error (-force). New behavior is that -force results in a best-effort rename: rename symbols which are found and just ignore the rest. The existing help for -force sort of already implies this behavior. Reviewers: cfe-commits, klimek, arphaman Reviewed By: klimek Differential Revision: https://reviews.llvm.org/D37634 llvm-svn: 312942
* Recommit r312127: [refactor] AST selection tree should contain syntacticAlex Lorenz2017-08-301-0/+22
| | | | | | | | | | | | | | | | form of PseudoObjectExpr The new commit adjusts unittest test code compilation options so that the Objective-C code in the unittest can be parsed on non-macOS platforms. Original message: The AST selection finder now constructs a selection tree that contains only the syntactic form of PseudoObjectExpr. This form of selection tree is more meaningful when doing downstream analysis as we're interested in the syntactic features of the AST and the correct lexical parent relation. llvm-svn: 312132
* Revert r312127 as the ObjC unittest code fails to compile on LinuxAlex Lorenz2017-08-301-22/+0
| | | | llvm-svn: 312131
* [refactor] AST selection tree should contain syntactic formAlex Lorenz2017-08-301-0/+22
| | | | | | | | | | | of PseudoObjectExpr The AST selection finder now constructs a selection tree that contains only the syntactic form of PseudoObjectExpr. This form of selection tree is more meaningful when doing downstream analysis as we're interested in the syntactic features of the AST and the correct lexical parent relation. llvm-svn: 312127
* [refactor] Examine the whole range for ObjC @implementation declsAlex Lorenz2017-08-301-2/+16
| | | | | | when computing the AST selection llvm-svn: 312121
* 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
* [refactor] initial support for refactoring action rulesAlex Lorenz2017-08-282-0/+24
| | | | | | | | | | | | | | | | | | This patch implements the initial support for refactoring action rules. The first rule that's supported is a "source change" rule that returns a set of atomic changes. This patch is based on the ideas presented in my RFC: http://lists.llvm.org/pipermail/cfe-dev/2017-July/054831.html The following pieces from the RFC are added by this patch: - `createRefactoringRule` (known as `apply` in the RFC) - `requiredSelection` refactoring action rule requirement. - `selection::SourceSelectionRange` selection constraint. Differential Revision: https://reviews.llvm.org/D36075 llvm-svn: 311884
* [clang-diff] Treat CXXCtorInitializer as a nodeJohannes Altmanninger2017-08-271-26/+36
| | | | | | | | | | Reviewers: arphaman Subscribers: cfe-commits, klimek Differential Revision: https://reviews.llvm.org/D37002 llvm-svn: 311865
* [clang-diff] Remove NodeCountVisitor, NFCJohannes Altmanninger2017-08-251-35/+3
| | | | | | | | Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D37000 llvm-svn: 311770
* Add missing std::move callAlex Lorenz2017-08-241-1/+1
| | | | | | | This should fix http://green.lab.llvm.org/green/job/clang-stage1-cmake-RA-incremental_build/41578/ llvm-svn: 311656
* [refactor] Add the AST source selection componentAlex Lorenz2017-08-242-0/+192
| | | | | | | | | | | | | This commit adds the base AST source selection component to the refactoring library. AST selection is represented using a tree of SelectedASTNode values. Each selected node gets its own selection kind, which can actually be None even in the middle of tree (e.g. statement in a macro whose child is in a macro argument). The initial version constructs a "raw" selection tree, without applying filters and canonicalisation operations to the nodes. Differential Revision: https://reviews.llvm.org/D35012 llvm-svn: 311655
* [clang-diff] Fix getRelativeNameJohannes Altmanninger2017-08-221-2/+4
| | | | | | Handle the case when DeclContext is null. llvm-svn: 311434
* [clang-diff] Use the relative name for NamedDeclJohannes Altmanninger2017-08-221-16/+57
| | | | | | | | | | | | | | Summary: If a node referring to a name is within a class or namespace, do not use the full qualified name, but strip the namespace prefix. Reviewers: arphaman, bkramer Subscribers: klimek Differential Revision: https://reviews.llvm.org/D36681 llvm-svn: 311433
* [clang-diff] Improve and test getNodeValueJohannes Altmanninger2017-08-201-39/+87
| | | | | | | | | | | | Summary: Use qualified names if available. Reviewers: arphaman Subscribers: klimek Differential Revision: https://reviews.llvm.org/D36186 llvm-svn: 311292
* [clang-diff] Fix similarity computationJohannes Altmanninger2017-08-201-13/+22
| | | | | | | | | | | | | | Summary: Add separate tests for the top-down and the bottom-up phase, as well as one for the optimal matching. Reviewers: arphaman Subscribers: klimek Differential Revision: https://reviews.llvm.org/D36185 llvm-svn: 311284
* [clang-diff] Filter AST nodesJohannes Altmanninger2017-08-201-1/+16
| | | | | | | | | | | | | | Summary: Ignore macros and implicit AST nodes, as well as anything outside of the main source file. Reviewers: arphaman Subscribers: klimek Differential Revision: https://reviews.llvm.org/D36184 llvm-svn: 311280
* [clang-diff] Simplify mappingJohannes Altmanninger2017-08-191-59/+15
| | | | | | | | | | | | | | | | | | | Summary: Until we find a decent heuristic on how to choose between multiple identical trees, there is no point in supporting multiple mappings. This also enables matching of nodes with parents of different types, because there are many instances where this is appropriate. For example for and foreach statements; functions in the global or other namespaces. Reviewers: arphaman Subscribers: klimek Differential Revision: https://reviews.llvm.org/D36183 llvm-svn: 311251
* Revert "Revert "[clang-diff] Move printing of matches and changes to ↵Johannes Altmanninger2017-08-191-181/+142
| | | | | | | | | | clang-diff"" Fix build by renaming ChangeKind -> Change This reverts commit 0c78c5729f29315d7945988efd048c0cb86c07ce. llvm-svn: 311222
* Revert "Revert "[clang-diff] Move the JSON export function to clang-diff""Johannes Altmanninger2017-08-191-26/+28
| | | | | | | This reverts commit eac4c13ac9ea8f12bc049e040c7b9c8a517f54e7, the original commit *should* not have caused the build failure. llvm-svn: 311216
* Revert "[clang-diff] Move the JSON export function to clang-diff"Vlad Tsyrklevich2017-08-181-28/+26
| | | | | | This reverts commit r311199, it was causing widespread build failures. llvm-svn: 311211
* Revert "[clang-diff] Move printing of matches and changes to clang-diff"Vlad Tsyrklevich2017-08-181-143/+181
| | | | | | This reverts commit r311200, it was causing widespread build failures. llvm-svn: 311210
* [clang-diff] Move printing of matches and changes to clang-diffJohannes Altmanninger2017-08-181-181/+143
| | | | | | | | | | | | | | | Summary: This also changes the output order of the changes. Now the matches are printed in pre-order, intertwined with insertions, updates, and moves. Deletions are printed afterwards. Reviewers: arphaman Subscribers: klimek Differential Revision: https://reviews.llvm.org/D36179 llvm-svn: 311200
* [clang-diff] Move the JSON export function to clang-diffJohannes Altmanninger2017-08-181-26/+28
| | | | | | | | | | Reviewers: arphaman Subscribers: klimek Differential Revision: https://reviews.llvm.org/D36178 llvm-svn: 311199
* [clang-diff] Fix some errors and inconsistenciesJohannes Altmanninger2017-08-181-32/+25
| | | | | | | | | | | | | | | | Fix to the computation of the rightmost descendant. Prevents root nodes from being mapped if they are already mapped. This only makes a difference when we compare AST Nodes other than entire translation units, a feature which still has to be tested. Reviewers: arphaman Subscribers: klimek Differential Revision: https://reviews.llvm.org/D36176 llvm-svn: 311172
* [CommonOptionsParser] Expose ArgumentsAdjustingCompilationDatabaseJohannes Altmanninger2017-08-181-34/+23
| | | | | | | This is useful for tools such as clang-diff which do not use CommonOptionsParser due to the need for multiple compilation databases. llvm-svn: 311170
* Switch to consumeError(), since this can crash otherwise.Stephen Hines2017-08-151-1/+1
| | | | | | | | | | | | | | | | | Summary: If assertions are disabled, but LLVM_ABI_BREAKING_CHANGES is enabled, this will cause an issue with an unchecked Success. Switching to consumeError() is the correct way to bypass the check. Reviewers: llvm-commits, cfe-commits, arphaman Reviewed By: arphaman Subscribers: arphaman, klimek, pirama Differential Revision: https://reviews.llvm.org/D36728 llvm-svn: 310958
* [clang] Code cleanup in clang/toolingAlexander Shaposhnikov2017-08-151-1/+1
| | | | | | | | | 1. Add missing explicit for SymbolName constructor. 2. Add missing std::move in createRenameReplacements. Differential revision: https://reviews.llvm.org/D36715 llvm-svn: 310948
* [rename] Introduce symbol occurrencesAlex Lorenz2017-08-144-39/+108
| | | | | | | | | | | Symbol occurrences store the results of local rename and will also be used for the global, indexed rename results. Their kind is used to determine whether they should be renamed automatically or not. They can be converted to a set of AtomicChanges as well. Differential Revision: https://reviews.llvm.org/D36156 llvm-svn: 310853
* [rename] NFC, extract symbol canonicalization logic into functionAlex Lorenz2017-08-021-7/+16
| | | | | | This function will be used by the clang-refactor's rename actions llvm-svn: 309813
* [clang-diff] Renames, NFCJohannes Altmanninger2017-08-011-93/+90
| | | | llvm-svn: 309738
* [clang-diff] Move data declarations to the public headerJohannes Altmanninger2017-08-011-7/+116
| | | | llvm-svn: 309737
* Added `applyAtomicChanges` function.Eric Liu2017-07-312-4/+181
| | | | | | | | | | | | | | | | | | This re-commits r298913. o See thread http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20170327/189084.html o Tested with -DLLVM_ENABLE_LOCAL_SUBMODULE_VISIBILITY=0. Summary: ... which applies a set of `AtomicChange`s on code. Reviewers: klimek, djasper Reviewed By: djasper Subscribers: arphaman, mgorny, chapuni, cfe-commits Differential Revision: https://reviews.llvm.org/D30777 llvm-svn: 309548
* [clang-diff] Get rid of unused variable warnings in ASTDiff.cppAlex Lorenz2017-07-211-6/+4
| | | | llvm-svn: 308737
* Fix another compiler error from r308731Alex Lorenz2017-07-211-1/+1
| | | | | | | std::pair in emplace back couldn't be constructed because SNodeId has an explicit constructor. Not sure how this even compiled on my machine before. llvm-svn: 308734
OpenPOWER on IntegriCloud