[PATCH] D12022: Refactored dtor sanitizing into EHScopeStack

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 2 17:23:28 PDT 2015


rsmith added a comment.

I'd like to see some tests for poisoning bitfields, and particularly anonymous bitfields (I think the code works fine in those cases, but they're a bit special so explicitly testing them is useful).


================
Comment at: lib/CodeGen/CGCXX.cpp:151
@@ +150,3 @@
+  if (isa<CXXDestructorDecl>(MD) && getCodeGenOpts().SanitizeMemoryUseAfterDtor
+      && HasFieldWithTrivialDestructor(*this, MD->getParent()))
+    return true;
----------------
&& goes on previous line.

================
Comment at: lib/CodeGen/CGClass.cpp:1547
@@ +1546,3 @@
+      // Nothing to poison.
+      if (Layout.getFieldCount() == 0)
+        return;
----------------
eugenis wrote:
> Probably better check Dtor->getParent()->field_empty() for consistency.
This check is equivalent and more efficient.

================
Comment at: lib/CodeGen/CGClass.cpp:1559
@@ +1558,3 @@
+      RecordDecl::field_iterator Field;
+      for (Field = Dtor->getParent()->field_begin();
+           Field != Dtor->getParent()->field_end(); Field++) {
----------------
Can you use a range for?

================
Comment at: lib/CodeGen/CGClass.cpp:1587
@@ +1586,3 @@
+    // layoutEndOffset: index of the ASTRecordLayout field to end poisoning
+    //   (exclusive)
+    void PoisonBlock(CodeGenFunction &CGF, unsigned layoutStartOffset,
----------------
Doxygenize this comment  (use ///, \param).


http://reviews.llvm.org/D12022





More information about the cfe-commits mailing list