summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clangd/IncludeFixer.cpp
Commit message (Collapse)AuthorAgeFilesLines
* NFC: Fix trivial typos in commentsKazuaki Ishizaki2020-01-041-2/+2
|
* [clangd] Simplify the callside of URI::resolve, NFC.Haojian Wu2019-09-231-4/+2
| | | | | | | | | | | | | | | | Summary: - Add a overrloded URI::resolve, which accepts a string URI; - also fixed some callside that don't check the error; Reviewers: kadircet Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D67916 llvm-svn: 372617
* [clangd] Compute scopes eagerly in IncludeFixerIlya Biryukov2019-08-061-34/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Computing lazily leads to crashes. In particular, computing scopes may produce diagnostics (from inside template instantiations) and we currently do it when processing another diagnostic, which leads to crashes. Moreover, we remember and access 'Scope*' when computing scopes. This might lead to invalid memory access if the Scope is deleted by the time we run the delayed computation. We did not actually construct an example when this happens, though. From the VCS and review history, it seems the optimization was introduced in the initial version without a mention of any performance benchmarks justifying the performance gains. This led me to a conclusion that the optimization was premature, so removing it to avoid crashes seems like the right trade-off at that point. Reviewers: sammccall Reviewed By: sammccall Subscribers: MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D65796 llvm-svn: 368019
* [clangd] cleanup: unify the implemenation of checking a location is inside ↵Haojian Wu2019-07-191-1/+1
| | | | | | | | | | | | | | | | main file. Summary: We have variant implementations in the codebase, this patch unifies them. Reviewers: ilya-biryukov, kadircet Subscribers: MaskRay, jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D64915 llvm-svn: 366541
* [clangd] Don't insert absolute paths, give up instead.Sam McCall2019-07-081-1/+5
| | | | | | | | | | | | | | Summary: Also implement resolution of paths relative to mainfile without HeaderSearchInfo. Reviewers: kadircet Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D64293 llvm-svn: 365364
* [clang][HeaderSearch] Shorten paths for includes in mainfile's directoryKadir Cetinkaya2019-07-031-2/+1
| | | | | | | | | | | | | | | | | | Summary: Currently HeaderSearch only looks at SearchDir's passed into it, but in addition to those paths headers can be relative to including file's directory. This patch makes sure that is taken into account. Reviewers: gribozavr Subscribers: jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D63295 llvm-svn: 365005
* [clangd] Check file path of declaring header when deciding whether to insert ↵Eric Liu2019-04-161-5/+7
| | | | | | | | | | | | | | | | | | | include. Summary: Previously, we would use include spelling of the declaring header to check whether the inserted header is the same as the main file. This doesn't help because we only have file path of the main file. Reviewers: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D60687 llvm-svn: 358496
* Moved Ref into its own header and implementation fileDmitri Gribenko2019-02-281-0/+1
| | | | | | | | | | | | Reviewers: ioeric Subscribers: mgorny, jkorous, mgrang, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D58778 llvm-svn: 355090
* Moved Symbol into its own header and implementation fileDmitri Gribenko2019-02-281-0/+1
| | | | | | | | | | | | Reviewers: ioeric Subscribers: mgorny, jkorous, arphaman, kadircet, jdoerfert, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D58774 llvm-svn: 355088
* [clangd] Handle another incomplete-type diagnostic case in IncludeFixer.Eric Liu2019-02-211-0/+1
| | | | llvm-svn: 354558
* [clangd] Handle unresolved scope specifier when fixing includes.Eric Liu2019-02-191-37/+140
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: In the following examples, "clangd" is unresolved, and the fixer will try to fix include for `clang::clangd`; however, clang::clangd::X is usually intended. So when handling a qualifier that is unresolved, we change the unresolved name and scopes so that the fixer will fix "clang::clangd::X" in the following example. ``` namespace clang { clangd::X ~~~~~~ } // or clang::clangd::X ~~~~~~ ``` Reviewers: sammccall Reviewed By: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, jdoerfert, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D58185 llvm-svn: 354330
* [clangd] Cache include fixes for diagnostics caused by the same unresolved ↵Eric Liu2019-02-181-20/+62
| | | | | | | | | | | | | | | | | | | | | | name or incomplete type. Summary: Multiple diagnostics can be caused by the same unresolved name or incomplete type, especially if the code is copy-pasted without #includes. The cache can avoid making repetitive index requests, and thus reduce latency and allow more diagnostics to be fixed (we limit the number of index requests for each parse). Reviewers: sammccall Reviewed By: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, jdoerfert, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D58239 llvm-svn: 354268
* [clangd] Handle a few more diag kinds in include fixer.Eric Liu2019-02-131-0/+6
| | | | | | | | | | | | Reviewers: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D58135 llvm-svn: 353926
* [clangd] Fix an assertion in TypoCorrection.Eric Liu2019-02-081-6/+7
| | | | | | | | | | | | | | Summary: https://github.com/clangd/clangd/issues/7 Reviewers: sammccall, hokein Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D57944 llvm-svn: 353514
* [clangd] Suggest adding missing includes for typos (like include-fixer).Eric Liu2019-02-071-14/+198
| | | | | | | | | | | | | | | | | | | Summary: This adds include-fixer feature into clangd based on D56903. Clangd now captures diagnostics caused by typos and attach include insertion fixes to potentially fix the typo. Reviewers: sammccall Reviewed By: sammccall Subscribers: cfe-commits, kadircet, arphaman, mgrang, jkorous, MaskRay, javed.absar, ilya-biryukov, mgorny Tags: #clang Differential Revision: https://reviews.llvm.org/D57021 llvm-svn: 353380
* [clangd] Suggest adding missing includes for incomplete type diagnostics.Eric Liu2019-01-281-0/+113
Summary: This enables clangd to intercept compiler diagnostics and attach fixes (e.g. by querying index). This patch adds missing includes for incomplete types e.g. member access into class with only forward declaration. This would allow adding missing includes for user-typed symbol names that are missing declarations (e.g. typos) in the future. Reviewers: sammccall Reviewed By: sammccall Subscribers: mgorny, ilya-biryukov, javed.absar, MaskRay, jkorous, mgrang, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D56903 llvm-svn: 352361
OpenPOWER on IntegriCloud