Skip to content

<source_location>: Use __builtin_FUNCSIG when Clang 17 is available #3729

@JMazurkiewicz

Description

@JMazurkiewicz

I've implemented __builtin_FUNCSIG in Clang recently (llvm/llvm-project@78d8312):

const char* __builtin_FUNCSIG();

We should use this builtin in source_location implementation after VS gets Clang 17:

#if defined(__clang__) || defined(__EDG__) // TRANSITION, DevCom-10199227 and LLVM-58951
const char* const _Function_ = __builtin_FUNCTION()
#else // ^^^ workaround / no workaround vvv
const char* const _Function_ = __builtin_FUNCSIG()
#endif // TRANSITION, DevCom-10199227 and LLVM-58951

Comparison:

// https://godbolt.org/z/zq6v9v87q
#include <iostream>

void f(const char* old_ = __builtin_FUNCTION(), const char* new_ = __builtin_FUNCSIG()) {
    std::cout << "old: " << old_ << "\nnew: " << new_ << '\n';
}

int main() {
    f();
}
old: main
new: int __cdecl main(void)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementSomething can be improvedfixedSomething works now, yay!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions