[PATCH] Skip Ubsan's vptr checks on constructors and destructors.

Byoungyoung Lee byoungyoung at chromium.org
Tue Jul 15 15:33:53 PDT 2014


Hi samsonov, rsmith,

Initial patch attempts to skip Ubsan's vptr checks on ctors and dtors as many (seemingly harmless) undefined behaviors were observed in ctors and dtors. This feature should be opted out with some other compiler flags (e.g., -mllvm for Asan), but right now there are no such flags in this patch.

http://reviews.llvm.org/D4528

Files:
  lib/CodeGen/CodeGenFunction.cpp

Index: lib/CodeGen/CodeGenFunction.cpp
===================================================================
--- lib/CodeGen/CodeGenFunction.cpp
+++ lib/CodeGen/CodeGenFunction.cpp
@@ -535,7 +535,9 @@
   CurFnInfo = &FnInfo;
   assert(CurFn->isDeclaration() && "Function already has body?");
 
-  if (CGM.getSanitizerBlacklist().isIn(*Fn))
+  if (CGM.getSanitizerBlacklist().isIn(*Fn) ||
+      (SanOpts->Vptr && D &&
+       (isa<CXXConstructorDecl>(D) || isa<CXXDestructorDecl>(D))))
     SanOpts = &SanitizerOptions::Disabled;
 
   // Pass inline keyword to optimizer if it appears explicitly on any
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D4528.11473.patch
Type: text/x-patch
Size: 601 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140715/110fe4e1/attachment.bin>


More information about the cfe-commits mailing list