[clang] [llvm] [Clang] Add `-fsanitize-prefix-map` for remapping source paths in sanitizer metadata (PR #186908)

Vitaly Buka via cfe-commits cfe-commits at lists.llvm.org
Sat Nov 28 12:11:48 PST 2026


================
@@ -4068,6 +4068,15 @@ llvm::Constant *CodeGenFunction::EmitCheckSourceLocation(SourceLocation Loc) {
   if (PLoc.isValid()) {
     StringRef FilenameString = PLoc.getFilename();
 
+    // Apply sanitize prefix map.
+    SmallString<256> RemappedName(FilenameString);
+    for (const auto &[Old, New] : CGM.getCodeGenOpts().SanitizePrefixMap) {
----------------
vitalybuka wrote:

```suggestion
    for (const auto &[Old, New] :
         llvm::reverse(CGM.getCodeGenOpts().SanitizePrefixMap)) {
```
Iterate in reverse so the last matching prefix wins, consistent with -fdebug-prefix-map, -fcoverage-prefix-map, and -ffile-prefix-map.

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


More information about the cfe-commits mailing list