summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/unittests/include-fixer
Commit message (Collapse)AuthorAgeFilesLines
* Rename directory housing clang-include-fixer to be eponymousNico Weber2019-03-255-1065/+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-193-12/+9
| | | | | | | | | | | | | | | | | 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
* Add explicit dependency on clangSerialization after rC348911Fangrui Song2018-12-122-0/+2
| | | | llvm-svn: 348916
* Lift VFS from clang to llvm (NFC)Jonas Devlieghere2018-10-102-5/+5
| | | | | | | | | | | | | | | | | | | 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
* [CMake] Use PRIVATE in target_link_libraries for executablesShoaib Meenai2017-12-052-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We currently use target_link_libraries without an explicit scope specifier (INTERFACE, PRIVATE or PUBLIC) when linking executables. Dependencies added in this way apply to both the target and its dependencies, i.e. they become part of the executable's link interface and are transitive. Transitive dependencies generally don't make sense for executables, since you wouldn't normally be linking against an executable. This also causes issues for generating install export files when using LLVM_DISTRIBUTION_COMPONENTS. For example, clang has a lot of LLVM library dependencies, which are currently added as interface dependencies. If clang is in the distribution components but the LLVM libraries it depends on aren't (which is a perfectly legitimate use case if the LLVM libraries are being built static and there are therefore no run-time dependencies on them), CMake will complain about the LLVM libraries not being in export set when attempting to generate the install export file for clang. This is reasonable behavior on CMake's part, and the right thing is for LLVM's build system to explicitly use PRIVATE dependencies for executables. Unfortunately, CMake doesn't allow you to mix and match the keyword and non-keyword target_link_libraries signatures for a single target; i.e., if a single call to target_link_libraries for a particular target uses one of the INTERFACE, PRIVATE, or PUBLIC keywords, all other calls must also be updated to use those keywords. This means we must do this change in a single shot. I also fully expect to have missed some instances; I tested by enabling all the projects in the monorepo (except dragonegg), and configuring both with and without shared libraries, on both Darwin and Linux, but I'm planning to rely on the buildbots for other configurations (since it should be pretty easy to fix those). Even after this change, we still have a lot of target_link_libraries calls that don't specify a scope keyword, mostly for shared libraries. I'm thinking about addressing those in a follow-up, but that's a separate change IMO. Differential Revision: https://reviews.llvm.org/D40823 llvm-svn: 319840
* [include-fixer] Add fuzzy SymbolIndex, where identifier needn't match exactly.Sam McCall2017-03-132-0/+62
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Add fuzzy SymbolIndex, where identifier needn't match exactly. The purpose for this is global autocomplete in clangd. The query will be a partial identifier up to the cursor, and the results will be suggestions. It's in include-fixer because: - it handles SymbolInfos, actually SymbolIndex is exactly the right interface - it's a good harness for lit testing the fuzzy YAML index - (Laziness: we can't unit test clangd until reorganizing with a tool/ dir) Other questionable choices: - FuzzySymbolIndex, which just refines the contract of SymbolIndex. This is an interface to allow extension to large monorepos (*cough*) - an always-true safety check that Identifier == Name is removed from SymbolIndexManager, as it's not true for fuzzy matching - exposing -db=fuzzyYaml from include-fixer is not a very useful feature, and a non-orthogonal ui (fuzziness vs data source). -db=fixed is similar though. Reviewers: bkramer Subscribers: cfe-commits, mgorny Differential Revision: https://reviews.llvm.org/D30720 llvm-svn: 297630
* [include-fixer] Remove line number from Symbol identitySam McCall2017-03-092-166/+158
| | | | | | | | | | | | | | | | | | | 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-282-82/+194
| | | | | | | | | | | | | | | | | | | | | | | 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
* [find-all-symbols] Index partial template specializations.Haojian Wu2017-01-111-0/+22
| | | | | | | | | | | | | | | Summary: Fix no std::function index. Previously, we don't index all the template specialization declarations of functions and classes (Because we assume that template functions/classes are indexed by their template declarations), but this is not always true in some cases like `std::function` which only has a partial template specialization declaration. Reviewers: ioeric, bkramer Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D27920 llvm-svn: 291669
* [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] 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
* [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
* IncludeFixerTests: Update libdeps.NAKAMURA Takumi2016-05-311-0/+1
| | | | llvm-svn: 271295
* [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
* [find-all-symbols] Added hardcode header mapping from header postfix to ↵Eric Liu2016-05-241-43/+18
| | | | | | | | | | | | | | header name for STL symbols. Summary: [find-all-symbols] Added hardcode header mapping from header postfix to header name for STL symbols. Reviewers: klimek, bkramer Subscribers: cfe-commits, hokein Differential Revision: http://reviews.llvm.org/D20566 llvm-svn: 270566
* [find-all-symbols] Some cleanups in unittest.Haojian Wu2016-05-201-6/+0
| | | | llvm-svn: 270211
* [find-all-symbol] Ignore inline namespace context.Haojian Wu2016-05-201-1/+6
| | | | | | | | | | Reviewers: bkramer Subscribers: cfe-commits, ioeric Differential Revision: http://reviews.llvm.org/D20465 llvm-svn: 270206
* [find-all-symbol] Try to fix the failure windows unittest.Haojian Wu2016-05-201-1/+7
| | | | llvm-svn: 270199
* [find-all-symbols] make HeaderMapCollector optional in FindAllSymbols and ↵Eric Liu2016-05-201-1/+1
| | | | | | FindAllMacros. llvm-svn: 270193
* [find-all-symbol] Add macro support.Haojian Wu2016-05-201-11/+52
| | | | | | | | | | Reviewers: bkramer Subscribers: cfe-commits, ioeric Differential Revision: http://reviews.llvm.org/D20420 llvm-svn: 270189
* [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
* FindAllSymbolsTests doesn't require clangToolingCore.NAKAMURA Takumi2016-05-181-1/+0
| | | | llvm-svn: 269874
OpenPOWER on IntegriCloud