https://bugs.llvm.org/show_bug.cgi?id=52360

            Bug ID: 52360
           Summary: __PRETTY_FUNCTION__ leaks absolute paths even with
                    -fmacro-prefix-map
           Product: clang
           Version: trunk
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangb...@nondot.org
          Reporter: vesko.karaga...@gmail.com
                CC: htmldevelo...@gmail.com, llvm-bugs@lists.llvm.org,
                    neeil...@live.com, richard-l...@metafoo.co.uk

The `-fmacro-prefix-map` option remaps "file source paths in predefined
preprocessor macros and __builtin_FILE()". The __PRETTY_FUNCTION__ predefined
macro expands to a string, which can contain absolute file paths when the
function signature includes a lambda as a template parameter.

```cpp
template <typename F>
void a() {
    const char* file = __FILE__;
    const char* func = __PRETTY_FUNCTION__;
}

int main() {
    auto f = []() { return 0; };
    a<decltype(f)>();
}
```

When the above code is compiled with `-fmacro-prefix-map=$SRCDIR=/TEST`, the
paths in the expansion of `__PRETTY_FUNCTION__` are not remapped.

The output binary contains:
```
void a() [F = (lambda at /app/example.cpp:8:14)]
```

Compiler Explorer: https://godbolt.org/z/8vYW84oMv

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to