diff options
| author | Haojian Wu <hokein@google.com> | 2018-04-09 15:09:44 +0000 |
|---|---|---|
| committer | Haojian Wu <hokein@google.com> | 2018-04-09 15:09:44 +0000 |
| commit | e9a5a2f10ca1d04fbf06b50dcb052711b8ddb1e7 (patch) | |
| tree | 472e3ff946f416405d10bd79acabc8507c5aac36 /clang-tools-extra/clangd/URI.cpp | |
| parent | 935474fef57d9bf57cd7faca0deb1f2b0ce3e8c3 (diff) | |
| download | bcm5719-llvm-e9a5a2f10ca1d04fbf06b50dcb052711b8ddb1e7.tar.gz bcm5719-llvm-e9a5a2f10ca1d04fbf06b50dcb052711b8ddb1e7.zip | |
[clangd] Allow using customized include path in URI.
Summary:
Calculating the include path from absolute file path does not always
work for all build system, e.g. bazel uses symlink as the build working
directory. The absolute file path from editor and clang is diverged from
each other. We need to address it properly in build sysmtem integration.
This patch worksarounds the issue by providing a hook in URI which allows
clients to provide their customized include path.
Reviewers: sammccall
Subscribers: klimek, ilya-biryukov, jkorous-apple, ioeric, MaskRay, cfe-commits
Differential Revision: https://reviews.llvm.org/D45426
llvm-svn: 329578
Diffstat (limited to 'clang-tools-extra/clangd/URI.cpp')
| -rw-r--r-- | clang-tools-extra/clangd/URI.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/clang-tools-extra/clangd/URI.cpp b/clang-tools-extra/clangd/URI.cpp index c0e10cef173..a722640890d 100644 --- a/clang-tools-extra/clangd/URI.cpp +++ b/clang-tools-extra/clangd/URI.cpp @@ -196,5 +196,12 @@ llvm::Expected<std::string> URI::resolve(const URI &Uri, return S->get()->getAbsolutePath(Uri.Authority, Uri.Body, HintPath); } +llvm::Expected<std::string> URI::includeSpelling(const URI &Uri) { + auto S = findSchemeByName(Uri.Scheme); + if (!S) + return S.takeError(); + return S->get()->getIncludeSpelling(Uri); +} + } // namespace clangd } // namespace clang |

