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).
74 lines
2.8 KiB
C++
74 lines
2.8 KiB
C++
// RUN: rm -rf %t
|
|
// RUN: split-file %s %t
|
|
// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/no-lsv -I%t %t/stddef.cpp -verify
|
|
// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-local-submodule-visibility -fmodules-cache-path=%t/lsv -I%t %t/stddef.cpp -verify
|
|
|
|
//--- stddef.cpp
|
|
#include <b.h>
|
|
|
|
void *pointer = NULL;
|
|
size_t size = 0;
|
|
|
|
// When building with modules, a pcm is never re-imported, so re-including
|
|
// stddef.h will not re-import _Builtin_stddef.null to restore the definition of
|
|
// NULL, even though stddef.h will unconditionally include __stddef_null.h when
|
|
// building with modules.
|
|
#undef NULL
|
|
#include <stddef.h>
|
|
|
|
void *anotherPointer = NULL; // expected-error{{use of undeclared identifier 'NULL'}}
|
|
|
|
// stddef.h needs to be a `textual` header to support clients doing things like
|
|
// this.
|
|
//
|
|
// #define __need_NULL
|
|
// #include <stddef.h>
|
|
//
|
|
// As a textual header designed to be included multiple times, it can't directly
|
|
// declare anything, or those declarations would go into every module that
|
|
// included it. e.g. if stddef.h contained all of its declarations, and modules
|
|
// A and B included stddef.h, they would both have the declaration for size_t.
|
|
// That breaks Swift, which uses the module name as part of the type name, i.e.
|
|
// A.size_t and B.size_t are treated as completely different types in Swift and
|
|
// cannot be interchanged. To fix that, stddef.h (and stdarg.h) are split out
|
|
// into a separate file per __need macro that can be normal headers in explicit
|
|
// submodules. That runs into yet another wrinkle though. When modules build,
|
|
// declarations from previous submodules leak into subsequent ones when not
|
|
// using local submodule visibility. Consider if stddef.h did the normal thing.
|
|
//
|
|
// #ifndef __STDDEF_H
|
|
// #define __STDDEF_H
|
|
// // include all of the sub-headers
|
|
// #endif
|
|
//
|
|
// When SM builds without local submodule visibility, it will precompile a.h
|
|
// first. When it gets to b.h, the __STDDEF_H declaration from precompiling a.h
|
|
// will leak, and so when b.h includes stddef.h, it won't include any of its
|
|
// sub-headers, and SM.B will thus not import _Builtin_stddef or make any of its
|
|
// submodules visible. Precompiling b.h will be fine since it sees all of the
|
|
// declarations from a.h including stddef.h, but clients that only include b.h
|
|
// will not see any of the stddef.h types. stddef.h thus has to make sure to
|
|
// always include the necessary sub-headers, even if they've been included
|
|
// already. They all have their own header guards to allow this.
|
|
// __stddef_null.h is extra special, so this test makes sure to cover NULL plus
|
|
// one of the normal stddef.h types.
|
|
|
|
//--- module.modulemap
|
|
module SM {
|
|
module A {
|
|
header "a.h"
|
|
export *
|
|
}
|
|
|
|
module B {
|
|
header "b.h"
|
|
export *
|
|
}
|
|
}
|
|
|
|
//--- a.h
|
|
#include <stddef.h>
|
|
|
|
//--- b.h
|
|
#include <stddef.h>
|