summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/unittests/include-fixer/IncludeFixerTest.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Rename directory housing clang-include-fixer to be eponymousNico Weber2019-03-251-371/+0
| | | | | | | | | | | Makes the name of this directory consistent with the names of the other directories in clang-tools-extra. Similar to r356254. No intended behavior change. Differential Revision: https://reviews.llvm.org/D59750 llvm-svn: 356897
* 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
* Lift VFS from clang to llvm (NFC)Jonas Devlieghere2018-10-101-2/+2
| | | | | | | | | | | | | | | | | | | 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
* Fix tests after changes to clang-format in r330573.Manuel Klimek2018-04-231-8/+10
| | | | | | | | | | We do now both: - stop reformatting a sequence after a closing brace in more cases, in order to not misindent after an incorrect closing brace - format the closing brace when formatting the line containing the opening brace llvm-svn: 330580
* [include-fixer] Remove line number from Symbol identitySam McCall2017-03-091-11/+11
| | | | | | | | | | | | | | | | | | | Summary: Remove line number from Symbol identity. For our purposes (include-fixer and clangd autocomplete), function overloads within the same header should mostly be treated as a single combined symbol. We may want to track individual occurrences (line number, full type info) and aggregate this during mapreduce, but that's not done here. Reviewers: hokein, bkramer Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D30685 llvm-svn: 297371
* [include-fixer] Add usage count to find-all-symbols.Sam McCall2017-02-281-40/+47
| | | | | | | | | | | | | | | | | | | | | | | Summary: Add usage count to find-all-symbols. FindAllSymbols now finds (most!) main-file usages of the discovered symbols. The per-TU map output has NumUses=0 or 1 (only one use per file is counted). The reducer aggregates these to find the number of files that use a symbol. The NumOccurrences is now set to 1 in the mapper rather than being inferred by the reducer, for consistency. The idea here is to use NumUses for ranking: intuitively number of files that use a symbol is more meaningful than number of files that include the header. Reviewers: hokein, bkramer Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D30210 llvm-svn: 296446
* [include-fixer] Load symbol index asynchronously.Benjamin Kramer2017-01-091-2/+3
| | | | | | | | We don't actually need the index until parse time, so fetch it in the background and start parsing. By the time it is actually needed it's likely that the loading phase has completed in the background. llvm-svn: 291446
* [include-fixer] Desugar incomplete types.Benjamin Kramer2016-12-161-0/+4
| | | | | | | | This will look through typedefs so include-fixer will look up the target of the typedef instead of the typedef itself (which is already in scope). llvm-svn: 289952
* Fix a buildbot failure in include-fixer.Eric Liu2016-12-021-7/+4
| | | | llvm-svn: 288495
* [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
* [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
* [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
* [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
* [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-111-5/+8
| | | | | | | | | | | | | | | 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] 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] 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 clang-format cleaner to insert header.Eric Liu2016-05-311-20/+23
| | | | | | | | | | | | Summary: clang-format's cleanupAroundReplacements() takes care of header insertions. Reviewers: bkramer Subscribers: cfe-commits, hokein Differential Revision: http://reviews.llvm.org/D20816 llvm-svn: 271287
* [include-fixer] use tooling::Replacements since the order of replacements ↵Eric Liu2016-05-311-6/+6
| | | | | | | | | | don't matter anymore. Summary: [include-fixer] use tooling::Replacements since the order of replacements don't matter anymore. Differential Revision: http://reviews.llvm.org/D20813 llvm-svn: 271279
* [include-fixer] Create a mode in vim integration to show multiple potential ↵Haojian Wu2016-05-311-4/+9
| | | | | | | | | | | | | | | | | | | headers. Summary: Some changes in the patch: * Add two commandline flags in clang-include-fixer. * Introduce a IncludeFixerContext for the queried symbol. * Pull out CreateReplacementsForHeader. Reviewers: bkramer Subscribers: klimek, cfe-commits, ioeric Differential Revision: http://reviews.llvm.org/D20621 llvm-svn: 271258
* [include-fixer] Make search handle fully qualified names correctly.Benjamin Kramer2016-05-191-0/+6
| | | | | | | | | If a search string starts with "::" we don't want to return any results for suffixes of that string. Differential Revision: http://reviews.llvm.org/D20424 llvm-svn: 270055
* [include-fixer] Remove obsolete windows hack.Benjamin Kramer2016-05-191-4/+2
| | | | llvm-svn: 270045
* [include-fixer] Sort headers after inserting new headers.Eric Liu2016-05-191-23/+41
| | | | | | | | | | | | Summary: [include-fixer] Sort headers after inserting new headers. Reviewers: bkramer Subscribers: klimek, djasper, hokein, cfe-commits Differential Revision: http://reviews.llvm.org/D20370 llvm-svn: 270031
* [include-fixer] Also look up prefixes of queries.Benjamin Kramer2016-05-181-3/+0
| | | | | | | | | | | | This is used to find nested classes. For a nested name foo::bar::qux we will first look up foo::bar::qux, then foo::bar, then foo unless we find a result. This is used to support nested classes which are not part of the index but can only be used if the header for the parent context is included. Differential Revision: http://reviews.llvm.org/D20372 llvm-svn: 269956
* [include-fixer] Run tests with -fno-ms-compatibility.Benjamin Kramer2016-05-181-4/+3
| | | | | | | Something behind that flag makes us get fewer typo correction callbacks, unbreak the tests on windows for now. llvm-svn: 269894
* [include-fixer] Ignore non-scoped enum declaration during search.Haojian Wu2016-05-181-0/+10
| | | | | | | | | | Reviewers: bkramer Subscribers: cfe-commits, ioeric Differential Revision: http://reviews.llvm.org/D20354 llvm-svn: 269890
* IncludeFixerTest.cpp: Add explicit triple for some tests. They are failing ↵NAKAMURA Takumi2016-05-181-2/+4
| | | | | | for targeting *-win32. llvm-svn: 269870
* [include-fixer] Make the "extend to the right" hack support typos without ↵Benjamin Kramer2016-05-171-1/+11
| | | | | | | | nested names in the front. This handles cases where the initial namespace is unknown. llvm-svn: 269758
* [include-fixer] Use scope contexts information to improve query.Haojian Wu2016-05-131-0/+17
| | | | | | | | | | Reviewers: bkramer Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D20205 llvm-svn: 269430
* [include-fixer] Simplify unittest code.Haojian Wu2016-05-131-8/+14
| | | | | | | | | | | | | | | Summary: The InMemorySymbolIndex only constructs hard-coded Class symbols from a string map. The patch provide a flexable way in InMemorySymbolIndex to create a custom SymbolInfo in the include-fixer unittest. Reviewers: bkramer Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D20232 llvm-svn: 269427
* [include-fixer] Rename XrefsDB to SymbolIndex.Benjamin Kramer2016-05-131-8/+10
| | | | | | It's not really containing xrefs so the name didn't fit. No functional change. llvm-svn: 269403
* Disable IncludeFixerTests/IncludeFixer.NestedName for now. It doesn't pass ↵NAKAMURA Takumi2016-05-101-0/+3
| | | | | | for targeting win32. Investigating. llvm-svn: 269135
* [include-fixer] Work around partial names in both directions.Benjamin Kramer2016-05-101-0/+6
| | | | | | | | | | | | We already handled the case where we had a nested name specifier where parts from the beginning don't get a callback, also handle the case where the end doesn't get a callback. This happens with function calls in unknown namespaces. The way we do this for now based on character data is a bit of a hack, we may need to refine this later or fix clang to produce different callbacks. llvm-svn: 269029
* [include-fixer] For now, only add the first suggested include.Benjamin Kramer2016-05-101-0/+6
| | | | | | | | We used a std::set which made the picked include somewhat random (well, lexicographically sorted). Make the behavior more consistent by always picking the first one we found. llvm-svn: 269028
* Added XrefsDBManager into include-fixer and made XrefsDB return SymbolInfo.Eric Liu2016-05-041-5/+10
| | | | | | | | | | | | Summary: Added XrefsDBManager into include-fixer and made XrefsDB return SymbolInfo. Reviewers: hokein, djasper, klimek Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D19869 llvm-svn: 268480
* [include-fixer] Add an option to minimize include paths.Benjamin Kramer2016-04-281-11/+38
| | | | | | | This will always pick the shortest possible path based on -I options. Based on the #include suggestion code for modules. llvm-svn: 267868
* IncludeFixerTest.cpp: Tweak not to assume clang-tools-extra were onto ↵NAKAMURA Takumi2016-04-201-1/+1
| | | | | | clang/tools/extra. llvm-svn: 266874
* [include-fixer] Add a prototype for a new include fixing tool.Benjamin Kramer2016-04-201-0/+87
Summary: The goal of this tool is fairly simple, look up unknown identifiers in a global database and add the corresponding #include line. It accomplishes this by hooking into Sema as an ExternalSemaSource and responding to typo correction callbacks. This means we can see the unknown identifier before it's being munged by error recovery. This doesn't work perfectly yet as some typo corrections don't emit callbacks (delayed typos), but I think this is fixable. We also handle only one include at a time as this is meant to be run directly from the editing environment eventually. Adding multiple includes at the same time is tricky because of error recovery. This version only has a a dummy database, so all you can do is fixing missing includes of <string>, but the indexer to build a database will follow soon. Reviewers: djasper Subscribers: ioeric, hokein, cfe-commits Differential Revision: http://reviews.llvm.org/D19314 llvm-svn: 266870
OpenPOWER on IntegriCloud