================
@@ -0,0 +1,50 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -std=c++14 -emit-llvm -o -
%s | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -std=c++14 -emit-llvm -o -
%s -fexperimental-new-constant-interpreter | FileCheck %s
+
+int b = 10;
+const int f = (__builtin_assume_dereferenceable((char*)&b + 1, 3), 12);
+int use_f = f;
+
+constexpr int g = 20;
+const int h = (__builtin_assume_dereferenceable((char*)&g + 1, 2), 42);
+int use_h = h;
+
+constexpr char arr[] = "hello";
+constexpr const char* ptr = arr + 1;
+constexpr int fully_constexpr() {
+ __builtin_assume_dereferenceable(ptr, 2);
+ return 100;
+}
+constexpr int i = fully_constexpr();
+int use_i = i;
+
+void test_nullptr() {
+ __builtin_assume_dereferenceable(nullptr, 0);
+}
+
+void test_zero_size() {
+ int x = 10;
+ __builtin_assume_dereferenceable(&x, 0);
+}
+
+void test_function_ptr() {
+ __builtin_assume_dereferenceable((void*)&test_zero_size, 8);
+}
+
----------------
tbaederr wrote:
Add an example with an integer-to-pointer cast back? I don't think the current
implementation in the bytecode interpreter (that accepts all integral pointers)
is correct.
https://github.com/llvm/llvm-project/pull/169869
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits