[PATCH] D56860: [clangd] NFC: Use buildCompilerInvocation in CodeComplete
Kadir Cetinkaya via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Jan 17 08:51:04 PST 2019
kadircet created this revision.
kadircet added a reviewer: ilya-biryukov.
Herald added subscribers: cfe-commits, arphaman, jkorous, MaskRay, ioeric.
Repository:
rCTE Clang Tools Extra
https://reviews.llvm.org/D56860
Files:
clangd/CodeComplete.cpp
Index: clangd/CodeComplete.cpp
===================================================================
--- clangd/CodeComplete.cpp
+++ clangd/CodeComplete.cpp
@@ -1017,25 +1017,11 @@
const SemaCompleteInput &Input,
IncludeStructure *Includes = nullptr) {
trace::Span Tracer("Sema completion");
- std::vector<const char *> ArgStrs;
- for (const auto &S : Input.Command.CommandLine)
- ArgStrs.push_back(S.c_str());
-
- if (Input.VFS->setCurrentWorkingDirectory(Input.Command.Directory)) {
- log("Couldn't set working directory");
- // We run parsing anyway, our lit-tests rely on results for non-existing
- // working dirs.
- }
-
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS = Input.VFS;
if (Input.Preamble && Input.Preamble->StatCache)
VFS = Input.Preamble->StatCache->getConsumingFS(std::move(VFS));
- IgnoreDiagnostics DummyDiagsConsumer;
- auto CI = createInvocationFromCommandLine(
- ArgStrs,
- CompilerInstance::createDiagnostics(new DiagnosticOptions,
- &DummyDiagsConsumer, false),
- VFS);
+ auto CI =
+ buildCompilerInvocation(ParseInputs{Input.Command, VFS, Input.Contents});
if (!CI) {
elog("Couldn't create CompilerInvocation");
return false;
@@ -1073,6 +1059,7 @@
*Offset;
// NOTE: we must call BeginSourceFile after prepareCompilerInstance. Otherwise
// the remapped buffers do not get freed.
+ IgnoreDiagnostics DummyDiagsConsumer;
auto Clang = prepareCompilerInstance(
std::move(CI),
(Input.Preamble && !CompletingInPreamble) ? &Input.Preamble->Preamble
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D56860.182305.patch
Type: text/x-patch
Size: 1655 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190117/d509b29c/attachment.bin>
More information about the cfe-commits
mailing list