Author: Michael Park Date: 2026-02-05T22:04:54-08:00 New Revision: 295b0ef7b9aa345867e458912c8ade3f55a41f99
URL: https://github.com/llvm/llvm-project/commit/295b0ef7b9aa345867e458912c8ade3f55a41f99 DIFF: https://github.com/llvm/llvm-project/commit/295b0ef7b9aa345867e458912c8ade3f55a41f99.diff LOG: [C++20][Modules] Fix relocatable PCH feature. (#180023) Added: Modified: clang/lib/Serialization/ASTWriter.cpp clang/test/PCH/reloc.c Removed: ################################################################################ diff --git a/clang/lib/Serialization/ASTWriter.cpp b/clang/lib/Serialization/ASTWriter.cpp index 3e10bbfedfe65..b55440b4a4f39 100644 --- a/clang/lib/Serialization/ASTWriter.cpp +++ b/clang/lib/Serialization/ASTWriter.cpp @@ -1526,10 +1526,12 @@ void ASTWriter::WriteControlBlock(Preprocessor &PP, StringRef isysroot) { // Write out all other paths relative to the base directory if possible. BaseDirectory.assign(BaseDir->begin(), BaseDir->end()); - } else if (!isysroot.empty()) { - // Write out paths relative to the sysroot if possible. - BaseDirectory = std::string(isysroot); } + } else if (!isysroot.empty()) { + // Write out paths relative to the sysroot if possible. + SmallString<128> CleanedSysroot(isysroot); + cleanPathForOutput(PP.getFileManager(), CleanedSysroot); + BaseDirectory.assign(CleanedSysroot.begin(), CleanedSysroot.end()); } // Module map file diff --git a/clang/test/PCH/reloc.c b/clang/test/PCH/reloc.c index 435fde2e19234..019e3c495218b 100644 --- a/clang/test/PCH/reloc.c +++ b/clang/test/PCH/reloc.c @@ -3,6 +3,11 @@ // RUN: %clang -target x86_64-apple-darwin11 -fsyntax-only \ // RUN: -include-pch %t -isysroot %S/Inputs/libroot %s -Xclang -verify // RUN: not %clang -target x86_64-apple-darwin11 -include-pch %t %s +// RUN: llvm-bcanalyzer --dump --disable-histogram %t \ +// RUN: | FileCheck %s +// CHECK: <ORIGINAL_FILE {{.*}}/> blob data = 'usr{{[/\\]}}include{{[/\\]}}reloc.h' +// CHECK: <INPUT_FILE {{.*}}/> blob data = 'usr{{[/\\]}}include{{[/\\]}}reloc.h' +// CHECK: <INPUT_FILE {{.*}}/> blob data = 'usr{{[/\\]}}include{{[/\\]}}reloc2.h' // REQUIRES: x86-registered-target #include <reloc.h> _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
