[PATCH] [ms-cxxabi] Fix the calling convention for operator new in records

Richard Smith richard at metafoo.co.uk
Mon Sep 30 15:29:04 PDT 2013



================
Comment at: lib/Sema/DeclSpec.cpp:329-334
@@ -327,1 +328,8 @@
 
+bool Declarator::isStaticMember() {
+  return getContext() == MemberContext &&
+         (getDeclSpec().getStorageClassSpec() == DeclSpec::SCS_static ||
+          CXXMethodDecl::isStaticOverloadedOperator(
+              getName().OperatorFunctionId.Operator));
+}
+
----------------
This does not, and cannot, return the correct result for an out-of-line declaration of a member function. You can't tell whether such a member is static until you've looked up the previous declaration.

So... either turn the Context check into an assert, or rename this function to make it clear that it only works for declarations within the class body.

================
Comment at: lib/Sema/SemaDecl.cpp:6491-6492
@@ -6490,6 +6490,4 @@
 
-  if (DC->isRecord() &&
-      D.getDeclSpec().getStorageClassSpec() != DeclSpec::SCS_static &&
-      !D.getDeclSpec().isFriendSpecified())
-    adjustMemberFunctionCC(R);
+  if (DC->isRecord() && !D.getDeclSpec().isFriendSpecified())
+    adjustMemberFunctionCC(R, D.isStaticMember());
 
----------------
Do we need to adjust the calling convention for static members here? (Is the default for them ever different from the default for non-members?) If so, we should have a testcase for the calling convention of members explicitly declared static.


http://llvm-reviews.chandlerc.com/D1761



More information about the cfe-commits mailing list