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).
70 lines
2.2 KiB
C++
70 lines
2.2 KiB
C++
// RUN: %clang_analyze_cc1 %s -analyzer-checker=core.uninitialized.NewArraySize -analyzer-output=text -verify
|
|
|
|
#include "Inputs/system-header-simulator-cxx.h"
|
|
|
|
void checkUndefinedElmenetCountValue() {
|
|
int n;
|
|
// expected-note@-1{{'n' declared without an initial value}}
|
|
|
|
int *arr = new int[n]; // expected-warning{{Element count in new[] is a garbage value}}
|
|
// expected-note@-1{{Element count in new[] is a garbage value}}
|
|
}
|
|
|
|
void checkUndefinedElmenetCountMultiDimensionalValue() {
|
|
int n;
|
|
// expected-note@-1{{'n' declared without an initial value}}
|
|
|
|
auto *arr = new int[n][5]; // expected-warning{{Element count in new[] is a garbage value}}
|
|
// expected-note@-1{{Element count in new[] is a garbage value}}
|
|
}
|
|
|
|
void checkUndefinedElmenetCountReference() {
|
|
int n;
|
|
// expected-note@-1{{'n' declared without an initial value}}
|
|
|
|
int &ref = n;
|
|
// expected-note@-1{{'ref' initialized here}}
|
|
|
|
int *arr = new int[ref]; // expected-warning{{Element count in new[] is a garbage value}}
|
|
// expected-note@-1{{Element count in new[] is a garbage value}}
|
|
}
|
|
|
|
void checkUndefinedElmenetCountMultiDimensionalReference() {
|
|
int n;
|
|
// expected-note@-1{{'n' declared without an initial value}}
|
|
|
|
int &ref = n;
|
|
// expected-note@-1{{'ref' initialized here}}
|
|
|
|
auto *arr = new int[ref][5]; // expected-warning{{Element count in new[] is a garbage value}}
|
|
// expected-note@-1{{Element count in new[] is a garbage value}}
|
|
}
|
|
|
|
int foo() {
|
|
int n;
|
|
|
|
return n;
|
|
}
|
|
|
|
void checkUndefinedElmenetCountFunction() {
|
|
int *arr = new int[foo()]; // expected-warning{{Element count in new[] is a garbage value}}
|
|
// expected-note@-1{{Element count in new[] is a garbage value}}
|
|
}
|
|
|
|
void checkUndefinedElmenetCountMultiDimensionalFunction() {
|
|
auto *arr = new int[foo()][5]; // expected-warning{{Element count in new[] is a garbage value}}
|
|
// expected-note@-1{{Element count in new[] is a garbage value}}
|
|
}
|
|
|
|
void *malloc(size_t);
|
|
|
|
void checkUndefinedPlacementElementCount() {
|
|
int n;
|
|
// expected-note@-1{{'n' declared without an initial value}}
|
|
|
|
void *buffer = malloc(sizeof(std::string) * 10);
|
|
std::string *p =
|
|
::new (buffer) std::string[n]; // expected-warning{{Element count in new[] is a garbage value}}
|
|
// expected-note@-1{{Element count in new[] is a garbage value}}
|
|
}
|