Skip to content

Commit 017551a

Browse files
committed
Make sure more specific remappings come first
1 parent 80f559e commit 017551a

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

clang/lib/Index/IndexingAction.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -830,8 +830,12 @@ static void writeUnitData(const CompilerInstance &CI,
830830
return nullptr;
831831
};
832832
PathRemapper Remapper;
833-
for (const auto &KV : CI.getCodeGenOpts().DebugPrefixMap)
834-
Remapper.addMapping(KV.first, KV.second);
833+
auto &PrefixMap = CI.getCodeGenOpts().DebugPrefixMap;
834+
// We need to add in reverse order since the `DebugPrefixMap` currently sorts
835+
// ascending instead of descending, but we want `foo/subpath/` to come before
836+
// `foo/`.
837+
for (auto It = PrefixMap.rbegin(); It != PrefixMap.rend(); ++It)
838+
Remapper.addMapping(It->first, It->second);
835839

836840
IndexUnitWriter UnitWriter(
837841
CI.getFileManager(), DataPath, "clang", getClangVersion(), OutputFile,

0 commit comments

Comments
 (0)