Files
RedBear-OS/local/recipes/dev/libclc/source/clang/test/Analysis/ctu-onego-existingdef.cpp
T
vasilito cb424d7448 build: static patch-sanity linter (shift-left the malformed-patch class)
verify-patch-sanity.py validates every active recipe .patch has internally-
consistent hunk line counts — catching the 'malformed patch at line N' failure
at commit/CI/preflight time instead of hours into a cook. This cycle hit that
class three times (qtwaylandscanner, sddm, xwayland), each only discovered when
cookbook tried to apply the patch.

Running it across the repo found 29 latent malformed patches (validated against
GNU patch: e.g. relibc/P3-sysv-ipc reproduces 'malformed patch at line 22').
They were harmless only because they sit in vendored recipes (baked, not re-
applied) — but would fail on any version-bump re-derivation. --fix recounts the
hunk headers (body untouched) and repaired all 29.

Wired into build-preflight.sh (Phase 1.0D) and redbear-ci.yml, with a unit test
(test-patch-sanity.sh). Skips archived/legacy trees and unvalidatable formats
(empty placeholders, bare-@@ git hunks).
2026-08-01 05:13:02 +03:00

68 lines
3.0 KiB
C++

// RUN: %clang_analyze_cc1 -std=c++14 -triple x86_64-pc-linux-gnu \
// RUN: -analyzer-checker=core,debug.ExprInspection \
// RUN: -analyzer-config eagerly-assume=false \
// RUN: -analyze-function='baruser(int)' -x c++ \
// RUN: -verify=nonctu %s
// RUN: rm -rf %t && mkdir %t
// RUN: mkdir -p %t/ctudir
// RUN: %clang_cc1 -std=c++14 -triple x86_64-pc-linux-gnu \
// RUN: -emit-pch -o %t/ctudir/ctu-onego-existingdef-other.cpp.ast %S/Inputs/ctu-onego-existingdef-other.cpp
// RUN: cp %S/Inputs/ctu-onego-existingdef-other.cpp.externalDefMap.ast-dump.txt %t/ctudir/externalDefMap.txt
// Existing and equal function definition in both TU. `other` calls `bar` thus
// `bar` will be indirectly imported. During the import we recognize that there
// is an existing definition in the main TU, so we don't create a new Decl.
// Thus, ctu should not bifurcate on the call of `bar` it should directly
// inlinie that as in the case of nonctu.
// Note, we would not get a warning below, if `bar` is conservatively evaluated.
int bar() {
return 0;
}
//Here we completely supress the CTU work list execution. We should not
//bifurcate on the call of `bar`. (We do not load the foreign AST at all.)
// RUN: %clang_analyze_cc1 -std=c++14 -triple x86_64-pc-linux-gnu \
// RUN: -analyzer-checker=core,debug.ExprInspection \
// RUN: -analyzer-config eagerly-assume=false \
// RUN: -analyzer-config experimental-enable-naive-ctu-analysis=true \
// RUN: -analyzer-config ctu-dir=%t/ctudir \
// RUN: -verify=stu %s \
// RUN: -analyze-function='baruser(int)' -x c++ \
// RUN: -analyzer-config ctu-max-nodes-pct=0 \
// RUN: -analyzer-config ctu-max-nodes-min=0
//Here we enable the CTU work list execution. We should not bifurcate on the
//call of `bar`.
// RUN: %clang_analyze_cc1 -std=c++14 -triple x86_64-pc-linux-gnu \
// RUN: -analyzer-checker=core,debug.ExprInspection \
// RUN: -analyzer-config eagerly-assume=false \
// RUN: -analyzer-config experimental-enable-naive-ctu-analysis=true \
// RUN: -analyzer-config ctu-dir=%t/ctudir \
// RUN: -verify=ctu %s \
// RUN: -analyze-function='baruser(int)' -x c++ \
// RUN: -analyzer-config ctu-max-nodes-pct=100 \
// RUN: -analyzer-config ctu-max-nodes-min=1000
//Check that the AST file is loaded.
// RUN: %clang_analyze_cc1 -std=c++14 -triple x86_64-pc-linux-gnu \
// RUN: -analyzer-checker=core,debug.ExprInspection \
// RUN: -analyzer-config eagerly-assume=false \
// RUN: -analyzer-config experimental-enable-naive-ctu-analysis=true \
// RUN: -analyzer-config ctu-dir=%t/ctudir \
// RUN: -analyze-function='baruser(int)' -x c++ \
// RUN: -analyzer-config ctu-max-nodes-pct=100 \
// RUN: -analyzer-config display-ctu-progress=true \
// RUN: -analyzer-config ctu-max-nodes-min=1000 2>&1 %s | FileCheck %s
// CHECK: CTU loaded AST file
void other(); // Defined in the other TU.
void baruser(int) {
other();
int x = bar();
(void)(1 / x);
// ctu-warning@-1{{Division by zero}}
// stu-warning@-2{{Division by zero}}
// nonctu-warning@-3{{Division by zero}}
}