Files
TheRock/compiler/amd-llvm/clang/test/Analysis/ctu/diag/load-threshold.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

57 lines
2.4 KiB
C++

// Test that exceeding ctu-import-cpp-threshold produces load_threshold_reached,
// which silently fails AST import.
//
// With threshold=1, the first external AST (foo) is loaded successfully.
// The second lookup (bar) finds the threshold exhausted and emits a remark once.
// All subsequent threshold-blocked lookups fail silently, including those in a
// second analysis entry point (test2): the remark is not repeated, and the
// already-cached AST for foo remains accessible.
//
// RUN: rm -rf %t && mkdir %t
// RUN: %clang_cc1 -std=c++14 -triple x86_64-pc-linux-gnu \
// RUN: -emit-pch -o %t/simple.cpp.ast \
// RUN: %S/Inputs/simple.cpp
// RUN: %clang_cc1 -std=c++14 -triple x86_64-pc-linux-gnu \
// RUN: -emit-pch -o %t/bar.cpp.ast \
// RUN: %S/Inputs/bar.cpp
// RUN: %clang_cc1 -std=c++14 -triple x86_64-pc-linux-gnu \
// RUN: -emit-pch -o %t/third.cpp.ast \
// RUN: %S/Inputs/third.cpp
// RUN: echo '11:c:@F@foo#I# simple.cpp.ast' > %t/externalDefMap.txt
// RUN: echo '11:c:@F@bar#I# bar.cpp.ast' >> %t/externalDefMap.txt
// RUN: echo '13:c:@F@third#I# third.cpp.ast' >> %t/externalDefMap.txt
// RUN: %clang_analyze_cc1 -std=c++14 -triple x86_64-pc-linux-gnu \
// RUN: -analyzer-checker=core \
// RUN: -analyzer-config experimental-enable-naive-ctu-analysis=true \
// RUN: -analyzer-config ctu-dir=%t \
// RUN: -analyzer-config ctu-import-cpp-threshold=1 \
// RUN: -Rctu-remarks \
// RUN: -verify %s
// foo is loaded successfully (first load, within threshold).
// bar is the first to hit the threshold; the remark is emitted once.
// Subsequent threshold-blocked lookups (bar(2), third) fail silently.
//
// test2() is a second entry point analyzed after test(). It is defined first
// to be analyzed last.
int foo(int);
int bar(int);
int third(int);
// In a second entry point the threshold state persists from test(): the remark
// is not repeated, foo's AST is still accessible from cache, and new
// threshold-blocked lookups (bar, third) fail silently.
void test2() {
foo(1); // no remark: foo's AST was cached during test()'s analysis
bar(1); // no remark: threshold already reported in test()
third(1); // no remark: threshold already reported in test()
}
void test() {
foo(1);
bar(1); // expected-remark {{reached a the CTU-import threshold before trying to import definition}}
bar(2); // no remark: threshold already reported
third(1); // no remark: threshold already reported
}