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).
105 lines
2.8 KiB
C++
105 lines
2.8 KiB
C++
// RUN: %clang_cc1 %s -triple %itanium_abi_triple -std=c++11 -disable-O0-optnone -emit-llvm -o - | FileCheck %s
|
|
|
|
// Test optnone on template instantiations.
|
|
|
|
//-- Effect of optnone on generic add template function.
|
|
|
|
template <typename T> T template_normal(T a)
|
|
{
|
|
return a + a;
|
|
}
|
|
|
|
template <typename T> __attribute__((optnone)) T template_optnone(T a)
|
|
{
|
|
return a + a + a;
|
|
}
|
|
|
|
// This function should cause instantiations of each template, one marked
|
|
// with the 'optnone' attribute.
|
|
int container(int i)
|
|
{
|
|
return template_normal<int>(i) + template_optnone<int>(i);
|
|
}
|
|
|
|
// CHECK: @_Z15template_normalIiET_S0_({{.*}}) [[NORMAL:#[0-9]+]]
|
|
// CHECK: @_Z16template_optnoneIiET_S0_({{.*}}) [[OPTNONE:#[0-9]+]]
|
|
|
|
|
|
//-- Effect of optnone on a partial specialization.
|
|
// FIRST TEST: a method becomes marked with optnone in the specialization.
|
|
|
|
template <typename T, typename U> class template_normal_base {
|
|
public:
|
|
T method(T t, U u)
|
|
{
|
|
return t + static_cast<T>(u);
|
|
}
|
|
};
|
|
|
|
template <typename U> class template_normal_base<int, U>
|
|
{
|
|
public:
|
|
__attribute__((optnone)) int method (int t, U u)
|
|
{
|
|
return t - static_cast<int>(u);
|
|
}
|
|
};
|
|
|
|
// This function should cause an instantiation of the full template (whose
|
|
// method is not marked optnone) and an instantiation of the partially
|
|
// specialized template (whose method is marked optnone).
|
|
void container2()
|
|
{
|
|
int y = 2;
|
|
float z = 3.0;
|
|
template_normal_base<float, int> class_normal;
|
|
template_normal_base<int, float> class_optnone;
|
|
float r1 = class_normal.method(z, y);
|
|
float r2 = class_optnone.method(y, z);
|
|
}
|
|
|
|
// CHECK: @_ZN20template_normal_baseIfiE6methodEfi({{.*}}) [[NORMAL]]
|
|
// CHECK: @_ZN20template_normal_baseIifE6methodEif({{.*}}) [[OPTNONE]]
|
|
|
|
|
|
//-- Effect of optnone on a partial specialization.
|
|
// SECOND TEST: a method loses optnone in the specialization.
|
|
|
|
template <typename T, typename U> class template_optnone_base {
|
|
public:
|
|
__attribute__((optnone)) T method(T t, U u)
|
|
{
|
|
return t + static_cast<T>(u);
|
|
}
|
|
};
|
|
|
|
template <typename U> class template_optnone_base<int, U>
|
|
{
|
|
public:
|
|
int method (int t, U u)
|
|
{
|
|
return t - static_cast<int>(u);
|
|
}
|
|
};
|
|
|
|
// This function should cause an instantiation of the full template (whose
|
|
// method is marked optnone) and an instantiation of the partially
|
|
// specialized template (whose method is not marked optnone).
|
|
void container3()
|
|
{
|
|
int y = 2;
|
|
float z = 3.0;
|
|
template_optnone_base<float, int> class_optnone;
|
|
template_optnone_base<int, float> class_normal;
|
|
float r1 = class_optnone.method(z, y);
|
|
float r2 = class_normal.method(y, z);
|
|
}
|
|
|
|
// CHECK: @_ZN21template_optnone_baseIfiE6methodEfi({{.*}}) [[OPTNONE]]
|
|
// CHECK: @_ZN21template_optnone_baseIifE6methodEif({{.*}}) [[NORMAL]]
|
|
|
|
|
|
// CHECK: attributes [[NORMAL]] =
|
|
// CHECK-NOT: optnone
|
|
// CHECK: attributes [[OPTNONE]] = {{.*}} optnone
|