[llvm-bugs] [Bug 52360] New: __PRETTY_FUNCTION__ leaks absolute paths even with -fmacro-prefix-map

via llvm-bugs llvm-bugs at lists.llvm.org
Sat Oct 30 05:55:09 PDT 2021


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: unassignedclangbugs at nondot.org
          Reporter: vesko.karaganev at gmail.com
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org,
                    neeilans at live.com, richard-llvm at 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20211030/4e187543/attachment.html>


More information about the llvm-bugs mailing list