[PATCH] [UBsan] Skip -fsanitize=vptr instrumentations when the pointer value is null

Richard Smith richard at metafoo.co.uk
Tue Jul 15 21:31:10 PDT 2014


================
Comment at: lib/CodeGen/CGExpr.cpp:464
@@ -463,3 +463,3 @@
 
   if (SanOpts->Null) {
     // The glvalue must not be an empty glvalue.
----------------
Instead of the below fix, please instead fix this by changing this line to

    if (SanOpts->Null || TCK == TCK_DowncastPointer)

================
Comment at: test/CodeGen/ubsan-vptr-null.cpp:1
@@ +1,2 @@
+// Verify ubsan vptr skip null pointer value cases.
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsanitize=vptr -emit-llvm %s -o - | FileCheck %s
----------------
Can you fold this into an existing test file?

================
Comment at: test/CodeGen/ubsan-vptr-null.cpp:13
@@ +12,3 @@
+  // CHECK: [[CMP_RES:%.*]] = icmp ne %class.Foo* %{{[0-9]+}}, null
+  // CHECK: br {{.*}} [[CMP_RES]], label %not.vptr_null, label %vptr_null
+  // CHECK-LABEL: cont
----------------
Please don't check the label names here: this test will fail in non-debug builds where we don't name blocks.

================
Comment at: test/CodeGen/ubsan-vptr-null.cpp:15
@@ +14,3 @@
+  // CHECK-LABEL: cont
+  // CHECK: br label %vptr_null
+
----------------
Likewise here.

http://reviews.llvm.org/D4412






More information about the cfe-commits mailing list