mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-16 13:06:48 +00:00

TySan supports some preprocessor checks and ignorelists, but they are currently untested. This PR adds some tests to make sure they all work. @fhahn @AaronBallman, this is based off the discussion in the documentation PR [#123595]
31 lines
757 B
C
31 lines
757 B
C
// RUN: %clang_tysan -O0 %s -o %t && %run %t >%t.out 2>&1 && FileCheck --check-prefix=CHECK-SANITIZED %s < %t.out
|
|
// RUN: %clang_tysan -DNOSAN -O0 %s -o %t && %run %t >%t.out 2>&1 && FileCheck --check-prefix=CHECK-NOSAN %s < %t.out
|
|
// RUN: %clang -O0 %s -o %t && %run %t >%t.out 2>&1 && FileCheck --check-prefix=CHECK-SIMPLE %s < %t.out
|
|
|
|
#include <stdio.h>
|
|
|
|
#if __has_feature(type_sanitizer)
|
|
|
|
# ifdef NOSAN
|
|
__attribute__((no_sanitize("type")))
|
|
# endif
|
|
int main(){
|
|
|
|
int value = 42;
|
|
printf("As float: %f\n", *(float *)&value);
|
|
// CHECK-SANITIZED: ERROR: TypeSanitizer
|
|
// CHECK-NOSAN-NOT: ERROR: TypeSanitizer
|
|
|
|
return 0;
|
|
}
|
|
|
|
#else
|
|
|
|
int main() {
|
|
printf("Nothing interesting here\n");
|
|
return 0;
|
|
}
|
|
// CHECK-SIMPLE: Nothing interesting here
|
|
|
|
#endif
|