Skip to content

Commit 91670f5

Browse files
committedJul 21, 2021
[clangd] Remove big PreambleData constructor. NFC
1 parent 44c9adb commit 91670f5

File tree

2 files changed

+9
-21
lines changed

2 files changed

+9
-21
lines changed
 

‎clang-tools-extra/clangd/Preamble.cpp

+8-16
Original file line numberDiff line numberDiff line change
@@ -312,18 +312,6 @@ bool isMainFile(llvm::StringRef FileName, const SourceManager &SM) {
312312

313313
} // namespace
314314

315-
PreambleData::PreambleData(const ParseInputs &Inputs,
316-
PrecompiledPreamble Preamble,
317-
std::vector<Diag> Diags, IncludeStructure Includes,
318-
MainFileMacros Macros,
319-
std::unique_ptr<PreambleFileStatusCache> StatCache,
320-
CanonicalIncludes CanonIncludes)
321-
: Version(Inputs.Version), CompileCommand(Inputs.CompileCommand),
322-
Preamble(std::move(Preamble)), Diags(std::move(Diags)),
323-
Includes(std::move(Includes)), Macros(std::move(Macros)),
324-
StatCache(std::move(StatCache)), CanonIncludes(std::move(CanonIncludes)) {
325-
}
326-
327315
std::shared_ptr<const PreambleData>
328316
buildPreamble(PathRef FileName, CompilerInvocation CI,
329317
const ParseInputs &Inputs, bool StoreInMemory,
@@ -393,10 +381,14 @@ buildPreamble(PathRef FileName, CompilerInvocation CI,
393381
vlog("Built preamble of size {0} for file {1} version {2}",
394382
BuiltPreamble->getSize(), FileName, Inputs.Version);
395383
std::vector<Diag> Diags = PreambleDiagnostics.take();
396-
auto Result = std::make_shared<PreambleData>(
397-
Inputs, std::move(*BuiltPreamble), std::move(Diags),
398-
CapturedInfo.takeIncludes(), CapturedInfo.takeMacros(),
399-
std::move(StatCache), CapturedInfo.takeCanonicalIncludes());
384+
auto Result = std::make_shared<PreambleData>(std::move(*BuiltPreamble));
385+
Result->Version = Inputs.Version;
386+
Result->CompileCommand = Inputs.CompileCommand;
387+
Result->Diags = std::move(Diags);
388+
Result->Includes = CapturedInfo.takeIncludes();
389+
Result->Macros = CapturedInfo.takeMacros();
390+
Result->CanonIncludes = CapturedInfo.takeCanonicalIncludes();
391+
Result->StatCache = std::move(StatCache);
400392
Result->MainIsIncludeGuarded = CapturedInfo.isMainFileIncludeGuarded();
401393
return Result;
402394
}

‎clang-tools-extra/clangd/Preamble.h

+1-5
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,7 @@ namespace clangd {
4747
/// As we must avoid re-parsing the preamble, any information that can only
4848
/// be obtained during parsing must be eagerly captured and stored here.
4949
struct PreambleData {
50-
PreambleData(const ParseInputs &Inputs, PrecompiledPreamble Preamble,
51-
std::vector<Diag> Diags, IncludeStructure Includes,
52-
MainFileMacros Macros,
53-
std::unique_ptr<PreambleFileStatusCache> StatCache,
54-
CanonicalIncludes CanonIncludes);
50+
PreambleData(PrecompiledPreamble Preamble) : Preamble(std::move(Preamble)) {}
5551

5652
// Version of the ParseInputs this preamble was built from.
5753
std::string Version;

0 commit comments

Comments
 (0)
Please sign in to comment.