Merge detect_clang_bug96267

This commit is contained in:
Luke Dashjr 2024-06-21 19:28:12 +00:00
commit b1fd3a60a7
3 changed files with 22 additions and 0 deletions

View File

@ -14,12 +14,30 @@
namespace kernel {
bool Clang_IndVarSimplify_Bug_SanityCheck() {
// See https://github.com/llvm/llvm-project/issues/96267
const char s[] = {0, 0x75};
signed int last = 0xff;
for (const char *it = s; it < &s[2]; ++it) {
if (*it <= 0x4e) {
} else if (*it == 0x75 && last <= 0x4e) {
return true;
}
last = *it;
}
return false;
}
util::Result<void> SanityChecks(const Context&)
{
if (!dbwrapper_SanityCheck()) {
return util::Error{Untranslated("Database sanity check failure. Aborting.")};
}
if (!Clang_IndVarSimplify_Bug_SanityCheck()) {
return util::Error{Untranslated("Compiler optimization sanity check failure. Aborting.")};
}
if (!ECC_InitSanityCheck()) {
return util::Error{Untranslated("Elliptic curve cryptography sanity check failure. Aborting.")};
}

View File

@ -11,6 +11,8 @@ namespace kernel {
struct Context;
[[nodiscard]] bool Clang_IndVarSimplify_Bug_SanityCheck();
/**
* Ensure a usable environment with all necessary library support.
*/

View File

@ -3,6 +3,7 @@
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <dbwrapper.h>
#include <kernel/checks.h>
#include <key.h>
#include <test/util/setup_common.h>
#include <util/time.h>
@ -14,6 +15,7 @@ BOOST_FIXTURE_TEST_SUITE(sanity_tests, BasicTestingSetup)
BOOST_AUTO_TEST_CASE(basic_sanity)
{
BOOST_CHECK_MESSAGE(dbwrapper_SanityCheck() == true, "dbwrapper sanity test");
BOOST_CHECK_MESSAGE(kernel::Clang_IndVarSimplify_Bug_SanityCheck() == true, "Clang IndVarSimplify bug sanity test");
BOOST_CHECK_MESSAGE(ECC_InitSanityCheck() == true, "secp256k1 sanity test");
BOOST_CHECK_MESSAGE(ChronoSanityCheck() == true, "chrono epoch test");
}