brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.9 KiB · 1814da2 Raw
67 lines · cpp
1// RUN: rm -rf %t.1 %t.22// RUN: mkdir %t.1 %t.23 4// Build and use an ASan-enabled module.5// RUN: %clang_cc1 -fsanitize=address -fmodules -fmodules-cache-path=%t.1 \6// RUN:   -fmodule-map-file=%S/Inputs/check-for-sanitizer-feature/map \7// RUN:   -I %S/Inputs/check-for-sanitizer-feature -verify %s8// RUN: ls %t.1 | count 29 10// Force a module rebuild by disabling ASan.11// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t.1 \12// RUN:   -fmodule-map-file=%S/Inputs/check-for-sanitizer-feature/map \13// RUN:   -I %S/Inputs/check-for-sanitizer-feature -verify %s14// RUN: ls %t.1 | count 315 16// Enable ASan again: check that there is no import failure, and no rebuild.17// RUN: %clang_cc1 -fsanitize=address -fmodules -fmodules-cache-path=%t.1 \18// RUN:   -fmodule-map-file=%S/Inputs/check-for-sanitizer-feature/map \19// RUN:   -I %S/Inputs/check-for-sanitizer-feature -verify %s20// RUN: ls %t.1 | count 321 22// Some sanitizers can not affect AST generation when enabled. Check that23// module rebuilds don't occur when these sanitizers are enabled.24//25// First, build without any sanitization.26// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t.2 \27// RUN:   -fmodule-map-file=%S/Inputs/check-for-sanitizer-feature/map \28// RUN:   -I %S/Inputs/check-for-sanitizer-feature -verify %s29// RUN: ls %t.2 | count 230//31// Next, build with sanitization, and check that a new module isn't built.32// RUN: %clang_cc1 -fsanitize=cfi-vcall,float-divide-by-zero,unsigned-integer-overflow,nullability-arg,null -fmodules \33// RUN:   -fmodules-cache-path=%t.2 \34// RUN:   -fmodule-map-file=%S/Inputs/check-for-sanitizer-feature/map \35// RUN:   -I %S/Inputs/check-for-sanitizer-feature -verify %s36// RUN: ls %t.2 | count 237 38// Finally, test that including enabled sanitizers in the module hash isn't39// required to ensure correctness of module imports.40//41// Emit a PCH with ASan enabled.42// RUN: %clang_cc1 -x c -fsanitize=address %S/Inputs/check-for-sanitizer-feature/check.h -emit-pch -o %t.asan_pch43//44// Import the PCH without ASan enabled (we expect an error).45// RUN: not %clang_cc1 -x c -include-pch %t.asan_pch %s -verify 2>&1 | FileCheck %s --check-prefix=PCH_MISMATCH46// PCH_MISMATCH: precompiled file '{{.*}}.asan_pch' was compiled with the target feature '-fsanitize=address' but the current translation unit is not47//48// Emit a PCH with UBSan enabled.49// RUN: %clang_cc1 -x c -fsanitize=null %S/Inputs/check-for-sanitizer-feature/check.h -emit-pch -o %t.ubsan_pch50//51// Import the PCH without UBSan enabled (should work just fine).52// RUN: %clang_cc1 -x c -include-pch %t.ubsan_pch %s -I %S/Inputs/check-for-sanitizer-feature -verify53 54#include "check.h"55 56#if __has_feature(address_sanitizer)57#if HAS_ASAN != 158#error Module doesn't have the address_sanitizer feature, but main program does.59#endif60#else61#if HAS_ASAN != 062#error Module has the address_sanitizer feature, but main program doesn't.63#endif64#endif65 66// expected-no-diagnostics67