-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[clang/DependencyScanning/ModuleDepCollector] Refactor part of makeCommonInvocationForModuleBuild
into its own function
#88447
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
Conversation
@llvm/pr-subscribers-clang Author: Argyrios Kyrtzidis (akyrtzi) ChangesThe function is named Full diff: https://github.com/llvm/llvm-project/pull/88447.diff 2 Files Affected:
diff --git a/clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h b/clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
index 081899cc2c8503..b971269c4983ed 100644
--- a/clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
+++ b/clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
@@ -308,6 +308,9 @@ class ModuleDepCollector final : public DependencyCollector {
ModuleDeps &Deps);
};
+/// Resets some options that introduce dependencies unnecessarily.
+void removeUnnecessaryDependencies(CompilerInvocation &CI, bool ForModuleBuild);
+
} // end namespace dependencies
} // end namespace tooling
} // end namespace clang
diff --git a/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp b/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
index 94ccbd3351b09d..fd425ff7c4cafe 100644
--- a/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
+++ b/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
@@ -154,6 +154,20 @@ void ModuleDepCollector::addOutputPaths(CowCompilerInvocation &CI,
}
}
+void dependencies::removeUnnecessaryDependencies(CompilerInvocation &CI,
+ bool ForModuleBuild) {
+ if (CI.getFrontendOpts().ProgramAction == frontend::GeneratePCH ||
+ (ForModuleBuild && !CI.getLangOpts().ModulesCodegen)) {
+ CI.getCodeGenOpts().DebugCompilationDir.clear();
+ CI.getCodeGenOpts().CoverageCompilationDir.clear();
+ CI.getCodeGenOpts().CoverageDataFile.clear();
+ CI.getCodeGenOpts().CoverageNotesFile.clear();
+ CI.getCodeGenOpts().ProfileInstrumentUsePath.clear();
+ CI.getCodeGenOpts().SampleProfileFile.clear();
+ CI.getCodeGenOpts().ProfileRemappingFile.clear();
+ }
+}
+
static CowCompilerInvocation
makeCommonInvocationForModuleBuild(CompilerInvocation CI) {
CI.resetNonModularOptions();
@@ -170,15 +184,8 @@ makeCommonInvocationForModuleBuild(CompilerInvocation CI) {
// TODO: Figure out better way to set options to their default value.
CI.getCodeGenOpts().MainFileName.clear();
CI.getCodeGenOpts().DwarfDebugFlags.clear();
- if (!CI.getLangOpts().ModulesCodegen) {
- CI.getCodeGenOpts().DebugCompilationDir.clear();
- CI.getCodeGenOpts().CoverageCompilationDir.clear();
- CI.getCodeGenOpts().CoverageDataFile.clear();
- CI.getCodeGenOpts().CoverageNotesFile.clear();
- CI.getCodeGenOpts().ProfileInstrumentUsePath.clear();
- CI.getCodeGenOpts().SampleProfileFile.clear();
- CI.getCodeGenOpts().ProfileRemappingFile.clear();
- }
+
+ removeUnnecessaryDependencies(CI, /*ForModuleBuild=*/true);
// Map output paths that affect behaviour to "-" so their existence is in the
// context hash. The final path will be computed in addOutputPaths.
|
clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
Outdated
Show resolved
Hide resolved
0344d18
to
f96eadb
Compare
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.
LGTM. I assume you'll call resetBenignCodeGenOptions()
from ModuleDepCollector::applyDiscoveredDependencies()
in a follow-up, non-NFC patch, right? (So that it applies to the primary invocation, i.e. the actual PCH.) Maybe leaving a FIXME behind would be nice, just to make the intent clear.
…ommonInvocationForModuleBuild` into its own function The new function is about clearing out benign codegen options and can be applied for PCH invocations as well.
f96eadb
to
8b21183
Compare
makeCommonInvocationForModuleBuild
into its own function, NFCmakeCommonInvocationForModuleBuild
into its own function
@jansvoboda11 see updated commit, I made the change per your suggestion. |
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.
Thanks! Still LGTM.
…ommonInvocationForModuleBuild` into its own function (llvm#88447) The new function is about clearing out benign codegen options and can be applied for PCH invocations as well.
…ommonInvocationForModuleBuild` into its own function (llvm#88447) The new function is about clearing out benign codegen options and can be applied for PCH invocations as well. (cherry picked from commit 6331024)
The new function is about clearing out benign codegen options and can be applied for PCH invocations as well.