-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[clang][deps] Skip slow UNHASHED_CONTROL_BLOCK
records
#69975
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
5dd9d64
[clang][modules] Make `DIAGNOSTIC_OPTIONS` skippable
jansvoboda11 69d3645
[clang][modules] Make `HEADER_SEARCH_PATHS` skippable
jansvoboda11 3ce52bf
[clang][deps] Skip `DIAGNOSTIC_OPTIONS` and `HEADER_SEARCH_PATHS`
jansvoboda11 7be1ff5
Add -fmodules-skip-header-search-paths test, run clang-format
jansvoboda11 8811663
Note new options are for the scanner
jansvoboda11 6283999
Fix test on Windows
jansvoboda11 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1212,52 +1212,54 @@ void ASTWriter::writeUnhashedControlBlock(Preprocessor &PP, | |
Record.clear(); | ||
} | ||
|
||
const auto &HSOpts = PP.getHeaderSearchInfo().getHeaderSearchOpts(); | ||
|
||
// Diagnostic options. | ||
const auto &Diags = Context.getDiagnostics(); | ||
const DiagnosticOptions &DiagOpts = Diags.getDiagnosticOptions(); | ||
if (!HSOpts.ModulesSkipDiagnosticOptions) { | ||
jansvoboda11 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
#define DIAGOPT(Name, Bits, Default) Record.push_back(DiagOpts.Name); | ||
#define ENUM_DIAGOPT(Name, Type, Bits, Default) \ | ||
Record.push_back(static_cast<unsigned>(DiagOpts.get##Name())); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
#include "clang/Basic/DiagnosticOptions.def" | ||
Record.push_back(DiagOpts.Warnings.size()); | ||
for (unsigned I = 0, N = DiagOpts.Warnings.size(); I != N; ++I) | ||
AddString(DiagOpts.Warnings[I], Record); | ||
Record.push_back(DiagOpts.Remarks.size()); | ||
for (unsigned I = 0, N = DiagOpts.Remarks.size(); I != N; ++I) | ||
AddString(DiagOpts.Remarks[I], Record); | ||
// Note: we don't serialize the log or serialization file names, because they | ||
// are generally transient files and will almost always be overridden. | ||
Stream.EmitRecord(DIAGNOSTIC_OPTIONS, Record); | ||
Record.clear(); | ||
Record.push_back(DiagOpts.Warnings.size()); | ||
for (unsigned I = 0, N = DiagOpts.Warnings.size(); I != N; ++I) | ||
AddString(DiagOpts.Warnings[I], Record); | ||
Record.push_back(DiagOpts.Remarks.size()); | ||
for (unsigned I = 0, N = DiagOpts.Remarks.size(); I != N; ++I) | ||
AddString(DiagOpts.Remarks[I], Record); | ||
// Note: we don't serialize the log or serialization file names, because | ||
// they are generally transient files and will almost always be overridden. | ||
Stream.EmitRecord(DIAGNOSTIC_OPTIONS, Record); | ||
Record.clear(); | ||
} | ||
|
||
// Header search paths. | ||
Record.clear(); | ||
const HeaderSearchOptions &HSOpts = | ||
PP.getHeaderSearchInfo().getHeaderSearchOpts(); | ||
|
||
// Include entries. | ||
Record.push_back(HSOpts.UserEntries.size()); | ||
for (unsigned I = 0, N = HSOpts.UserEntries.size(); I != N; ++I) { | ||
const HeaderSearchOptions::Entry &Entry = HSOpts.UserEntries[I]; | ||
AddString(Entry.Path, Record); | ||
Record.push_back(static_cast<unsigned>(Entry.Group)); | ||
Record.push_back(Entry.IsFramework); | ||
Record.push_back(Entry.IgnoreSysRoot); | ||
} | ||
if (!HSOpts.ModulesSkipHeaderSearchPaths) { | ||
// Include entries. | ||
Record.push_back(HSOpts.UserEntries.size()); | ||
for (unsigned I = 0, N = HSOpts.UserEntries.size(); I != N; ++I) { | ||
const HeaderSearchOptions::Entry &Entry = HSOpts.UserEntries[I]; | ||
AddString(Entry.Path, Record); | ||
Record.push_back(static_cast<unsigned>(Entry.Group)); | ||
Record.push_back(Entry.IsFramework); | ||
Record.push_back(Entry.IgnoreSysRoot); | ||
} | ||
|
||
// System header prefixes. | ||
Record.push_back(HSOpts.SystemHeaderPrefixes.size()); | ||
for (unsigned I = 0, N = HSOpts.SystemHeaderPrefixes.size(); I != N; ++I) { | ||
AddString(HSOpts.SystemHeaderPrefixes[I].Prefix, Record); | ||
Record.push_back(HSOpts.SystemHeaderPrefixes[I].IsSystemHeader); | ||
} | ||
// System header prefixes. | ||
Record.push_back(HSOpts.SystemHeaderPrefixes.size()); | ||
for (unsigned I = 0, N = HSOpts.SystemHeaderPrefixes.size(); I != N; ++I) { | ||
AddString(HSOpts.SystemHeaderPrefixes[I].Prefix, Record); | ||
Record.push_back(HSOpts.SystemHeaderPrefixes[I].IsSystemHeader); | ||
} | ||
|
||
// VFS overlay files. | ||
Record.push_back(HSOpts.VFSOverlayFiles.size()); | ||
for (StringRef VFSOverlayFile : HSOpts.VFSOverlayFiles) | ||
AddString(VFSOverlayFile, Record); | ||
// VFS overlay files. | ||
Record.push_back(HSOpts.VFSOverlayFiles.size()); | ||
for (StringRef VFSOverlayFile : HSOpts.VFSOverlayFiles) | ||
AddString(VFSOverlayFile, Record); | ||
|
||
Stream.EmitRecord(HEADER_SEARCH_PATHS, Record); | ||
Stream.EmitRecord(HEADER_SEARCH_PATHS, Record); | ||
} | ||
|
||
// Write out the diagnostic/pragma mappings. | ||
WritePragmaDiagnosticMappings(Diags, /* isModule = */ WritingModule); | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// RUN: rm -rf %t && mkdir -p %t | ||
// RUN: split-file %s %t | ||
|
||
//--- module.modulemap | ||
module Mod { header "mod.h" } | ||
//--- mod.h | ||
//--- tu.c | ||
#include "mod.h" | ||
|
||
// Without any extra compiler flags, mismatched diagnostic options trigger recompilation of modules. | ||
// | ||
// RUN: %clang_cc1 -fmodules -fmodule-map-file=%t/module.modulemap -fmodules-cache-path=%t/cache1 -fdisable-module-hash \ | ||
// RUN: -fsyntax-only %t/tu.c -Wnon-modular-include-in-module | ||
// RUN: %clang_cc1 -fmodules -fmodule-map-file=%t/module.modulemap -fmodules-cache-path=%t/cache1 -fdisable-module-hash \ | ||
// RUN: -fsyntax-only %t/tu.c -Werror=non-modular-include-in-module -Rmodule-build 2>&1 \ | ||
// RUN: | FileCheck %s --check-prefix=DID-REBUILD | ||
// DID-REBUILD: remark: building module 'Mod' | ||
|
||
// When skipping serialization of diagnostic options, mismatches cannot be detected, old PCM file gets reused. | ||
// | ||
// RUN: %clang_cc1 -fmodules -fmodule-map-file=%t/module.modulemap -fmodules-cache-path=%t/cache2 -fdisable-module-hash \ | ||
// RUN: -fsyntax-only %t/tu.c -fmodules-skip-diagnostic-options -Wnon-modular-include-in-module | ||
// RUN: %clang_cc1 -fmodules -fmodule-map-file=%t/module.modulemap -fmodules-cache-path=%t/cache2 -fdisable-module-hash \ | ||
// RUN: -fsyntax-only %t/tu.c -fmodules-skip-diagnostic-options -Werror=non-modular-include-in-module -Rmodule-build 2>&1 \ | ||
// RUN: | FileCheck %s --check-prefix=DID-REUSE --allow-empty | ||
// DID-REUSE-NOT: remark: building module 'Mod' | ||
// | ||
// RUN: %clang_cc1 -module-file-info %t/cache2/Mod.pcm | FileCheck %s --check-prefix=NO-DIAG-OPTS | ||
// NO-DIAG-OPTS-NOT: Diagnostic flags: | ||
|
||
// When disabling validation of diagnostic options, mismatches are not checked for, old PCM file gets reused. | ||
// | ||
// RUN: %clang_cc1 -fmodules -fmodule-map-file=%t/module.modulemap -fmodules-cache-path=%t/cache3 -fdisable-module-hash \ | ||
// RUN: -fsyntax-only %t/tu.c -fmodules-disable-diagnostic-validation -Wnon-modular-include-in-module | ||
// RUN: %clang_cc1 -fmodules -fmodule-map-file=%t/module.modulemap -fmodules-cache-path=%t/cache3 -fdisable-module-hash \ | ||
// RUN: -fsyntax-only %t/tu.c -fmodules-disable-diagnostic-validation -Werror=non-modular-include-in-module -Rmodule-build 2>&1 \ | ||
// RUN: | FileCheck %s --check-prefix=DID-REUSE --allow-empty | ||
// | ||
// RUN: %clang_cc1 -module-file-info %t/cache3/Mod.pcm | FileCheck %s --check-prefix=OLD-DIAG-OPTS | ||
// OLD-DIAG-OPTS: Diagnostic flags: | ||
// OLD-DIAG-OPTS-NEXT: -Wnon-modular-include-in-module |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// RUN: rm -rf %t && mkdir -p %t | ||
// RUN: split-file %s %t | ||
|
||
//--- module.modulemap | ||
module Mod { header "mod.h" } | ||
//--- mod.h | ||
//--- tu.c | ||
#include "mod.h" | ||
|
||
//--- one/foo.h | ||
//--- two/foo.h | ||
|
||
// By default, mismatched header search paths are ignored, old PCM file gets reused. | ||
// | ||
// RUN: %clang_cc1 -fmodules -fmodule-map-file=%t/module.modulemap -fmodules-cache-path=%t/cache1 -fdisable-module-hash \ | ||
// RUN: -fsyntax-only %t/tu.c -I %t/one | ||
// RUN: %clang_cc1 -fmodules -fmodule-map-file=%t/module.modulemap -fmodules-cache-path=%t/cache1 -fdisable-module-hash \ | ||
// RUN: -fsyntax-only %t/tu.c -I %t/two -Rmodule-build 2>&1 \ | ||
// RUN: | FileCheck %s --allow-empty --check-prefix=DID-REUSE | ||
// DID-REUSE-NOT: remark: building module 'Mod' | ||
// | ||
// RUN: %clang_cc1 -module-file-info %t/cache1/Mod.pcm | FileCheck %s --check-prefix=HS-PATHS | ||
// HS-PATHS: Header search paths: | ||
// HS-PATHS-NEXT: User entries: | ||
// HS-PATHS-NEXT: one | ||
|
||
// When skipping serialization of header search paths, mismatches cannot be detected, old PCM file gets reused. | ||
// | ||
// RUN: %clang_cc1 -fmodules -fmodule-map-file=%t/module.modulemap -fmodules-cache-path=%t/cache2 -fdisable-module-hash \ | ||
// RUN: -fsyntax-only %t/tu.c -fmodules-skip-header-search-paths -I %t/one | ||
// RUN: %clang_cc1 -fmodules -fmodule-map-file=%t/module.modulemap -fmodules-cache-path=%t/cache2 -fdisable-module-hash \ | ||
// RUN: -fsyntax-only %t/tu.c -fmodules-skip-header-search-paths -I %t/two -Rmodule-build 2>&1 \ | ||
// RUN: | FileCheck %s --check-prefix=DID-REUSE --allow-empty | ||
// | ||
// RUN: %clang_cc1 -module-file-info %t/cache2/Mod.pcm | FileCheck %s --check-prefix=NO-HS-PATHS | ||
// NO-HS-PATHS-NOT: Header search paths: |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.