Files
RedBear-OS/local/recipes/dev/libclc/source/clang/test/Analysis/issue-70464.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

155 lines
4.4 KiB
C++

// RUN: %clang_analyze_cc1 %s -verify -analyzer-checker=core,debug.ExprInspection
// Refer to https://github.com/llvm/llvm-project/issues/70464 for more details.
//
// When the base class does not have a declared constructor, the base
// initializer in the constructor of the derived class should use the given
// initializer list to finish the initialization of the base class.
//
// Also testing base constructor and delegate constructor to make sure this
// change will not break these two cases when a CXXConstructExpr is available.
void clang_analyzer_dump(int);
namespace init_list {
struct Base {
int foox;
};
class Derived : public Base {
public:
Derived() : Base{42} {
// The dereference to this->foox below should be initialized properly.
clang_analyzer_dump(this->foox); // expected-warning{{42 S32b}}
clang_analyzer_dump(foox); // expected-warning{{42 S32b}}
}
};
void entry() { Derived test; }
} // namespace init_list
namespace base_ctor_call {
struct Base {
int foox;
Base(int x) : foox(x) {}
};
class Derived : public Base {
public:
Derived() : Base{42} {
clang_analyzer_dump(this->foox); // expected-warning{{42 S32b}}
clang_analyzer_dump(foox); // expected-warning{{42 S32b}}
}
};
void entry() { Derived test; }
} // namespace base_ctor_call
namespace delegate_ctor_call {
struct Base {
int foox;
};
struct Derived : Base {
Derived(int parx) { this->foox = parx; }
Derived() : Derived{42} {
clang_analyzer_dump(this->foox); // expected-warning{{42 S32b}}
clang_analyzer_dump(foox); // expected-warning{{42 S32b}}
}
};
void entry() { Derived test; }
} // namespace delegate_ctor_call
// Additional test case from issue #59493
namespace init_list_array {
struct Base {
int foox[5];
};
class Derived1 : public Base {
public:
Derived1() : Base{{1,4,5,3,2}} {
// The dereference to this->foox below should be initialized properly.
clang_analyzer_dump(this->foox[0]); // expected-warning{{1 S32b}}
clang_analyzer_dump(this->foox[1]); // expected-warning{{4 S32b}}
clang_analyzer_dump(this->foox[2]); // expected-warning{{5 S32b}}
clang_analyzer_dump(this->foox[3]); // expected-warning{{3 S32b}}
clang_analyzer_dump(this->foox[4]); // expected-warning{{2 S32b}}
clang_analyzer_dump(foox[0]); // expected-warning{{1 S32b}}
clang_analyzer_dump(foox[1]); // expected-warning{{4 S32b}}
clang_analyzer_dump(foox[2]); // expected-warning{{5 S32b}}
clang_analyzer_dump(foox[3]); // expected-warning{{3 S32b}}
clang_analyzer_dump(foox[4]); // expected-warning{{2 S32b}}
}
};
void entry1() { Derived1 test; }
class Derived2 : public Base {
public:
Derived2() : Base{{0}} {
// The dereference to this->foox below should be initialized properly.
clang_analyzer_dump(this->foox[0]); // expected-warning{{0 S32b}}
clang_analyzer_dump(this->foox[1]); // expected-warning{{0 S32b}}
clang_analyzer_dump(this->foox[2]); // expected-warning{{0 S32b}}
clang_analyzer_dump(this->foox[3]); // expected-warning{{0 S32b}}
clang_analyzer_dump(this->foox[4]); // expected-warning{{0 S32b}}
clang_analyzer_dump(foox[0]); // expected-warning{{0 S32b}}
clang_analyzer_dump(foox[1]); // expected-warning{{0 S32b}}
clang_analyzer_dump(foox[2]); // expected-warning{{0 S32b}}
clang_analyzer_dump(foox[3]); // expected-warning{{0 S32b}}
clang_analyzer_dump(foox[4]); // expected-warning{{0 S32b}}
}
};
void entry2() { Derived2 test; }
} // namespace init_list_array
namespace init_list_struct {
struct Base {
struct { int a; int b; } foox;
};
class Derived : public Base {
public:
Derived() : Base{{42, 24}} {
// The dereference to this->foox below should be initialized properly.
clang_analyzer_dump(this->foox.a); // expected-warning{{42 S32b}}
clang_analyzer_dump(this->foox.b); // expected-warning{{24 S32b}}
clang_analyzer_dump(foox.a); // expected-warning{{42 S32b}}
clang_analyzer_dump(foox.b); // expected-warning{{24 S32b}}
}
};
} // namespace init_list_struct
// Additional test case from issue 54533
namespace init_list_enum {
struct Base {
enum : unsigned char { ZERO = 0, FORTY_TWO = 42 } foox;
};
class Derived : public Base {
public:
Derived() : Base{FORTY_TWO} {
// The dereference to this->foox below should be initialized properly.
clang_analyzer_dump(this->foox); // expected-warning{{42 S32b}}
clang_analyzer_dump(foox); // expected-warning{{42 S32b}}
}
};
void entry() { Derived test; }
} // namespace init_list_enum