[PATCH] D92001: [ubsan] Fix crash on __builtin_assume_aligned

Orivej Desh via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 23 21:28:56 PST 2020


orivej updated this revision to Diff 307239.

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92001/new/

https://reviews.llvm.org/D92001

Files:
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/test/CodeGen/ubsan-assume-aligned-crash.c


Index: clang/test/CodeGen/ubsan-assume-aligned-crash.c
===================================================================
--- /dev/null
+++ clang/test/CodeGen/ubsan-assume-aligned-crash.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -fsanitize=alignment -emit-llvm %s -o /dev/null
+
+/* Testcase for PR45813 - clang crashes checking isVolatileQualified of isNull pointee. */
+
+__attribute__((aligned(8))) int data[2];
+
+int* test() {
+    return __builtin_assume_aligned(data, 8);
+}
Index: clang/lib/CodeGen/CodeGenFunction.cpp
===================================================================
--- clang/lib/CodeGen/CodeGenFunction.cpp
+++ clang/lib/CodeGen/CodeGenFunction.cpp
@@ -2521,7 +2521,7 @@
 
   // Don't check pointers to volatile data. The behavior here is implementation-
   // defined.
-  if (Ty->getPointeeType().isVolatileQualified())
+  if (!Ty->getPointeeType().isNull() && Ty->getPointeeType().isVolatileQualified())
     return;
 
   // We need to temorairly remove the assumption so we can insert the


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D92001.307239.patch
Type: text/x-patch
Size: 1018 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20201124/ae42bd0e/attachment.bin>


More information about the cfe-commits mailing list