[clangd] Remove big PreambleData constructor. NFC

This commit is contained in:
Sam McCall 2021-07-21 11:31:52 +02:00
parent 44c9adb414
commit 91670f5f20
2 changed files with 9 additions and 21 deletions

View File

@ -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;
}

View File

@ -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;