@@ -160,6 +160,26 @@ void ModuleDepCollector::addOutputPaths(CowCompilerInvocation &CI,
160
160
}
161
161
}
162
162
163
+ void dependencies::resetBenignCodeGenOptions (frontend::ActionKind ProgramAction,
164
+ const LangOptions &LangOpts,
165
+ CodeGenOptions &CGOpts) {
166
+ // TODO: Figure out better way to set options to their default value.
167
+ if (ProgramAction == frontend::GenerateModule) {
168
+ CGOpts.MainFileName .clear ();
169
+ CGOpts.DwarfDebugFlags .clear ();
170
+ }
171
+ if (ProgramAction == frontend::GeneratePCH ||
172
+ (ProgramAction == frontend::GenerateModule && !LangOpts.ModulesCodegen )) {
173
+ CGOpts.DebugCompilationDir .clear ();
174
+ CGOpts.CoverageCompilationDir .clear ();
175
+ CGOpts.CoverageDataFile .clear ();
176
+ CGOpts.CoverageNotesFile .clear ();
177
+ CGOpts.ProfileInstrumentUsePath .clear ();
178
+ CGOpts.SampleProfileFile .clear ();
179
+ CGOpts.ProfileRemappingFile .clear ();
180
+ }
181
+ }
182
+
163
183
static CowCompilerInvocation
164
184
makeCommonInvocationForModuleBuild (CompilerInvocation CI) {
165
185
CI.resetNonModularOptions ();
@@ -176,18 +196,8 @@ makeCommonInvocationForModuleBuild(CompilerInvocation CI) {
176
196
// LLVM options are not going to affect the AST
177
197
CI.getFrontendOpts ().LLVMArgs .clear ();
178
198
179
- // TODO: Figure out better way to set options to their default value.
180
- CI.getCodeGenOpts ().MainFileName .clear ();
181
- CI.getCodeGenOpts ().DwarfDebugFlags .clear ();
182
- if (!CI.getLangOpts ().ModulesCodegen ) {
183
- CI.getCodeGenOpts ().DebugCompilationDir .clear ();
184
- CI.getCodeGenOpts ().CoverageCompilationDir .clear ();
185
- CI.getCodeGenOpts ().CoverageDataFile .clear ();
186
- CI.getCodeGenOpts ().CoverageNotesFile .clear ();
187
- CI.getCodeGenOpts ().ProfileInstrumentUsePath .clear ();
188
- CI.getCodeGenOpts ().SampleProfileFile .clear ();
189
- CI.getCodeGenOpts ().ProfileRemappingFile .clear ();
190
- }
199
+ resetBenignCodeGenOptions (frontend::GenerateModule, CI.getLangOpts (),
200
+ CI.getCodeGenOpts ());
191
201
192
202
// Map output paths that affect behaviour to "-" so their existence is in the
193
203
// context hash. The final path will be computed in addOutputPaths.
@@ -371,6 +381,8 @@ static bool needsModules(FrontendInputFile FIF) {
371
381
372
382
void ModuleDepCollector::applyDiscoveredDependencies (CompilerInvocation &CI) {
373
383
CI.clearImplicitModuleBuildOptions ();
384
+ resetBenignCodeGenOptions (CI.getFrontendOpts ().ProgramAction ,
385
+ CI.getLangOpts (), CI.getCodeGenOpts ());
374
386
375
387
if (llvm::any_of (CI.getFrontendOpts ().Inputs , needsModules)) {
376
388
Preprocessor &PP = ScanInstance.getPreprocessor ();
0 commit comments