Skip to content

[5.7][Index/IndexStore] Preserve the canonical output file path #4766

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion clang/lib/Index/IndexUnitReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,11 @@ class IndexUnitBitstreamVisitor : public BitstreamVisitor<IndexUnitBitstreamVisi
case UNIT_PATH_BUFFER:
Reader.PathsBuffer = Blob;
Reader.WorkingDir = Reader.getAndRemapPathFromBuffer(WorkDirOffset, WorkDirSize);
Reader.OutputFile = Reader.getAndRemapPathFromBuffer(OutputFileOffset, OutputFileSize);
// We intentionally do -not- remap the output file and instead leave it
// in the canonical form. This is because the output file need not be an
// actual real file path and this allows clients to provide the same
// canonical output path e.g. in the explicit output files list.
Reader.OutputFile = Reader.getPathFromBuffer(OutputFileOffset, OutputFileSize).str();
Reader.SysrootPath = Reader.getAndRemapPathFromBuffer(SysrootOffset, SysrootSize);

// now we can populate the main file's path
Expand Down
3 changes: 1 addition & 2 deletions clang/test/Index/Store/print-unit-roundtrip-remapping.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ void foo(int i);
// CHECK-NOT: main-path: SRC_ROOT{{/|\\}}print-unit-roundtrip-remapping.c
// CHECK: main-path: {{.*}}{{/|\\}}print-unit-roundtrip-remapping.c
// CHECK-NOT: work-dir: BUILD_ROOT
// CHECK-NOT: out-file: SRC_ROOT{{/|\\}}print-unit-roundtrip-remapping.c.o
// CHECK: out-file: {{.*}}{{/|\\}}print-unit-roundtrip-remapping.c.o
// CHECK: out-file: SRC_ROOT{{/|\\}}print-unit-roundtrip-remapping.c.o
// CHECK: target: x86_64-apple-macosx10.8
// CHECK: is-debug: 1
// CHECK: DEPEND START
Expand Down
5 changes: 4 additions & 1 deletion clang/tools/IndexStore/IndexStore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,10 @@ indexstore_store_get_unit_name_from_output_path(indexstore_t c_store,
size_t buf_size) {
IndexDataStore *store = static_cast<IndexDataStore*>(c_store);
SmallString<256> unitName;
auto remapper = store->getPathRemapper();
// We intentionally don't use the index store's path remapper since it
// maps from canonical -> local instead of local -> canonical. This means that
// callers must gives us the canonical `output_path`, not the local one.
PathRemapper remapper;
IndexUnitWriter::getUnitNameForAbsoluteOutputFile(output_path, unitName,
remapper);
size_t nameLen = unitName.size();
Expand Down