-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
[clang] NFCI: Mutate HeaderSearchOptions
earlier
#130823
Conversation
@llvm/pr-subscribers-clang Author: Jan Svoboda (jansvoboda11) ChangesI would like to ensure that Full diff: https://github.com/llvm/llvm-project/pull/130823.diff 3 Files Affected:
diff --git a/clang/include/clang/Lex/HeaderSearchOptions.h b/clang/include/clang/Lex/HeaderSearchOptions.h
index 7a16926c186d2..68308f5693ac6 100644
--- a/clang/include/clang/Lex/HeaderSearchOptions.h
+++ b/clang/include/clang/Lex/HeaderSearchOptions.h
@@ -235,6 +235,7 @@ class HeaderSearchOptions {
/// Whether to entirely skip writing diagnostic options.
/// Primarily used to speed up deserialization during dependency scanning.
+ /// FIXME: Consider moving these into separate `SerializationOptions` class.
LLVM_PREFERRED_TYPE(bool)
unsigned ModulesSkipDiagnosticOptions : 1;
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp
index 4eb743acf327f..34821d9f8dd30 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -4964,6 +4964,12 @@ bool CompilerInvocation::CreateFromArgsImpl(
llvm::Triple T(Res.getTargetOpts().Triple);
ParseHeaderSearchArgs(Res.getHeaderSearchOpts(), Args, Diags,
Res.getFileSystemOpts().WorkingDir);
+ if (Res.getFrontendOpts().GenReducedBMI ||
+ Res.getFrontendOpts().ProgramAction ==
+ frontend::GenerateReducedModuleInterface) {
+ Res.getHeaderSearchOpts().ModulesSkipDiagnosticOptions = true;
+ Res.getHeaderSearchOpts().ModulesSkipHeaderSearchPaths = true;
+ }
ParseAPINotesArgs(Res.getAPINotesOpts(), Args, Diags);
ParsePointerAuthArgs(LangOpts, Args, Diags);
diff --git a/clang/lib/Serialization/GeneratePCH.cpp b/clang/lib/Serialization/GeneratePCH.cpp
index 12751beb8d715..512d5050d6520 100644
--- a/clang/lib/Serialization/GeneratePCH.cpp
+++ b/clang/lib/Serialization/GeneratePCH.cpp
@@ -120,13 +120,6 @@ Module *CXX20ModulesGenerator::getEmittingModule(ASTContext &Ctx) {
}
void CXX20ModulesGenerator::HandleTranslationUnit(ASTContext &Ctx) {
- // FIMXE: We'd better to wrap such options to a new class ASTWriterOptions
- // since this is not about searching header really.
- HeaderSearchOptions &HSOpts =
- getPreprocessor().getHeaderSearchInfo().getHeaderSearchOpts();
- HSOpts.ModulesSkipDiagnosticOptions = true;
- HSOpts.ModulesSkipHeaderSearchPaths = true;
-
PCHGenerator::HandleTranslationUnit(Ctx);
if (!isComplete())
|
@llvm/pr-subscribers-clang-modules Author: Jan Svoboda (jansvoboda11) ChangesI would like to ensure that Full diff: https://github.com/llvm/llvm-project/pull/130823.diff 3 Files Affected:
diff --git a/clang/include/clang/Lex/HeaderSearchOptions.h b/clang/include/clang/Lex/HeaderSearchOptions.h
index 7a16926c186d2..68308f5693ac6 100644
--- a/clang/include/clang/Lex/HeaderSearchOptions.h
+++ b/clang/include/clang/Lex/HeaderSearchOptions.h
@@ -235,6 +235,7 @@ class HeaderSearchOptions {
/// Whether to entirely skip writing diagnostic options.
/// Primarily used to speed up deserialization during dependency scanning.
+ /// FIXME: Consider moving these into separate `SerializationOptions` class.
LLVM_PREFERRED_TYPE(bool)
unsigned ModulesSkipDiagnosticOptions : 1;
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp
index 4eb743acf327f..34821d9f8dd30 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -4964,6 +4964,12 @@ bool CompilerInvocation::CreateFromArgsImpl(
llvm::Triple T(Res.getTargetOpts().Triple);
ParseHeaderSearchArgs(Res.getHeaderSearchOpts(), Args, Diags,
Res.getFileSystemOpts().WorkingDir);
+ if (Res.getFrontendOpts().GenReducedBMI ||
+ Res.getFrontendOpts().ProgramAction ==
+ frontend::GenerateReducedModuleInterface) {
+ Res.getHeaderSearchOpts().ModulesSkipDiagnosticOptions = true;
+ Res.getHeaderSearchOpts().ModulesSkipHeaderSearchPaths = true;
+ }
ParseAPINotesArgs(Res.getAPINotesOpts(), Args, Diags);
ParsePointerAuthArgs(LangOpts, Args, Diags);
diff --git a/clang/lib/Serialization/GeneratePCH.cpp b/clang/lib/Serialization/GeneratePCH.cpp
index 12751beb8d715..512d5050d6520 100644
--- a/clang/lib/Serialization/GeneratePCH.cpp
+++ b/clang/lib/Serialization/GeneratePCH.cpp
@@ -120,13 +120,6 @@ Module *CXX20ModulesGenerator::getEmittingModule(ASTContext &Ctx) {
}
void CXX20ModulesGenerator::HandleTranslationUnit(ASTContext &Ctx) {
- // FIMXE: We'd better to wrap such options to a new class ASTWriterOptions
- // since this is not about searching header really.
- HeaderSearchOptions &HSOpts =
- getPreprocessor().getHeaderSearchInfo().getHeaderSearchOpts();
- HSOpts.ModulesSkipDiagnosticOptions = true;
- HSOpts.ModulesSkipHeaderSearchPaths = true;
-
PCHGenerator::HandleTranslationUnit(Ctx);
if (!isComplete())
|
if (Res.getFrontendOpts().GenReducedBMI || | ||
Res.getFrontendOpts().ProgramAction == | ||
frontend::GenerateReducedModuleInterface) { | ||
Res.getHeaderSearchOpts().ModulesSkipDiagnosticOptions = true; | ||
Res.getHeaderSearchOpts().ModulesSkipHeaderSearchPaths = true; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this actually have the same semantics? These appear to always be true
for GenerateModuleInterfaceAction
regardless of reduced BMI or not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, the semantics probably changed. All tests passed locally on macOS, though 🤔 @ChuanqiXu9, can you clarify what the intent is?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ping @ChuanqiXu9.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this looks good now. Also nice in general to not mess with options after argument parsing.
This PR makes the `HeaderSearchOptions` object referenced by `HeaderSearch` constant. Depends on #130823.
I would like to ensure that
CompilerInvocation
and its constituents are not mutated late during the compilation. This PR moves adjustment of theHeaderSearchOptions::ModulesSkip{DiagnosticOptions,HeaderSearchPaths}
bits from somewhere deep in the serialization library intoCompilerInvocation::CreateFromArgs()
.