2013-04-03 18:31:38 +00:00
|
|
|
//===-- llvm-readobj.h ----------------------------------------------------===//
|
2013-02-20 02:37:12 +00:00
|
|
|
//
|
2019-01-19 08:50:56 +00:00
|
|
|
// 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
|
2013-02-20 02:37:12 +00:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2014-08-13 16:26:38 +00:00
|
|
|
#ifndef LLVM_TOOLS_LLVM_READOBJ_LLVM_READOBJ_H
|
|
|
|
#define LLVM_TOOLS_LLVM_READOBJ_LLVM_READOBJ_H
|
2013-02-20 02:37:12 +00:00
|
|
|
|
2022-03-31 09:36:10 -04:00
|
|
|
#include "ObjDumper.h"
|
|
|
|
|
|
|
|
#include "llvm/ADT/SmallVector.h"
|
2013-04-03 18:31:38 +00:00
|
|
|
#include "llvm/Support/CommandLine.h"
|
2015-12-04 21:29:53 +00:00
|
|
|
#include "llvm/Support/Compiler.h"
|
2022-03-31 09:33:04 -04:00
|
|
|
#include "llvm/Support/Error.h"
|
2022-03-31 09:36:10 -04:00
|
|
|
#include "llvm/Support/ErrorOr.h"
|
2013-02-20 02:37:12 +00:00
|
|
|
|
|
|
|
namespace llvm {
|
2013-04-03 18:31:38 +00:00
|
|
|
namespace object {
|
|
|
|
class RelocationRef;
|
|
|
|
}
|
2013-02-20 02:37:12 +00:00
|
|
|
|
2013-04-03 18:31:38 +00:00
|
|
|
// Various helper functions.
|
2021-07-28 09:31:14 -07:00
|
|
|
[[noreturn]] void reportError(Error Err, StringRef Input);
|
Recommit r369190 "[llvm-readobj/llvm-readelf] - Improve/cleanup the error reporting API."
Fix: Add a `consumeError` call removed by mistake to 'printStackSize',
this should fix the "Expected<T> must be checked before access or destruction." reported by following bot:
http://lab.llvm.org:8011/builders/clang-x64-windows-msvc/builds/9743/steps/stage%201%20check/logs/stdio
Original commit message:
Currently we have the following functions for error reporting:
LLVM_ATTRIBUTE_NORETURN void reportError(Twine Msg);
void reportError(Error Err, StringRef Input);
void reportWarning(Twine Msg);
void reportWarning(StringRef Input, Error Err);
void warn(llvm::Error Err);
void error(std::error_code EC);
Problems are: naming is inconsistent, arguments order is inconsistent,
some of the functions looks excessive.
After applying this patch we have:
void reportError(Error Err, StringRef Input);
void reportError(std::error_code EC, StringRef Input);
void reportWarning(Error Err, StringRef Input);
I'd be happy to remove reportError(std::error_code EC, StringRef Input) too, but it
is used by COFF heavily.
Test cases were updated, they show an improvement introduced.
Differential revision: https://reviews.llvm.org/D66286
llvm-svn: 369194
2019-08-17 16:07:18 +00:00
|
|
|
void reportWarning(Error Err, StringRef Input);
|
2017-05-03 17:11:11 +00:00
|
|
|
|
2019-08-08 07:17:35 +00:00
|
|
|
template <class T> T unwrapOrError(StringRef Input, Expected<T> EO) {
|
|
|
|
if (EO)
|
|
|
|
return *EO;
|
2019-08-13 12:07:41 +00:00
|
|
|
reportError(EO.takeError(), Input);
|
2019-08-08 07:17:35 +00:00
|
|
|
}
|
2013-04-03 18:31:38 +00:00
|
|
|
} // namespace llvm
|
|
|
|
|
|
|
|
namespace opts {
|
2021-07-12 10:14:42 -07:00
|
|
|
extern bool SectionRelocations;
|
|
|
|
extern bool SectionSymbols;
|
|
|
|
extern bool SectionData;
|
|
|
|
extern bool ExpandRelocs;
|
|
|
|
extern bool CodeViewSubsectionBytes;
|
|
|
|
extern bool Demangle;
|
2021-12-10 23:27:06 +00:00
|
|
|
enum OutputStyleTy { LLVM, GNU, JSON, UNKNOWN };
|
2021-07-12 10:14:42 -07:00
|
|
|
extern OutputStyleTy Output;
|
2013-04-03 18:31:38 +00:00
|
|
|
} // namespace opts
|
|
|
|
|
|
|
|
#define LLVM_READOBJ_ENUM_ENT(ns, enum) \
|
|
|
|
{ #enum, ns::enum }
|
2013-02-20 02:37:12 +00:00
|
|
|
|
2016-01-13 19:32:35 +00:00
|
|
|
#define LLVM_READOBJ_ENUM_CLASS_ENT(enum_class, enum) \
|
2022-09-25 23:14:15 -07:00
|
|
|
{ #enum, std::underlying_type_t<enum_class>(enum_class::enum) }
|
2016-01-13 19:32:35 +00:00
|
|
|
|
2013-02-20 02:37:12 +00:00
|
|
|
#endif
|