[clang] [llvm] [Clang] Make -ffile-compilation-dir= support reproducible sanitizer builds (PR #201803)

Vitaly Buka via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 27 21:17:43 PST 2026


================
@@ -4175,6 +4175,19 @@ llvm::Constant *CodeGenFunction::EmitCheckSourceLocation(SourceLocation Loc) {
   if (PLoc.isValid()) {
     StringRef FilenameString = PLoc.getFilename();
 
+    // If a sanitize compilation dir is set, make absolute paths relative to it.
+    llvm::SmallString<256> FileBuf(FilenameString);
+    if (!CGM.getCodeGenOpts().SanitizeCompilationDir.empty() &&
+        llvm::sys::path::is_absolute(FilenameString)) {
----------------
vitalybuka wrote:

Normalize dot components on the file path before prefix matching so out-of-tree paths with parent segments still match.
```suggestion
    llvm::SmallString<256> FileBuf;
    if (!CGM.getCodeGenOpts().SanitizeCompilationDir.empty() &&
        llvm::sys::path::is_absolute(FilenameString)) {
      FileBuf = FilenameString;
      llvm::sys::path::remove_dots(FileBuf, /*remove_dot_dot=*/true);
```

https://github.com/llvm/llvm-project/pull/201803


More information about the cfe-commits mailing list