-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[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
Conversation
@llvm/pr-subscribers-clang Author: Zahira Ammarguellat (zahiraam) ChangesThe macro Full diff: https://github.com/llvm/llvm-project/pull/128184.diff 2 Files Affected:
diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
index b747aa8df807d..a019dd2818e59 100644
--- a/clang/lib/AST/Expr.cpp
+++ b/clang/lib/AST/Expr.cpp
@@ -747,8 +747,10 @@ 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())
- Out << "static ";
+ if (MD->isStatic()) {
+ if (!ForceElaboratedPrinting)
+ Out << "static ";
+ }
}
class PrettyCallbacks final : public PrintingCallbacks {
diff --git a/clang/test/SemaCXX/source_location.cpp b/clang/test/SemaCXX/source_location.cpp
index 069a9004927a9..a9fca2a17c939 100644
--- a/clang/test/SemaCXX/source_location.cpp
+++ b/clang/test/SemaCXX/source_location.cpp
@@ -524,6 +524,37 @@ 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 void f(double f) {
+ (void)f;
+#ifdef MS
+ static_assert(is_equal(__FUNCTION__, "test_func::inner::C<class test_func::A>::f"));
+#else
+ static_assert(is_equal(__FUNCTION__, "f"));
+#endif
+ }
+ };
+}
+
+ void foo() {
+ test_func::inner::C<test_func::A>::f<char>(1);
+ test_func::inner::C<test_func::A>::f<void>(1.0);
+}
+
} // namespace test_func
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with a nit.
Please be sure to add a release note to clang/docs/ReleaseNotes.rst
for the fix. Also, please add a test for constexpr
(I believe we handle that correctly, but we might as well make sure we handle all the storage class specifiers at once).
clang/lib/AST/Expr.cpp
Outdated
if (MD->isStatic()) { | ||
if (!ForceElaboratedPrinting) | ||
Out << "static "; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (MD->isStatic()) { | |
if (!ForceElaboratedPrinting) | |
Out << "static "; | |
} | |
if (MD->isStatic() && !ForceElaboratedPrinting) | |
Out << "static "; |
…llvm#128184) The macro `FUNCTION` is returning the `static` specifier for static templated functions. It's not the case for MSVC. See https://godbolt.org/z/KnhWhqs47 Clang-cl is returning: `__FUNCTION__ static inner::C<class A>::f` `__FUNCTION__ static inner::C<class A>::f` for the reproducer.
The macro
FUNCTION
is returning thestatic
specifier for static templated functions. It's not the case for MSVC.See https://godbolt.org/z/KnhWhqs47
Clang-cl is returning:
__FUNCTION__ static inner::C<class A>::f
__FUNCTION__ static inner::C<class A>::f
for the reproducer.