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).
75 lines
2.3 KiB
C++
75 lines
2.3 KiB
C++
//===-- Demangle.cpp - Common demangling functions ------------------------===//
|
|
//
|
|
// 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
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
///
|
|
/// \file This file contains definitions of common demangling functions.
|
|
///
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "llvm/Demangle/Demangle.h"
|
|
#include "llvm/Demangle/StringViewExtras.h"
|
|
#include <cstdlib>
|
|
#include <string_view>
|
|
|
|
using llvm::itanium_demangle::starts_with;
|
|
|
|
std::string llvm::demangle(std::string_view MangledName) {
|
|
std::string Result;
|
|
|
|
if (nonMicrosoftDemangle(MangledName, Result))
|
|
return Result;
|
|
|
|
if (starts_with(MangledName, '_') &&
|
|
nonMicrosoftDemangle(MangledName.substr(1), Result,
|
|
/*CanHaveLeadingDot=*/false))
|
|
return Result;
|
|
|
|
if (char *Demangled = microsoftDemangle(MangledName, nullptr, nullptr)) {
|
|
Result = Demangled;
|
|
std::free(Demangled);
|
|
} else {
|
|
Result = MangledName;
|
|
}
|
|
return Result;
|
|
}
|
|
|
|
static bool isItaniumEncoding(std::string_view S) {
|
|
// Itanium demangler supports prefixes with 1-4 underscores.
|
|
const size_t Pos = S.find_first_not_of('_');
|
|
return Pos > 0 && Pos <= 4 && S[Pos] == 'Z';
|
|
}
|
|
|
|
static bool isRustEncoding(std::string_view S) { return starts_with(S, "_R"); }
|
|
|
|
static bool isDLangEncoding(std::string_view S) { return starts_with(S, "_D"); }
|
|
|
|
bool llvm::nonMicrosoftDemangle(std::string_view MangledName,
|
|
std::string &Result, bool CanHaveLeadingDot,
|
|
bool ParseParams) {
|
|
char *Demangled = nullptr;
|
|
|
|
// Do not consider the dot prefix as part of the demangled symbol name.
|
|
if (CanHaveLeadingDot && MangledName.size() > 0 && MangledName[0] == '.') {
|
|
MangledName.remove_prefix(1);
|
|
Result = ".";
|
|
}
|
|
|
|
if (isItaniumEncoding(MangledName))
|
|
Demangled = itaniumDemangle(MangledName, ParseParams);
|
|
else if (isRustEncoding(MangledName))
|
|
Demangled = rustDemangle(MangledName);
|
|
else if (isDLangEncoding(MangledName))
|
|
Demangled = dlangDemangle(MangledName);
|
|
|
|
if (!Demangled)
|
|
return false;
|
|
|
|
Result += Demangled;
|
|
std::free(Demangled);
|
|
return true;
|
|
}
|