1//===- Error.h --------------------------------------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLVM_TOOLS_LLVM_DWARFUTIL_ERROR_H
10#define LLVM_TOOLS_LLVM_DWARFUTIL_ERROR_H
11
12#include "llvm/ADT/STLExtras.h"
13#include "llvm/ADT/StringRef.h"
14#include "llvm/Support/Debug.h"
15#include "llvm/Support/Error.h"
16#include "llvm/Support/Format.h"
17#include "llvm/Support/WithColor.h"
18#include "llvm/Support/raw_ostream.h"
19#include "llvm/TargetParser/Triple.h"
20
21namespace llvm {
22namespace dwarfutil {
23
24inline void error(Error Err, StringRef Prefix = "") {
25 handleAllErrors(E: std::move(Err), Handlers: [&](ErrorInfoBase &Info) {
26 WithColor::error(OS&: errs(), Prefix) << Info.message() << '\n';
27 });
28 std::exit(EXIT_FAILURE);
29}
30
31inline void warning(const Twine &Message, StringRef Prefix = "") {
32 WithColor::warning(OS&: errs(), Prefix) << Message << '\n';
33}
34
35inline void verbose(const Twine &Message, bool Verbose) {
36 if (Verbose)
37 outs() << Message << '\n';
38}
39
40} // end of namespace dwarfutil
41} // end of namespace llvm
42
43#endif // LLVM_TOOLS_LLVM_DWARFUTIL_ERROR_H
44

source code of llvm/tools/llvm-dwarfutil/Error.h