[clang-tools-extra] 91670f5 - [clangd] Remove big PreambleData constructor. NFC
Sam McCall via cfe-commits
cfe-commits at lists.llvm.org
Wed Jul 21 02:32:01 PDT 2021
Author: Sam McCall
Date: 2021-07-21T11:31:52+02:00
New Revision: 91670f5f20daa00b83520b76bcb54a5d373242f3
URL: https://github.com/llvm/llvm-project/commit/91670f5f20daa00b83520b76bcb54a5d373242f3
DIFF: https://github.com/llvm/llvm-project/commit/91670f5f20daa00b83520b76bcb54a5d373242f3.diff
LOG: [clangd] Remove big PreambleData constructor. NFC
Added:
Modified:
clang-tools-extra/clangd/Preamble.cpp
clang-tools-extra/clangd/Preamble.h
Removed:
################################################################################
diff --git a/clang-tools-extra/clangd/Preamble.cpp b/clang-tools-extra/clangd/Preamble.cpp
index bc8c51bcc8588..b41bd915ea22b 100644
--- a/clang-tools-extra/clangd/Preamble.cpp
+++ b/clang-tools-extra/clangd/Preamble.cpp
@@ -312,18 +312,6 @@ bool isMainFile(llvm::StringRef FileName, const SourceManager &SM) {
} // namespace
-PreambleData::PreambleData(const ParseInputs &Inputs,
- PrecompiledPreamble Preamble,
- std::vector<Diag> Diags, IncludeStructure Includes,
- MainFileMacros Macros,
- std::unique_ptr<PreambleFileStatusCache> StatCache,
- CanonicalIncludes CanonIncludes)
- : Version(Inputs.Version), CompileCommand(Inputs.CompileCommand),
- Preamble(std::move(Preamble)), Diags(std::move(Diags)),
- Includes(std::move(Includes)), Macros(std::move(Macros)),
- StatCache(std::move(StatCache)), CanonIncludes(std::move(CanonIncludes)) {
-}
-
std::shared_ptr<const PreambleData>
buildPreamble(PathRef FileName, CompilerInvocation CI,
const ParseInputs &Inputs, bool StoreInMemory,
@@ -393,10 +381,14 @@ buildPreamble(PathRef FileName, CompilerInvocation CI,
vlog("Built preamble of size {0} for file {1} version {2}",
BuiltPreamble->getSize(), FileName, Inputs.Version);
std::vector<Diag> Diags = PreambleDiagnostics.take();
- auto Result = std::make_shared<PreambleData>(
- Inputs, std::move(*BuiltPreamble), std::move(Diags),
- CapturedInfo.takeIncludes(), CapturedInfo.takeMacros(),
- std::move(StatCache), CapturedInfo.takeCanonicalIncludes());
+ auto Result = std::make_shared<PreambleData>(std::move(*BuiltPreamble));
+ Result->Version = Inputs.Version;
+ Result->CompileCommand = Inputs.CompileCommand;
+ Result->Diags = std::move(Diags);
+ Result->Includes = CapturedInfo.takeIncludes();
+ Result->Macros = CapturedInfo.takeMacros();
+ Result->CanonIncludes = CapturedInfo.takeCanonicalIncludes();
+ Result->StatCache = std::move(StatCache);
Result->MainIsIncludeGuarded = CapturedInfo.isMainFileIncludeGuarded();
return Result;
}
diff --git a/clang-tools-extra/clangd/Preamble.h b/clang-tools-extra/clangd/Preamble.h
index fa48d6753528c..ecf10880ba7dc 100644
--- a/clang-tools-extra/clangd/Preamble.h
+++ b/clang-tools-extra/clangd/Preamble.h
@@ -47,11 +47,7 @@ namespace clangd {
/// As we must avoid re-parsing the preamble, any information that can only
/// be obtained during parsing must be eagerly captured and stored here.
struct PreambleData {
- PreambleData(const ParseInputs &Inputs, PrecompiledPreamble Preamble,
- std::vector<Diag> Diags, IncludeStructure Includes,
- MainFileMacros Macros,
- std::unique_ptr<PreambleFileStatusCache> StatCache,
- CanonicalIncludes CanonIncludes);
+ PreambleData(PrecompiledPreamble Preamble) : Preamble(std::move(Preamble)) {}
// Version of the ParseInputs this preamble was built from.
std::string Version;
More information about the cfe-commits
mailing list