[PATCH] D11106: use-after-dtor cmd option

David Majnemer david.majnemer at gmail.com
Fri Jul 10 14:40:47 PDT 2015


majnemer added a subscriber: majnemer.

================
Comment at: lib/CodeGen/CGClass.cpp:1461-1462
@@ +1460,4 @@
+  if (CGM.getCodeGenOpts().SanitizeMemoryUseAfterDtor) {
+    SmallVector<llvm::Value *, 4> Args;
+    SmallVector<llvm::Type *, 4> ArgTypes;
+
----------------
`Args` and `ArgTypes` always have a fixed number of elements.  An array might be a better choice.

================
Comment at: lib/CodeGen/CGClass.cpp:1468-1476
@@ +1467,11 @@
+    ArgTypes.push_back(IntTy);
+    const ASTRecordLayout &Layout =
+        getContext().getASTRecordLayout(Dtor->getParent());
+    Args.push_back(
+        llvm::ConstantInt::get(CGM.IntTy, Layout.getSize().getQuantity()));
+
+    llvm::FunctionType *FnType =
+        llvm::FunctionType::get(CGM.VoidTy, ArgTypes, false);
+    llvm::Value *Fn =
+        CGM.CreateRuntimeFunction(FnType, "__sanitizer_dtor_exit_callback");
+    EmitNounwindRuntimeCall(Fn, Args);
----------------
I couldn't find a definition of `__sanitizer_dtor_exit_callback` but `int` seems like the wrong type if it is supposed to hold the size of the record.

Consider:
  struct S { char x[1ULL << 32]; ~S() {} } s;

This type will have size 4294967296 but will be represent as 0 if coerced to an int type on most (all?) 64-bit platforms.


http://reviews.llvm.org/D11106







More information about the cfe-commits mailing list