Skip to content

[CLANG-CL] Remove the 'static' specifier for _FUNCTION_ in MSVC mode. #128184

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ Bug Fixes in This Version
- Clang now outputs correct values when #embed data contains bytes with negative
signed char values (#GH102798).

- Remove the ``static`` specifier for the value of ``_FUNCTION_`` for static functions, in MSVC compatibility mode.

Bug Fixes to Compiler Builtins
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Expand Down
2 changes: 1 addition & 1 deletion clang/lib/AST/Expr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -747,7 +747,7 @@ std::string PredefinedExpr::ComputeName(PredefinedIdentKind IK,
if (const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(FD)) {
if (MD->isVirtual() && IK != PredefinedIdentKind::PrettyFunctionNoVirtual)
Out << "virtual ";
if (MD->isStatic())
if (MD->isStatic() && !ForceElaboratedPrinting)
Out << "static ";
}

Expand Down
51 changes: 51 additions & 0 deletions clang/test/SemaCXX/source_location.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,57 @@ TestClass<test_func::C> t2;
TestStruct<test_func::S> t3;
TestEnum<test_func::E> t4;

class A { int b;};
namespace inner {
template <class Ty>
class C {
public:
template <class T>
static void f(int i) {
(void)i;
#ifdef MS
static_assert(is_equal(__FUNCTION__, "test_func::inner::C<class test_func::A>::f"));
#else
static_assert(is_equal(__FUNCTION__, "f"));
#endif
}
template <class T>
static constexpr void cf(int i) {
(void)i;
#ifdef MS
static_assert(is_equal(__FUNCTION__, "test_func::inner::C<class test_func::A>::cf"));
#else
static_assert(is_equal(__FUNCTION__, "cf"));
#endif
}
template <class T>
static void df(double f) {
(void)f;
#ifdef MS
static_assert(is_equal(__FUNCTION__, "test_func::inner::C<class test_func::A>::df"));
#else
static_assert(is_equal(__FUNCTION__, "df"));
#endif
}
template <class T>
static constexpr void cdf(double f) {
(void)f;
#ifdef MS
static_assert(is_equal(__FUNCTION__, "test_func::inner::C<class test_func::A>::cdf"));
#else
static_assert(is_equal(__FUNCTION__, "cdf"));
#endif
}
};
}

void foo() {
test_func::inner::C<test_func::A>::f<char>(1);
test_func::inner::C<test_func::A>::cf<char>(1);
test_func::inner::C<test_func::A>::df<void>(1.0);
test_func::inner::C<test_func::A>::cdf<void>(1.0);
}

} // namespace test_func


Expand Down