Skip to content

Commit ca6743d

Browse files
committed
[clang][deps] Skip writing DIAG_PRAGMA_MAPPINGS record (llvm#70874)
Following up on llvm#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. (cherry picked from commit 22c6851)
1 parent e435b08 commit ca6743d

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

clang/include/clang/Lex/HeaderSearchOptions.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,10 @@ class HeaderSearchOptions {
224224
/// Primarily used to speed up deserialization during dependency scanning.
225225
unsigned ModulesSkipHeaderSearchPaths : 1;
226226

227+
/// Whether to entirely skip writing pragma diagnostic mappings.
228+
/// Primarily used to speed up deserialization during dependency scanning.
229+
unsigned ModulesSkipPragmaDiagnosticMappings : 1;
230+
227231
unsigned ModulesHashContent : 1;
228232

229233
/// Whether we should include all things that could impact the module in the
@@ -244,7 +248,8 @@ class HeaderSearchOptions {
244248
ValidateASTInputFilesContent(false), UseDebugInfo(false),
245249
ModulesValidateDiagnosticOptions(true),
246250
ModulesSkipDiagnosticOptions(false),
247-
ModulesSkipHeaderSearchPaths(false), ModulesHashContent(false),
251+
ModulesSkipHeaderSearchPaths(false),
252+
ModulesSkipPragmaDiagnosticMappings(false), ModulesHashContent(false),
248253
ModulesStrictContextHash(false) {}
249254

250255
/// AddPath - Add the \p Path path to the specified \p Group list.

clang/lib/Serialization/ASTWriter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1267,8 +1267,8 @@ void ASTWriter::writeUnhashedControlBlock(Preprocessor &PP,
12671267
AddString(FSOpts.WorkingDir, Record);
12681268
Stream.EmitRecord(FILE_SYSTEM_OPTIONS, Record);
12691269

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

12731273
// Header search entry usage.
12741274
auto HSEntryUsage = PP.getHeaderSearchInfo().computeUserEntryUsage();

clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,8 @@ class DependencyScanningAction : public tooling::ToolAction {
436436
ScanInstance.getHeaderSearchOpts().ModulesStrictContextHash = true;
437437
ScanInstance.getHeaderSearchOpts().ModulesSkipDiagnosticOptions = true;
438438
ScanInstance.getHeaderSearchOpts().ModulesSkipHeaderSearchPaths = true;
439+
ScanInstance.getHeaderSearchOpts().ModulesSkipPragmaDiagnosticMappings =
440+
true;
439441

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

0 commit comments

Comments
 (0)