[clang-tools-extra] r368482 - [clangd] Give absolute path to clang-tidy and include-fixer. HintPath should always be absolute, some URI schemes care.
Sam McCall via cfe-commits
cfe-commits at lists.llvm.org
Fri Aug 9 13:45:25 PDT 2019
Author: sammccall
Date: Fri Aug 9 13:45:24 2019
New Revision: 368482
URL: http://llvm.org/viewvc/llvm-project?rev=368482&view=rev
Log:
[clangd] Give absolute path to clang-tidy and include-fixer. HintPath should always be absolute, some URI schemes care.
Modified:
clang-tools-extra/trunk/clangd/ClangdUnit.cpp
Modified: clang-tools-extra/trunk/clangd/ClangdUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdUnit.cpp?rev=368482&r1=368481&r2=368482&view=diff
==============================================================================
--- clang-tools-extra/trunk/clangd/ClangdUnit.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdUnit.cpp Fri Aug 9 13:45:24 2019
@@ -304,6 +304,7 @@ ParsedAST::build(std::unique_ptr<Compile
StoreDiags ASTDiags;
std::string Content = Buffer->getBuffer();
+ std::string Filename = Buffer->getBufferIdentifier(); // Absolute.
auto Clang = prepareCompilerInstance(std::move(CI), PreamblePCH,
std::move(Buffer), VFS, ASTDiags);
@@ -329,7 +330,7 @@ ParsedAST::build(std::unique_ptr<Compile
llvm::Optional<tidy::ClangTidyContext> CTContext;
{
trace::Span Tracer("ClangTidyInit");
- dlog("ClangTidy configuration for file {0}: {1}", MainInput.getFile(),
+ dlog("ClangTidy configuration for file {0}: {1}", Filename,
tidy::configurationAsText(Opts.ClangTidyOpts));
tidy::ClangTidyCheckFactories CTFactories;
for (const auto &E : tidy::ClangTidyModuleRegistry::entries())
@@ -338,7 +339,7 @@ ParsedAST::build(std::unique_ptr<Compile
tidy::ClangTidyGlobalOptions(), Opts.ClangTidyOpts));
CTContext->setDiagnosticsEngine(&Clang->getDiagnostics());
CTContext->setASTContext(&Clang->getASTContext());
- CTContext->setCurrentFile(MainInput.getFile());
+ CTContext->setCurrentFile(Filename);
CTFactories.createChecks(CTContext.getPointer(), CTChecks);
ASTDiags.setLevelAdjuster([&CTContext](DiagnosticsEngine::Level DiagLevel,
const clang::Diagnostic &Info) {
@@ -385,15 +386,15 @@ ParsedAST::build(std::unique_ptr<Compile
llvm::Optional<IncludeFixer> FixIncludes;
auto BuildDir = VFS->getCurrentWorkingDirectory();
if (Opts.SuggestMissingIncludes && Index && !BuildDir.getError()) {
- auto Style = getFormatStyleForFile(MainInput.getFile(), Content, VFS.get());
+ auto Style = getFormatStyleForFile(Filename, Content, VFS.get());
auto Inserter = std::make_shared<IncludeInserter>(
- MainInput.getFile(), Content, Style, BuildDir.get(),
+ Filename, Content, Style, BuildDir.get(),
&Clang->getPreprocessor().getHeaderSearchInfo());
if (Preamble) {
for (const auto &Inc : Preamble->Includes.MainFileIncludes)
Inserter->addExisting(Inc);
}
- FixIncludes.emplace(MainInput.getFile(), Inserter, *Index,
+ FixIncludes.emplace(Filename, Inserter, *Index,
/*IndexRequestLimit=*/5);
ASTDiags.contributeFixes([&FixIncludes](DiagnosticsEngine::Level DiagLevl,
const clang::Diagnostic &Info) {
More information about the cfe-commits
mailing list