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).
106 lines
3.3 KiB
C++
106 lines
3.3 KiB
C++
//===--- TextDiagnostic.cpp - Text Diagnostic Pretty-Printing -------------===//
|
|
//
|
|
// 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
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// Coding style: https://mlir.llvm.org/getting_started/DeveloperGuide/
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "flang/Frontend/TextDiagnostic.h"
|
|
#include "clang/Basic/DiagnosticOptions.h"
|
|
#include "llvm/Support/raw_ostream.h"
|
|
|
|
using namespace Fortran::frontend;
|
|
|
|
// TODO: Similar enums are defined in clang/lib/Frontend/TextDiagnostic.cpp.
|
|
// It would be best to share them
|
|
static const enum llvm::raw_ostream::Colors noteColor =
|
|
llvm::raw_ostream::BLACK;
|
|
static const enum llvm::raw_ostream::Colors remarkColor =
|
|
llvm::raw_ostream::BLUE;
|
|
static const enum llvm::raw_ostream::Colors warningColor =
|
|
llvm::raw_ostream::MAGENTA;
|
|
static const enum llvm::raw_ostream::Colors errorColor = llvm::raw_ostream::RED;
|
|
static const enum llvm::raw_ostream::Colors fatalColor = llvm::raw_ostream::RED;
|
|
// Used for changing only the bold attribute.
|
|
static const enum llvm::raw_ostream::Colors savedColor =
|
|
llvm::raw_ostream::SAVEDCOLOR;
|
|
|
|
TextDiagnostic::TextDiagnostic() {}
|
|
|
|
TextDiagnostic::~TextDiagnostic() {}
|
|
|
|
/*static*/ void
|
|
TextDiagnostic::printDiagnosticLevel(llvm::raw_ostream &os,
|
|
clang::DiagnosticsEngine::Level level,
|
|
bool showColors) {
|
|
if (showColors) {
|
|
// Print diagnostic category in bold and color
|
|
switch (level) {
|
|
case clang::DiagnosticsEngine::Ignored:
|
|
llvm_unreachable("Invalid diagnostic type");
|
|
case clang::DiagnosticsEngine::Note:
|
|
os.changeColor(noteColor, true);
|
|
break;
|
|
case clang::DiagnosticsEngine::Remark:
|
|
os.changeColor(remarkColor, true);
|
|
break;
|
|
case clang::DiagnosticsEngine::Warning:
|
|
os.changeColor(warningColor, true);
|
|
break;
|
|
case clang::DiagnosticsEngine::Error:
|
|
os.changeColor(errorColor, true);
|
|
break;
|
|
case clang::DiagnosticsEngine::Fatal:
|
|
os.changeColor(fatalColor, true);
|
|
break;
|
|
}
|
|
}
|
|
|
|
switch (level) {
|
|
case clang::DiagnosticsEngine::Ignored:
|
|
llvm_unreachable("Invalid diagnostic type");
|
|
case clang::DiagnosticsEngine::Note:
|
|
os << "note";
|
|
break;
|
|
case clang::DiagnosticsEngine::Remark:
|
|
os << "remark";
|
|
break;
|
|
case clang::DiagnosticsEngine::Warning:
|
|
os << "warning";
|
|
break;
|
|
case clang::DiagnosticsEngine::Error:
|
|
os << "error";
|
|
break;
|
|
case clang::DiagnosticsEngine::Fatal:
|
|
os << "fatal error";
|
|
break;
|
|
}
|
|
|
|
os << ": ";
|
|
|
|
if (showColors)
|
|
os.resetColor();
|
|
}
|
|
|
|
/*static*/
|
|
void TextDiagnostic::printDiagnosticMessage(llvm::raw_ostream &os,
|
|
bool isSupplemental,
|
|
llvm::StringRef message,
|
|
bool showColors) {
|
|
if (showColors && !isSupplemental) {
|
|
// Print primary diagnostic messages in bold and without color.
|
|
os.changeColor(savedColor, true);
|
|
}
|
|
|
|
os << message;
|
|
|
|
if (showColors)
|
|
os.resetColor();
|
|
os << '\n';
|
|
}
|