Skip to content

Commit d336db2

Browse files
authored
Merge pull request swiftlang#4766 from DavidGoldman/fixindexoutputpaths5.7
[5.7][Index/IndexStore] Preserve the canonical output file path
2 parents a1c63d5 + d3e13f8 commit d336db2

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

clang/lib/Index/IndexUnitReader.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,11 @@ class IndexUnitBitstreamVisitor : public BitstreamVisitor<IndexUnitBitstreamVisi
212212
case UNIT_PATH_BUFFER:
213213
Reader.PathsBuffer = Blob;
214214
Reader.WorkingDir = Reader.getAndRemapPathFromBuffer(WorkDirOffset, WorkDirSize);
215-
Reader.OutputFile = Reader.getAndRemapPathFromBuffer(OutputFileOffset, OutputFileSize);
215+
// We intentionally do -not- remap the output file and instead leave it
216+
// in the canonical form. This is because the output file need not be an
217+
// actual real file path and this allows clients to provide the same
218+
// canonical output path e.g. in the explicit output files list.
219+
Reader.OutputFile = Reader.getPathFromBuffer(OutputFileOffset, OutputFileSize).str();
216220
Reader.SysrootPath = Reader.getAndRemapPathFromBuffer(SysrootOffset, SysrootSize);
217221

218222
// now we can populate the main file's path

clang/test/Index/Store/print-unit-roundtrip-remapping.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ void foo(int i);
1414
// CHECK-NOT: main-path: SRC_ROOT{{/|\\}}print-unit-roundtrip-remapping.c
1515
// CHECK: main-path: {{.*}}{{/|\\}}print-unit-roundtrip-remapping.c
1616
// CHECK-NOT: work-dir: BUILD_ROOT
17-
// CHECK-NOT: out-file: SRC_ROOT{{/|\\}}print-unit-roundtrip-remapping.c.o
18-
// CHECK: out-file: {{.*}}{{/|\\}}print-unit-roundtrip-remapping.c.o
17+
// CHECK: out-file: SRC_ROOT{{/|\\}}print-unit-roundtrip-remapping.c.o
1918
// CHECK: target: x86_64-apple-macosx10.8
2019
// CHECK: is-debug: 1
2120
// CHECK: DEPEND START

clang/tools/IndexStore/IndexStore.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,10 @@ indexstore_store_get_unit_name_from_output_path(indexstore_t c_store,
613613
size_t buf_size) {
614614
IndexDataStore *store = static_cast<IndexDataStore*>(c_store);
615615
SmallString<256> unitName;
616-
auto remapper = store->getPathRemapper();
616+
// We intentionally don't use the index store's path remapper since it
617+
// maps from canonical -> local instead of local -> canonical. This means that
618+
// callers must gives us the canonical `output_path`, not the local one.
619+
PathRemapper remapper;
617620
IndexUnitWriter::getUnitNameForAbsoluteOutputFile(output_path, unitName,
618621
remapper);
619622
size_t nameLen = unitName.size();

0 commit comments

Comments
 (0)