[clang] [clang] Add missing readonly/readnone annotations (PR #158424)
Quentin Chateau via cfe-commits
cfe-commits at lists.llvm.org
Tue Sep 16 13:53:04 PDT 2025
================
@@ -14,14 +14,20 @@ T1 __attribute__((pure)) f3(void);
void __attribute__((const)) f4(T1 a);
void __attribute__((pure)) f5(T1 a);
-void *ps[] = { f0, f1, f2, f3, f4, f5 };
+// NOTE: The int parameters verifies non-ptr parameters are not a problem
+T1 __attribute__((const)) f6(void*, int);
+T1 __attribute__((pure)) f7(void*, int);
+
+void *ps[] = { f0, f1, f2, f3, f4, f5, f6, f7 };
// CHECK: declare i32 @f0() [[RN:#[0-9]+]]
// CHECK: declare i32 @f1() [[RO:#[0-9]+]]
// CHECK: declare void @f2({{.*}} sret({{.*}}) align 4)
// CHECK: declare void @f3({{.*}} sret({{.*}}) align 4)
// CHECK: declare void @f4({{.*}} byval({{.*}}) align 4)
// CHECK: declare void @f5({{.*}} byval({{.*}}) align 4)
+// CHECK: declare void @f6({{.*}} sret({{.*}}) align 4, {{.*}} readnone{{.*}})
+// CHECK: declare void @f7({{.*}} sret({{.*}}) align 4, {{.*}} readonly{{.*}})
----------------
qchateau wrote:
I strengthened the expectations, including on f0 to f5. I changed the return type of f4/f5, the attributes const/pure were ignored because the functions' return type was void.
https://github.com/llvm/llvm-project/pull/158424
More information about the cfe-commits
mailing list