@@ -154,6 +154,26 @@ void ModuleDepCollector::addOutputPaths(CowCompilerInvocation &CI,
154
154
}
155
155
}
156
156
157
+ void dependencies::resetBenignCodeGenOptions (frontend::ActionKind ProgramAction,
158
+ const LangOptions &LangOpts,
159
+ CodeGenOptions &CGOpts) {
160
+ // TODO: Figure out better way to set options to their default value.
161
+ if (ProgramAction == frontend::GenerateModule) {
162
+ CGOpts.MainFileName .clear ();
163
+ CGOpts.DwarfDebugFlags .clear ();
164
+ }
165
+ if (ProgramAction == frontend::GeneratePCH ||
166
+ (ProgramAction == frontend::GenerateModule && !LangOpts.ModulesCodegen )) {
167
+ CGOpts.DebugCompilationDir .clear ();
168
+ CGOpts.CoverageCompilationDir .clear ();
169
+ CGOpts.CoverageDataFile .clear ();
170
+ CGOpts.CoverageNotesFile .clear ();
171
+ CGOpts.ProfileInstrumentUsePath .clear ();
172
+ CGOpts.SampleProfileFile .clear ();
173
+ CGOpts.ProfileRemappingFile .clear ();
174
+ }
175
+ }
176
+
157
177
static CowCompilerInvocation
158
178
makeCommonInvocationForModuleBuild (CompilerInvocation CI) {
159
179
CI.resetNonModularOptions ();
@@ -167,18 +187,8 @@ makeCommonInvocationForModuleBuild(CompilerInvocation CI) {
167
187
// LLVM options are not going to affect the AST
168
188
CI.getFrontendOpts ().LLVMArgs .clear ();
169
189
170
- // TODO: Figure out better way to set options to their default value.
171
- CI.getCodeGenOpts ().MainFileName .clear ();
172
- CI.getCodeGenOpts ().DwarfDebugFlags .clear ();
173
- if (!CI.getLangOpts ().ModulesCodegen ) {
174
- CI.getCodeGenOpts ().DebugCompilationDir .clear ();
175
- CI.getCodeGenOpts ().CoverageCompilationDir .clear ();
176
- CI.getCodeGenOpts ().CoverageDataFile .clear ();
177
- CI.getCodeGenOpts ().CoverageNotesFile .clear ();
178
- CI.getCodeGenOpts ().ProfileInstrumentUsePath .clear ();
179
- CI.getCodeGenOpts ().SampleProfileFile .clear ();
180
- CI.getCodeGenOpts ().ProfileRemappingFile .clear ();
181
- }
190
+ resetBenignCodeGenOptions (frontend::GenerateModule, CI.getLangOpts (),
191
+ CI.getCodeGenOpts ());
182
192
183
193
// Map output paths that affect behaviour to "-" so their existence is in the
184
194
// context hash. The final path will be computed in addOutputPaths.
@@ -342,6 +352,8 @@ static bool needsModules(FrontendInputFile FIF) {
342
352
343
353
void ModuleDepCollector::applyDiscoveredDependencies (CompilerInvocation &CI) {
344
354
CI.clearImplicitModuleBuildOptions ();
355
+ resetBenignCodeGenOptions (CI.getFrontendOpts ().ProgramAction ,
356
+ CI.getLangOpts (), CI.getCodeGenOpts ());
345
357
346
358
if (llvm::any_of (CI.getFrontendOpts ().Inputs , needsModules)) {
347
359
Preprocessor &PP = ScanInstance.getPreprocessor ();
0 commit comments