Skip to content

Commit

Permalink
[clang][deps] Skip writing DIAG_PRAGMA_MAPPINGS record (#70874)
Browse files Browse the repository at this point in the history
Following up on #69975, this patch skips writing `DIAG_PRAGMA_MAPPINGS`
as well. Deserialization of this PCM record is still showing up in
profiles, since it needs to be VBR-decoded for every transitively loaded
PCM file.

The scanner doesn't make any guarantees about diagnostic accuracy (and
it even disables all warnings), so skipping this record should be safe.
  • Loading branch information
jansvoboda11 committed Nov 10, 2023
1 parent 8391f40 commit 22c6851
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
8 changes: 7 additions & 1 deletion clang/include/clang/Lex/HeaderSearchOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,11 @@ class HeaderSearchOptions {
LLVM_PREFERRED_TYPE(bool)
unsigned ModulesSkipHeaderSearchPaths : 1;

/// Whether to entirely skip writing pragma diagnostic mappings.
/// Primarily used to speed up deserialization during dependency scanning.
LLVM_PREFERRED_TYPE(bool)
unsigned ModulesSkipPragmaDiagnosticMappings : 1;

LLVM_PREFERRED_TYPE(bool)
unsigned ModulesHashContent : 1;

Expand All @@ -270,7 +275,8 @@ class HeaderSearchOptions {
ForceCheckCXX20ModulesInputFiles(false), UseDebugInfo(false),
ModulesValidateDiagnosticOptions(true),
ModulesSkipDiagnosticOptions(false),
ModulesSkipHeaderSearchPaths(false), ModulesHashContent(false),
ModulesSkipHeaderSearchPaths(false),
ModulesSkipPragmaDiagnosticMappings(false), ModulesHashContent(false),
ModulesStrictContextHash(false) {}

/// AddPath - Add the \p Path path to the specified \p Group list.
Expand Down
4 changes: 2 additions & 2 deletions clang/lib/Serialization/ASTWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1261,8 +1261,8 @@ void ASTWriter::writeUnhashedControlBlock(Preprocessor &PP,
Stream.EmitRecord(HEADER_SEARCH_PATHS, Record);
}

// Write out the diagnostic/pragma mappings.
WritePragmaDiagnosticMappings(Diags, /* isModule = */ WritingModule);
if (!HSOpts.ModulesSkipPragmaDiagnosticMappings)
WritePragmaDiagnosticMappings(Diags, /* isModule = */ WritingModule);

// Header search entry usage.
auto HSEntryUsage = PP.getHeaderSearchInfo().computeUserEntryUsage();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,8 @@ class DependencyScanningAction : public tooling::ToolAction {
ScanInstance.getHeaderSearchOpts().ModulesStrictContextHash = true;
ScanInstance.getHeaderSearchOpts().ModulesSkipDiagnosticOptions = true;
ScanInstance.getHeaderSearchOpts().ModulesSkipHeaderSearchPaths = true;
ScanInstance.getHeaderSearchOpts().ModulesSkipPragmaDiagnosticMappings =
true;

// Avoid some checks and module map parsing when loading PCM files.
ScanInstance.getPreprocessorOpts().ModulesCheckRelocated = false;
Expand Down

0 comments on commit 22c6851

Please sign in to comment.