summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/unittests
Commit message (Collapse)AuthorAgeFilesLines
...
* [clang-move] Add header guard for the new header.Haojian Wu2016-10-141-2/+5
| | | | | | | | | | | | | | | | | | Summary: The header guard generated by clang-move isn't always a perfect style, just avoid getting the header included multiple times during compiling period. Also, we can use llvm-Header-guard clang-tidy check to correct the guard automatically. Reviewers: ioeric Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D25610 llvm-svn: 284233
* [clang-tidy] Fix readability-braces-around-statements false positiveMarek Kurdej2016-10-141-16/+30
| | | | | | | | | | | | | | | | | Summary: This fixes a false-positive e.g. when string literals are returned from if statement. This patch includes as well a small fix to includes and renames of the test suite that collided with the name of the check. Reviewers: alexfh, hokein Subscribers: hokein Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D25558 llvm-svn: 284212
* Recommit r283538 "[clang-move] Support moving multiple classes in one run."Haojian Wu2016-10-131-4/+4
| | | | llvm-svn: 284109
* [change-namespace] don't miss comments in the beginning of a namespace block.Eric Liu2016-10-121-0/+32
| | | | | | | | | | Reviewers: hokein Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D25397 llvm-svn: 284011
* Revert "[ClangTidy] Add UsingInserter and NamespaceAliaser"Haojian Wu2016-10-122-239/+0
| | | | | | This reverts commit r283981. This patch breaks the buildbot. llvm-svn: 283985
* [ClangTidy] Add UsingInserter and NamespaceAliaserHaojian Wu2016-10-122-0/+239
| | | | | | | | | | | | | | | | Summary: This adds helper classes to add using declaractions and namespace aliases to function bodies. These help making function calls to deeply nested functions concise (e.g. when calling helpers in a refactoring) Patch by Julian Bangert! Reviewers: alexfh, hokein Subscribers: cfe-commits Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D24997 llvm-svn: 283981
* Revert "[clang-move] Support moving multiple classes in one run."Renato Golin2016-10-071-4/+4
| | | | | | | | | | | This reverts commit r283526 et al as it keeps randomly breaking bots, even after the commit has gone, on other people's commit ranges. Revert "[clang-move] Simplify lint tests" (r283545). Revert "Fix buildbot error." (r283534). Revert "Revert "fix buildbot error" since it is not right fix." (r283538). llvm-svn: 283553
* [clang-move] Support moving multiple classes in one run.Haojian Wu2016-10-071-4/+4
| | | | | | | | | | Reviewers: ioeric Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D25309 llvm-svn: 283526
* [clang-move] Move comments which are associated with the moved class.Haojian Wu2016-10-061-9/+41
| | | | | | | | | | Reviewers: ioeric Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D25227 llvm-svn: 283425
* [clang-move] Cleanup around replacements.Haojian Wu2016-10-061-1/+1
| | | | | | | | | | | | | | Summary: cleanup the remaining empty namespace after moving out the class defintitions. Reviewers: ioeric Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D25282 llvm-svn: 283424
* [change-namespace] Fixed a bug in getShortestQualifiedNameInNamespace.Eric Liu2016-10-051-0/+18
| | | | | | | | | | Reviewers: hokein Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D25065 llvm-svn: 283333
* [change-namespace] Fix a misplaced case when there is no trailing newline ↵Haojian Wu2016-10-041-0/+21
| | | | | | | | | | | | character at the end of the file. Reviewers: ioeric Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D25226 llvm-svn: 283210
* [clang-move] Make it support both relative and absolute file path arguments.Haojian Wu2016-10-041-2/+5
| | | | | | | | | | Reviewers: ioeric Subscribers: beanz, mgorny, cfe-commits Differential Revision: https://reviews.llvm.org/D24922 llvm-svn: 283202
* [change-namespace] fix namespace specifier of global variables.Eric Liu2016-09-301-0/+66
| | | | | | | | | | Reviewers: hokein Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D24963 llvm-svn: 282837
* Workaround ASTMatcher crashes. Added some more test cases.Eric Liu2016-09-271-2/+98
| | | | | | | | | | | | | | | Summary: - UsingDecl matcher crashed when `UsingShadowDecl` has no parent map. Workaround by moving parent check into `UsingDecl`. - FunctionDecl matcher crashed when there is a lambda defined in parameter list (also due to no parent map). Workaround by putting `unless(cxxMethodDecl())` before parent check. Reviewers: klimek, sbenza, aaron.ballman, hokein Subscribers: aaron.ballman, cfe-commits Differential Revision: https://reviews.llvm.org/D24862 llvm-svn: 282486
* [clang-move] The new.cc file should include new_header.h instead of old_header.hHaojian Wu2016-09-231-4/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Previously, all #includes (includeing old_header.h) in old.cc will be copied to new.cc, however, the new.cc should include new_header.h instead of the old_header.h Before applying the patch, the new.cc looks like: ``` #include "old_header.h" ... ``` The new.cc looks like with this patch: ``` #include "new_header" ... ``` Reviewers: ioeric Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D24828 llvm-svn: 282247
* [change-namespace] fix qualifier of function references.Eric Liu2016-09-221-0/+37
| | | | | | | | | | Reviewers: hokein Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D24803 llvm-svn: 282146
* Fix compiler warnings.Haojian Wu2016-09-211-3/+3
| | | | llvm-svn: 282074
* [change-namespace] fix name qualifiers in UsingShadowDecl and ↵Eric Liu2016-09-211-0/+85
| | | | | | | | | | | | NestedNameSpecifier. Reviewers: hokein Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D24784 llvm-svn: 282073
* [clang-move] A prototype tool for moving class definition to new file.Haojian Wu2016-09-213-0/+255
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This patch introduces a new tool which moves a specific class definition from files (.h, .cc) to new files (.h, .cc), which mostly acts like "Extract class defintion". In the long term, this tool should be merged in to clang-refactoring as a subtool. clang-move not only moves class definition, but also moves all the forward declarations, functions defined in anonymous namespace and #include headers to new files, to make sure the new files are compliable as much as possible. To move `Foo` from old.[h/cc] to new.[h/cc], use: ``` clang-move -name=Foo -old_header=old.h -old_cc=old.cc -new_header=new.h -new_cc=new.cc old.cc ``` To move `Foo` from old.h to new.h, use: ``` clang-move -name=Foo -old_header=old.h -new_header=new.h old.cc ``` Reviewers: klimek, djasper, ioeric Subscribers: mgorny, beanz, Eugene.Zelenko, bkramer, omtcyfz, cfe-commits Differential Revision: https://reviews.llvm.org/D24243 llvm-svn: 282070
* A clang tool for changing surrouding namespaces of class/function definitions.Eric Liu2016-09-193-0/+263
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: A tool for changing surrouding namespaces of class/function definitions while keeping references to types in the changed namespace correctly qualified by prepending namespace specifiers before them. Example: test.cc namespace na { class X {}; namespace nb { class Y { X x; }; } // namespace nb } // namespace na To move the definition of class Y from namespace "na::nb" to "x::y", run: clang-change-namespace --old_namespace "na::nb" \ --new_namespace "x::y" --file_pattern "test.cc" test.cc -- Output: namespace na { class X {}; } // namespace na namespace x { namespace y { class Y { na::X x; }; } // namespace y } // namespace x Reviewers: alexfh, omtcyfz, hokein Subscribers: mgorny, klimek, djasper, beanz, alexshap, Eugene.Zelenko, cfe-commits Differential Revision: https://reviews.llvm.org/D24183 llvm-svn: 281918
* [clang-rename] Merge rename-{at|all} & optimise.Kirill Bobyrev2016-09-163-109/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | Having both rename-at and rename-all both seems confusing and introduces unneeded difficulties. After merging rename-at and rename-all maintaining main function wrappers and custom help becomes redundant while CLI becomes less confusing. D24224 (which was the original patch causing buildbot failures) wasn't aware of bugs caused by passing both -offset and -qualified-name. After D24224 was landed it caused buildbot failures and therefor I just reverted it. Two things that make this patch different from D24224 are: * unittests/clang-rename was deleted, because it is unmaintained and doesn't do much. * Passing both `-offset` and `-qualified-name` isn't allowed anymore for the sake of preventing bugs. This patch is a trivial enhancement of accepted D24224 revision. Tested with `ninja check-all`. Differential Revision: https://reviews.llvm.org/D24567 llvm-svn: 281710
* [clang-tidy] Merge ExtraArgs(Before) instead of overriding them.Alexander Kornienko2016-08-231-0/+33
| | | | | | Added proper tests. llvm-svn: 279519
* [include-fixer] Support processing multiple files in one run.Haojian Wu2016-08-091-5/+5
| | | | | | | | | | | | | | | | | | | Summary: Previously, if we pass multiple files or a file pattern (e.g. /path/to/*.cc) to include-fixer, include-fixer will apply all replacements to the first argument, which probably causes crashes. With this patch, include-fixer can process multiple files now. Vim and Emacs integration are tested manually. Reviewers: bkramer Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D23266 llvm-svn: 278102
* Fix clang-tidy crash when a single fix is applied on multiple files.Eric Liu2016-08-091-7/+10
| | | | | | | | | | | | | | | Summary: tooling::Replacements only holds replacements for a single file, so this patch makes Fix a map from file paths to tooling::Replacements so that it can be applied on multiple files. Reviewers: hokein, alexfh Subscribers: Prazek, cfe-commits Differential Revision: https://reviews.llvm.org/D23257 llvm-svn: 278101
* [clang-tidy] misc-argument-comment non-strict modeAlexander Kornienko2016-08-041-2/+2
| | | | | | | | | | | | | | | | | Summary: The misc-argument-comment check now ignores leading and trailing underscores and case. The new `StrictMode` local/global option can be used to switch back to strict checking. Add getLocalOrGlobal version for integral types, minor cleanups. Reviewers: hokein, aaron.ballman Subscribers: aaron.ballman, Prazek, cfe-commits Differential Revision: https://reviews.llvm.org/D23135 llvm-svn: 277729
* [include-fixer] Correct nested class search for identifiers with scoped ↵Haojian Wu2016-08-021-1/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | information Summary: include-fixer will firstly try to use scoped namespace context information to search identifier. However, in some cases, it's unsafe to do nested class search, because it might treat the identifier as a nested class of scoped namespace. Given the following code, and the symbol database only has two classes: "foo" and "b::Bar". namespace foo { Bar t; } Before getting fixing, include-fixer will never search "Bar" symbol. Because it firstly tries to search "foo::Bar", there is no "Bar" in foo namespace, then it finds "foo" in database finally. So it treats "Bar" is a nested class of "foo". Reviewers: bkramer Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D23023 llvm-svn: 277442
* Changes related to new implementation of tooling::Replacements as class.Eric Liu2016-08-011-1/+8
| | | | | | | | | | | | Summary: See http://reviews.llvm.org/D21748 for details. Reviewers: djasper, klimek Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D21749 llvm-svn: 277336
* [include-fixer] Don't add qualifiers in missing complete type cases.Haojian Wu2016-07-261-0/+5
| | | | | | | | | | | | Summary: In missing complete type cases, we don't know where to add the qualifiers. Reviewers: bkramer Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D22812 llvm-svn: 276761
* ClangRenameTests: Update libdeps.NAKAMURA Takumi2016-07-221-0/+1
| | | | llvm-svn: 276445
* [include-fixer] Add mising qualifiers to all instances of an unidentified ↵Haojian Wu2016-07-211-7/+67
| | | | | | | | | | | | symbol. Reviewers: bkramer Subscribers: ioeric, cfe-commits Differential Revision: https://reviews.llvm.org/D22567 llvm-svn: 276280
* ClangRenameTests: Update libdeps. r275958 introduced clangASTMatchers.NAKAMURA Takumi2016-07-191-0/+1
| | | | llvm-svn: 275985
* [include-fixer] Always add as few as possible qualifiers to the unidentified ↵Haojian Wu2016-07-151-0/+8
| | | | | | | | | | | | symbol. Reviewers: bkramer Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D22367 llvm-svn: 275542
* [include-fixer] Correct an incorrecst judgement about prefix scoped qualifiers.Haojian Wu2016-07-141-2/+9
| | | | | | | | | | | | | | | Summary: The judgement that checks whether the fully-qualified name has scoped qualifiers prefix is incorrect. Should always check whether the first matched postion is the beginning position. Reviewers: bkramer Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D22343 llvm-svn: 275386
* [include-fixer] Implement adding missing namespace qualifiers in vim ↵Haojian Wu2016-07-131-4/+5
| | | | | | | | | | | | | | | | | integration. Summary: The patch extends include-fixer's "-output-headers", and "-insert-headers" command line options to make it dump more information (e.g. QualifiedSymbol), so that vim-integration can add missing qualifiers. Reviewers: bkramer Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D22299 llvm-svn: 275279
* Changes related to tooling::applyAllReplacements interface change in D21601.Eric Liu2016-07-112-6/+16
| | | | | | | | | | | | | | | Summary: this patch contains changes related to the interface change from http://reviews.llvm.org/D21601. Only submit this patch after D21601 is submitted. Reviewers: djasper, klimek Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D21602 llvm-svn: 275063
* [include-fixer] Don't add qualifiers to symbols which have global scope ↵Haojian Wu2016-07-081-7/+7
| | | | | | | | | | | | operator. Reviewers: bkramer Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D22127 llvm-svn: 274848
* [include-fixer] Add missing namespace qualifiers after inserting a missing ↵Haojian Wu2016-07-081-13/+48
| | | | | | | | | | | | | | | | | | | | | | | header. Summary: This is an initial version of fixing namespace issues by adding missing namespace qualifiers to an unidentified symbol. This version only fixes the first discovered unidentified symbol. In the long run, include-fixer should fix all unidentified symbols with a same name at one run. Currently, it works on command-line tool. The vim integration is not implemented yet. Reviewers: klimek, bkramer, djasper Subscribers: bkramer, ioeric, cfe-commits Differential Revision: http://reviews.llvm.org/D21603 llvm-svn: 274832
* [include-fixer] reduce stack size by changing RegexHeaderMap to use const ↵Eric Liu2016-07-041-1/+1
| | | | | | char * pair. llvm-svn: 274501
* [include-fixer] make HeaderMapCollector maps from regex instead of postfix.Eric Liu2016-07-041-5/+6
| | | | | | | | | | | | | | Summary: this enables us to map a group of headers to one header name, e.g. headers from one directory can be mapped to the same header. Reviewers: bkramer Subscribers: cfe-commits, hokein Differential Revision: http://reviews.llvm.org/D21787 llvm-svn: 274494
* Fix build of ClangRenameTestsMiklos Vajna2016-06-211-1/+1
| | | | | | Adapt the test to the code change introduced in r273304. llvm-svn: 273314
* [clang-apply-replacements] use Range::operator==() instead of self-defined ↵Eric Liu2016-06-211-3/+1
| | | | | | operator. llvm-svn: 273291
* [include-fixer] only deduplicate symbols after matching symbols with the ↵Eric Liu2016-06-131-7/+19
| | | | | | | | | | | | | | | | | | undefined identifier. Summary: we should only deduplicate symbols after matching symbols with the undefined identifier. This patch tries to fix the situation where matching symbols are deleted when it has the same header as a non-matching symbol, which can prevent finding the correct header even if there is a matched symbol. Reviewers: bkramer Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D21290 llvm-svn: 272576
* [include-fixer] do not index friend function declaration.Eric Liu2016-06-091-0/+21
| | | | | | | | | | | | | | | Summary: we want to exclude friend declaration, but the `DeclContext` of a friend function declaration is not the class in which it is declared, so we need to explicitly check if the parent is a `friendDecl`. Reviewers: bkramer Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D21175 llvm-svn: 272261
* [include-fixer] Keep dot dot in SymbolInfo file paths.Haojian Wu2016-06-081-1/+1
| | | | | | | | | | | | | | | | | | Summary: Currently, removing dot dot in header's path doesn't make include-fixer minimize path correctly in some cases, for example, specify a relative search path based on the build directory("-I../include/"). Besides, removing dot dot can break symbolic link directories. So don't removing it for now. Reviewers: ioeric, bkramer Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D21132 llvm-svn: 272152
* [include-fixer] do not add enum forward declaration into symbol index table.Eric Liu2016-06-081-0/+5
| | | | llvm-svn: 272132
* [include-fixer] Don't add missing header if the unindentified symbol isn't ↵Haojian Wu2016-06-031-0/+7
| | | | | | | | | | | | | | | | from the main file. Summary: The further solution is to add the missing header to the file where the symbol comes from. Reviewers: bkramer Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D20950 llvm-svn: 271660
* [include-fixer] use includer of .inc header to be the file path of a symbol ↵Eric Liu2016-06-011-2/+13
| | | | | | | | | | | | | | from .inc header. Summary: added PathConfig.cpp and use includer of .inc header to be the file path of a symbol from .inc header. Reviewers: bkramer Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D20855 llvm-svn: 271385
* [include-fixer] disable path cleaning test for windows and mingw.Eric Liu2016-05-311-5/+8
| | | | llvm-svn: 271321
* [find-all-symbols] remove dots in SymbolInfo file paths.Eric Liu2016-05-311-1/+16
| | | | | | | | | | | | Summary: remove dots in SymbolInfo file paths. Reviewers: bkramer, klimek Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D20819 llvm-svn: 271302
OpenPOWER on IntegriCloud