Files
RedBear-OS/local/recipes/dev/libclc/source/clang/lib/Testing/CommandLineArgs.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

114 lines
3.9 KiB
C++

//===--- CommandLineArgs.cpp ----------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "clang/Testing/CommandLineArgs.h"
#include "llvm/MC/TargetRegistry.h"
#include "llvm/Support/ErrorHandling.h"
namespace clang {
std::vector<TestLanguage> getCOrLater(const int MinimumStd) {
std::vector<TestLanguage> Result{};
#define TESTLANGUAGE_C(lang, version, std_flag, version_index) \
if (version >= MinimumStd) \
Result.push_back(Lang_##lang##version);
#include "clang/Testing/TestLanguage.def"
return Result;
}
std::vector<TestLanguage> getCXXOrLater(const int MinimumStd) {
std::vector<TestLanguage> Result{};
#define TESTLANGUAGE_CXX(lang, version, std_flag, version_index) \
if (version >= MinimumStd) \
Result.push_back(Lang_##lang##version);
#include "clang/Testing/TestLanguage.def"
return Result;
}
std::vector<std::string> getCommandLineArgsForTesting(TestLanguage Lang) {
// Test with basic arguments.
switch (Lang) {
#define TESTLANGUAGE_C(lang, version, std_flag, version_index) \
case Lang_##lang##version: \
return { "-x", "c", "-std=" #std_flag };
#define TESTLANGUAGE_CXX(lang, version, std_flag, version_index) \
case Lang_##lang##version: \
return { "-std=" #std_flag, "-frtti" };
#include "clang/Testing/TestLanguage.def"
case Lang_OBJC:
return {"-x", "objective-c", "-frtti", "-fobjc-nonfragile-abi"};
case Lang_OBJCXX:
return {"-x", "objective-c++", "-frtti"};
case Lang_OpenCL:
llvm_unreachable("Unhandled TestLanguage enum");
}
llvm_unreachable("Unhandled TestLanguage enum");
}
std::vector<std::string> getCC1ArgsForTesting(TestLanguage Lang) {
switch (Lang) {
#define TESTLANGUAGE_C(lang, version, std_flag, version_index) \
case Lang_##lang##version: \
return { "-xc", "-std=" #std_flag };
#define TESTLANGUAGE_CXX(lang, version, std_flag, version_index) \
case Lang_##lang##version: \
return { "-std=" #std_flag };
#include "clang/Testing/TestLanguage.def"
case Lang_OBJC:
return {"-xobjective-c"};
break;
case Lang_OBJCXX:
return {"-xobjective-c++"};
break;
case Lang_OpenCL:
llvm_unreachable("Unhandled TestLanguage enum");
}
llvm_unreachable("Unhandled TestLanguage enum");
}
StringRef getFilenameForTesting(TestLanguage Lang) {
switch (Lang) {
#define TESTLANGUAGE_C(lang, version, std_flag, version_index) \
case Lang_##lang##version: \
return "input.c";
#define TESTLANGUAGE_CXX(lang, version, std_flag, version_index) \
case Lang_##lang##version: \
return "input.cc";
#include "clang/Testing/TestLanguage.def"
case Lang_OpenCL:
return "input.cl";
case Lang_OBJC:
return "input.m";
case Lang_OBJCXX:
return "input.mm";
}
llvm_unreachable("Unhandled TestLanguage enum");
}
std::string getAnyTargetForTesting() {
for (const auto &Target : llvm::TargetRegistry::targets()) {
std::string Error;
StringRef TargetName(Target.getName());
if (TargetName == "x86-64")
TargetName = "x86_64";
if (llvm::TargetRegistry::lookupTarget(TargetName, Error) == &Target) {
return std::string(TargetName);
}
}
return "";
}
} // end namespace clang