Files
TheRock/compiler/amd-llvm/clang/test/Modules/check-for-sanitizer-feature.cpp
T
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

67 lines
2.9 KiB
C++

// RUN: rm -rf %t.1 %t.2
// RUN: mkdir %t.1 %t.2
// Build and use an ASan-enabled module.
// RUN: %clang_cc1 -fsanitize=address -fmodules -fmodules-cache-path=%t.1 \
// RUN: -fmodule-map-file=%S/Inputs/check-for-sanitizer-feature/map \
// RUN: -I %S/Inputs/check-for-sanitizer-feature -verify %s
// RUN: ls %t.1 | count 2
// Force a module rebuild by disabling ASan.
// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t.1 \
// RUN: -fmodule-map-file=%S/Inputs/check-for-sanitizer-feature/map \
// RUN: -I %S/Inputs/check-for-sanitizer-feature -verify %s
// RUN: ls %t.1 | count 3
// Enable ASan again: check that there is no import failure, and no rebuild.
// RUN: %clang_cc1 -fsanitize=address -fmodules -fmodules-cache-path=%t.1 \
// RUN: -fmodule-map-file=%S/Inputs/check-for-sanitizer-feature/map \
// RUN: -I %S/Inputs/check-for-sanitizer-feature -verify %s
// RUN: ls %t.1 | count 3
// Some sanitizers can not affect AST generation when enabled. Check that
// module rebuilds don't occur when these sanitizers are enabled.
//
// First, build without any sanitization.
// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t.2 \
// RUN: -fmodule-map-file=%S/Inputs/check-for-sanitizer-feature/map \
// RUN: -I %S/Inputs/check-for-sanitizer-feature -verify %s
// RUN: ls %t.2 | count 2
//
// Next, build with sanitization, and check that a new module isn't built.
// RUN: %clang_cc1 -fsanitize=cfi-vcall,float-divide-by-zero,unsigned-integer-overflow,nullability-arg,null -fmodules \
// RUN: -fmodules-cache-path=%t.2 \
// RUN: -fmodule-map-file=%S/Inputs/check-for-sanitizer-feature/map \
// RUN: -I %S/Inputs/check-for-sanitizer-feature -verify %s
// RUN: ls %t.2 | count 2
// Finally, test that including enabled sanitizers in the module hash isn't
// required to ensure correctness of module imports.
//
// Emit a PCH with ASan enabled.
// RUN: %clang_cc1 -x c -fsanitize=address %S/Inputs/check-for-sanitizer-feature/check.h -emit-pch -o %t.asan_pch
//
// Import the PCH without ASan enabled (we expect an error).
// RUN: not %clang_cc1 -x c -include-pch %t.asan_pch %s -verify 2>&1 | FileCheck %s --check-prefix=PCH_MISMATCH
// PCH_MISMATCH: precompiled file '{{.*}}.asan_pch' was compiled with the target feature '-fsanitize=address' but the current translation unit is not
//
// Emit a PCH with UBSan enabled.
// RUN: %clang_cc1 -x c -fsanitize=null %S/Inputs/check-for-sanitizer-feature/check.h -emit-pch -o %t.ubsan_pch
//
// Import the PCH without UBSan enabled (should work just fine).
// RUN: %clang_cc1 -x c -include-pch %t.ubsan_pch %s -I %S/Inputs/check-for-sanitizer-feature -verify
#include "check.h"
#if __has_feature(address_sanitizer)
#if HAS_ASAN != 1
#error Module doesn't have the address_sanitizer feature, but main program does.
#endif
#else
#if HAS_ASAN != 0
#error Module has the address_sanitizer feature, but main program doesn't.
#endif
#endif
// expected-no-diagnostics