Skip to content

Commit bcf2a47

Browse files
committed
[CLANG-CL] Remove the 'static' declaration specifier for _FUNCTION_ in
MSVC mode.
1 parent 1e1bf79 commit bcf2a47

File tree

2 files changed

+37
-2
lines changed

2 files changed

+37
-2
lines changed

clang/lib/AST/Expr.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -747,8 +747,12 @@ std::string PredefinedExpr::ComputeName(PredefinedIdentKind IK,
747747
if (const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(FD)) {
748748
if (MD->isVirtual() && IK != PredefinedIdentKind::PrettyFunctionNoVirtual)
749749
Out << "virtual ";
750-
if (MD->isStatic())
751-
Out << "static ";
750+
if (MD->isStatic()) {
751+
bool IsFunctionInMSVCCommpatEnv =
752+
IK == PredefinedIdentKind::Function && LO.MSVCCompat;
753+
if (ForceElaboratedPrinting && !IsFunctionInMSVCCommpatEnv)
754+
Out << "static ";
755+
}
752756
}
753757

754758
class PrettyCallbacks final : public PrintingCallbacks {

clang/test/SemaCXX/source_location.cpp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,37 @@ TestClass<test_func::C> t2;
524524
TestStruct<test_func::S> t3;
525525
TestEnum<test_func::E> t4;
526526

527+
class A { int b;};
528+
namespace inner {
529+
template <class Ty>
530+
class C {
531+
public:
532+
template <class T>
533+
static void f(int i) {
534+
(void)i;
535+
#ifdef MS
536+
static_assert(is_equal(__FUNCTION__, "test_func::inner::C<class test_func::A>::f"));
537+
#else
538+
static_assert(is_equal(__FUNCTION__, "f"));
539+
#endif
540+
}
541+
template <class T>
542+
static void f(double f) {
543+
(void)f;
544+
#ifdef MS
545+
static_assert(is_equal(__FUNCTION__, "test_func::inner::C<class test_func::A>::f"));
546+
#else
547+
static_assert(is_equal(__FUNCTION__, "f"));
548+
#endif
549+
}
550+
};
551+
}
552+
553+
void foo() {
554+
test_func::inner::C<test_func::A>::f<char>(1);
555+
test_func::inner::C<test_func::A>::f<void>(1.0);
556+
}
557+
527558
} // namespace test_func
528559

529560

0 commit comments

Comments
 (0)