cb424d7448
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).
78 lines
3.7 KiB
C++
78 lines
3.7 KiB
C++
// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection \
|
|
// RUN: -analyzer-config crosscheck-with-z3=true -verify %s
|
|
//
|
|
// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection \
|
|
// RUN: -verify %s
|
|
//
|
|
// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection \
|
|
// RUN: -analyzer-config support-symbolic-integer-casts=true -verify=symbolic %s
|
|
//
|
|
// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection \
|
|
// RUN: -analyzer-config support-symbolic-integer-casts=false -verify %s
|
|
//
|
|
// REQUIRES: asserts, z3
|
|
//
|
|
// Requires z3 only for refutation. Works with both constraint managers.
|
|
|
|
void clang_analyzer_dump(int);
|
|
|
|
using sugar_t = unsigned char;
|
|
|
|
// Enum types
|
|
enum class ScopedSugared : sugar_t {};
|
|
enum class ScopedPrimitive : unsigned char {};
|
|
enum UnscopedSugared : sugar_t {};
|
|
enum UnscopedPrimitive : unsigned char {};
|
|
|
|
template <typename T>
|
|
T conjure();
|
|
|
|
void test_enum_types() {
|
|
// Let's construct a 'binop(sym, int)', where the binop will trigger an
|
|
// integral promotion to int. Note that we need to first explicit cast
|
|
// the scoped-enum to an integral, to make it compile. We could have choosen
|
|
// any other binary operator.
|
|
int sym1 = static_cast<unsigned char>(conjure<ScopedSugared>()) & 0x0F;
|
|
int sym2 = static_cast<unsigned char>(conjure<ScopedPrimitive>()) & 0x0F;
|
|
int sym3 = static_cast<unsigned char>(conjure<UnscopedSugared>()) & 0x0F;
|
|
int sym4 = static_cast<unsigned char>(conjure<UnscopedPrimitive>()) & 0x0F;
|
|
|
|
// We need to introduce a constraint referring to the binop, to get it
|
|
// serialized during the z3-refutation.
|
|
if (sym1 && sym2 && sym3 && sym4) {
|
|
// no-crash on these dumps
|
|
//
|
|
// The 'clang_analyzer_dump' will construct a bugreport, which in turn will
|
|
// trigger a z3-refutation. Refutation will walk the bugpath, collect and
|
|
// serialize the path-constraints into z3 expressions. The binop will
|
|
// operate over 'int' type, but the symbolic operand might have a different
|
|
// type - surprisingly.
|
|
// Historically, the static analyzer did not emit symbolic casts in a lot
|
|
// of cases, not even when the c++ standard mandated it, like for casting
|
|
// a scoped enum to its underlying type. Hence, during the z3 constraint
|
|
// serialization, it made up these 'missing' integral casts - for the
|
|
// implicit cases at least.
|
|
// However, it would still not emit the cast for missing explicit casts,
|
|
// hence 8-bit wide symbol would be bitwise 'and'-ed with a 32-bit wide
|
|
// int, violating an assertion stating that the operands should have the
|
|
// same bitwidths.
|
|
|
|
clang_analyzer_dump(sym1);
|
|
// expected-warning-re@-1 {{((unsigned char) (conj_${{[0-9]+}}{enum ScopedSugared, LC{{[0-9]+}}, S{{[0-9]+}}, #{{[0-9]+}}})) & 15}}
|
|
// symbolic-warning-re@-2 {{((int) (conj_${{[0-9]+}}{enum ScopedSugared, LC{{[0-9]+}}, S{{[0-9]+}}, #{{[0-9]+}}})) & 15}}
|
|
|
|
clang_analyzer_dump(sym2);
|
|
// expected-warning-re@-1 {{((unsigned char) (conj_${{[0-9]+}}{enum ScopedPrimitive, LC{{[0-9]+}}, S{{[0-9]+}}, #{{[0-9]+}}})) & 15}}
|
|
// symbolic-warning-re@-2 {{((int) (conj_${{[0-9]+}}{enum ScopedPrimitive, LC{{[0-9]+}}, S{{[0-9]+}}, #{{[0-9]+}}})) & 15}}
|
|
|
|
clang_analyzer_dump(sym3);
|
|
// expected-warning-re@-1 {{(conj_${{[0-9]+}}{enum UnscopedSugared, LC{{[0-9]+}}, S{{[0-9]+}}, #{{[0-9]+}}}) & 15}}
|
|
// symbolic-warning-re@-2 {{((int) (conj_${{[0-9]+}}{enum UnscopedSugared, LC{{[0-9]+}}, S{{[0-9]+}}, #{{[0-9]+}}})) & 15}}
|
|
|
|
clang_analyzer_dump(sym4);
|
|
// expected-warning-re@-1 {{(conj_${{[0-9]+}}{enum UnscopedPrimitive, LC{{[0-9]+}}, S{{[0-9]+}}, #{{[0-9]+}}}) & 15}}
|
|
// symbolic-warning-re@-2 {{((int) (conj_${{[0-9]+}}{enum UnscopedPrimitive, LC{{[0-9]+}}, S{{[0-9]+}}, #{{[0-9]+}}})) & 15}}
|
|
}
|
|
}
|
|
|