[PATCH] [ms-cxxabi] Destroy temporary record arguments in the callee

John McCall rjmccall at apple.com
Wed Jun 19 14:17:10 PDT 2013


On Jun 19, 2013, at 1:44 PM, Reid Kleckner <rnk at google.com> wrote:
>    - Add conditional tests
>    - Deactivate cleanups in reverse
>    - Other comments.

+  /// \brief Are temporary objects passed by value to a call destroyed by the
+  /// callee?
+  bool isTemporaryDestroyedByCallee() const {

Please embellish this comment to discuss the ways in which this is
actually a major language difference.

+void Sema::CheckByValParamsForDtors(FunctionDecl *FD) {
+  assert(Context.getTargetInfo().getCXXABI().isTemporaryDestroyedByCallee());
+  for (unsigned p = 0, NumParams = FD->getNumParams(); p < NumParams; ++p) {
+    ParmVarDecl *Param = FD->getParamDecl(p);
+    if (CXXRecordDecl *RD = Param->getType()->getAsCXXRecordDecl()) {
+      if (CXXDestructorDecl *Dtor = LookupDestructor(RD)) {
+        // Don't call CheckDestructorAccess() or we'll reject valid TUs.
+        MarkFunctionReferenced(FD->getLocation(), Dtor);
+        DiagnoseUseOfDecl(Dtor, FD->getLocation());
+      }
+    }
+  }
+}
+

I think this code is dead now?

You should add my test case, and then you'll need to go do some
spelunking to make it pass, because you'll have to disable the check
for a destructor when initializing a parameter temporary.

John.



More information about the cfe-commits mailing list