llvm-project/clang/test/CodeGen/cfi-icall-generalize.c
Florian Mayer a7f1702f2c
[NFC] [CFI] correct comment in test (#152399)
It incorrectly stated that `const char*` gets normalized to ptr, while
it should say that `char*` does.
2025-08-06 16:07:40 -07:00

20 lines
1019 B
C

// RUN: %clang_cc1 -triple x86_64-unknown-linux -fsanitize=cfi-icall -fsanitize-trap=cfi-icall -emit-llvm -o - %s | FileCheck --check-prefix=CHECK --check-prefix=UNGENERALIZED %s
// RUN: %clang_cc1 -triple x86_64-unknown-linux -fsanitize=cfi-icall -fsanitize-trap=cfi-icall -fsanitize-cfi-icall-generalize-pointers -emit-llvm -o - %s | FileCheck --check-prefix=CHECK --check-prefix=GENERALIZED %s
// Test that const char* is generalized to const ptr and that char** is
// generalized to ptr
// CHECK: define{{.*}} ptr @f({{.*}} !type [[TYPE:![0-9]+]] !type [[TYPE_GENERALIZED:![0-9]+]]
int** f(const char *a, const char **b) {
return (int**)0;
}
void g(int** (*fp)(const char *, const char **)) {
// UNGENERALIZED: call i1 @llvm.type.test(ptr {{.*}}, metadata !"_ZTSFPPiPKcPS2_E")
// GENERALIZED: call i1 @llvm.type.test(ptr {{.*}}, metadata !"_ZTSFPvPKvS_E.generalized")
fp(0, 0);
}
// CHECK: [[TYPE]] = !{i64 0, !"_ZTSFPPiPKcPS2_E"}
// CHECK: [[TYPE_GENERALIZED]] = !{i64 0, !"_ZTSFPvPKvS_E.generalized"}