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


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
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to