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

Reid Kleckner rnk at google.com
Mon Oct 7 12:31:37 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));
+}
+
----------------
Richard Smith wrote:
> 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.
Yeah.  It's more like "isKnownStaticMember" or something.  How about I use Eli's idea of splitting this into isMember() and isStaticMember(), with the assert like you suggest?

================
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());
 
----------------
Richard Smith wrote:
> 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.
Yes, for this horrible testcase:

  typedef void *__thiscall OperatorNewType(__SIZE_TYPE__);
  typedef void __thiscall OperatorDeleteType(void *);
  struct TypedefNewDelete {
    OperatorNewType operator new;
    OperatorNewType operator new[];
    OperatorDeleteType operator delete;
    OperatorDeleteType operator delete[];
  };

We have to adjust __thiscall to __cdecl.


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



More information about the cfe-commits mailing list