@@ -145,94 +145,18 @@ void DepscanPrefixMapping::remapInvocationPaths(CompilerInvocation &Invocation,
145145 FrontendOpts.PathPrefixMappings .emplace_back (Map.Old , Map.New );
146146 }
147147
148- auto mapInPlaceAll = [&](std::vector<std::string> &Vector) {
149- for (auto &Path : Vector)
150- Mapper.mapInPlace (Path);
151- };
152-
153- auto &FileSystemOpts = Invocation.getFileSystemOpts ();
154- Mapper.mapInPlace (FileSystemOpts.CASFileSystemWorkingDirectory );
155-
156- // Remap header search.
157- auto &HeaderSearchOpts = Invocation.getHeaderSearchOpts ();
158- Mapper.mapInPlace (HeaderSearchOpts.Sysroot );
159- for (auto &Entry : HeaderSearchOpts.UserEntries )
160- if (Entry.IgnoreSysRoot )
161- Mapper.mapInPlace (Entry.Path );
162-
163- for (auto &Prefix : HeaderSearchOpts.SystemHeaderPrefixes )
164- Mapper.mapInPlace (Prefix.Prefix );
165- Mapper.mapInPlace (HeaderSearchOpts.ResourceDir );
166- Mapper.mapInPlace (HeaderSearchOpts.ModuleCachePath );
167- Mapper.mapInPlace (HeaderSearchOpts.ModuleUserBuildPath );
168- for (auto I = HeaderSearchOpts.PrebuiltModuleFiles .begin (),
169- E = HeaderSearchOpts.PrebuiltModuleFiles .end ();
170- I != E;) {
171- auto Current = I++;
172- Mapper.mapInPlace (Current->second );
173- }
174- mapInPlaceAll (HeaderSearchOpts.PrebuiltModulePaths );
175- mapInPlaceAll (HeaderSearchOpts.VFSOverlayFiles );
176-
177- // Preprocessor options.
178- auto &PPOpts = Invocation.getPreprocessorOpts ();
179- mapInPlaceAll (PPOpts.MacroIncludes );
180- mapInPlaceAll (PPOpts.Includes );
181- Mapper.mapInPlace (PPOpts.ImplicitPCHInclude );
182-
183- // Frontend options.
184- for (FrontendInputFile &Input : FrontendOpts.Inputs ) {
185- if (Input.isBuffer ())
186- continue ; // FIXME: Can this happen when parsing command-line?
187-
188- SmallString<256 > RemappedFile;
189- Mapper.map (Input.getFile (), RemappedFile);
190- if (RemappedFile != Input.getFile ())
191- Input =
192- FrontendInputFile (RemappedFile, Input.getKind (), Input.isSystem ());
193- }
194-
195- // Skip the output file. That's not the input CAS filesystem.
196- // Mapper.mapInPlace(OutputFile); <-- this doesn't make sense.
197-
198- Mapper.mapInPlace (FrontendOpts.CodeCompletionAt .FileName );
199-
200- // Don't remap plugins (for now), since we don't know how to remap their
201- // arguments. Maybe they should be loaded outside of the CAS filesystem?
148+ // Note: We don't remap plugins for now, since we don't know how to remap
149+ // their arguments. Maybe they should be loaded outside of the CAS filesystem?
202150 // Maybe we should error?
203151 //
204- // Mapper.mapInPlaceOrFilterOut(FrontendOpts.Plugins);
205-
206- mapInPlaceAll (FrontendOpts.ModuleMapFiles );
207- mapInPlaceAll (FrontendOpts.ModuleFiles );
208- mapInPlaceAll (FrontendOpts.ModulesEmbedFiles );
209- mapInPlaceAll (FrontendOpts.ASTMergeFiles );
210- Mapper.mapInPlace (FrontendOpts.OverrideRecordLayoutsFile );
211- Mapper.mapInPlace (FrontendOpts.StatsFile );
212-
213- // Filesystem options.
214- Mapper.mapInPlace (FileSystemOpts.WorkingDir );
215-
216- // Code generation options.
217- auto &CodeGenOpts = Invocation.getCodeGenOpts ();
218- Mapper.mapInPlace (CodeGenOpts.DebugCompilationDir );
219- Mapper.mapInPlace (CodeGenOpts.CoverageCompilationDir );
220-
221- // Sanitizer options.
222- mapInPlaceAll (Invocation.getLangOpts ().NoSanitizeFiles );
223-
224- // Handle coverage mappings.
225- Mapper.mapInPlace (CodeGenOpts.ProfileInstrumentUsePath );
226- Mapper.mapInPlace (CodeGenOpts.SampleProfileFile );
227- Mapper.mapInPlace (CodeGenOpts.ProfileRemappingFile );
228-
229- // Dependency output options.
230- // Note: these are not in the cache key, but they are in the module context
231- // hash, which indirectly impacts the cache key when importing a module.
232- // In the future we may change how -fmodule-file-cache-key works when
233- // remapping to avoid needing this.
234- for (auto &ExtraDep : Invocation.getDependencyOutputOpts ().ExtraDeps )
235- Mapper.mapInPlace (ExtraDep.first );
152+ // Note: DependencyOutputOptions::ExtraDeps are not in the cache key, but they
153+ // are in the module context hash, which indirectly impacts the cache key when
154+ // importing a module. In the future we may change how -fmodule-file-cache-key
155+ // works when remapping to avoid needing this.
156+ Invocation.visitPaths ([&Mapper](std::string &Path) {
157+ Mapper.mapInPlace (Path);
158+ return false ;
159+ });
236160}
237161
238162void DepscanPrefixMapping::configurePrefixMapper (const CompilerInvocation &CI,
0 commit comments