15#include "BitstreamRemarkParser.h"
27 while (!InBuffer.
empty()) {
29 std::pair<StringRef, StringRef> Split = InBuffer.
split(
'\0');
32 InBuffer = Split.second;
39 std::make_error_code(std::errc::invalid_argument),
40 "String with index %u is out of bounds (size = %u).", Index,
53 switch (ParserFormat) {
55 return std::make_unique<YAMLRemarkParser>(Buf);
58 std::make_error_code(std::errc::invalid_argument),
59 "The YAML with string table format requires a parsed string table.");
61 return std::make_unique<BitstreamRemarkParser>(Buf);
64 "Unknown remark parser format.");
72 switch (ParserFormat) {
75 "The YAML format can't be used with a string "
76 "table. Use yaml-strtab instead.");
78 return std::make_unique<YAMLStrTabRemarkParser>(Buf, std::move(StrTab));
80 return std::make_unique<BitstreamRemarkParser>(Buf, std::move(StrTab));
83 "Unknown remark parser format.");
90 Format ParserFormat,
StringRef Buf, std::optional<ParsedStringTable> StrTab,
91 std::optional<StringRef> ExternalFilePrependPath) {
92 switch (ParserFormat) {
98 std::move(ExternalFilePrependPath));
101 std::move(ExternalFilePrependPath));
104 "Unknown remark parser format.");
112 std::unique_ptr<RemarkParser> TheParser;
113 std::optional<std::string> Err;
116 std::optional<ParsedStringTable> StrTab = std::nullopt)
122 bool hasError()
const {
return Err.has_value(); }
123 const char *getMessage()
const {
return Err ? Err->c_str() :
nullptr; };
144 CParser &TheCParser = *
unwrap(Parser);
156 TheCParser.handleError(std::move(E));
161 return wrap(MaybeRemark->release());
165 return unwrap(Parser)->hasError();
168extern "C" const char *
170 return unwrap(Parser)->getMessage();
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
#define DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ty, ref)
Lightweight error class with error context and mandatory checking.
bool isA() const
Check whether one error is a subclass of another.
Tagged union holding either a T or a Error.
Error takeError()
Take ownership of the stored error.
StringRef - Represent a constant reference to a string, i.e.
std::pair< StringRef, StringRef > split(char Separator) const
Split into two substrings around the first occurrence of a separator character.
constexpr bool empty() const
empty - Check if the string is empty.
constexpr size_t size() const
size - Get the string size.
constexpr const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ C
The default llvm calling convention, compatible with C.
This is an optimization pass for GlobalISel generic memory operations.
Error createStringError(std::error_code EC, char const *Fmt, const Ts &... Vals)
Create formatted StringError object.
void cantFail(Error Err, const char *Msg=nullptr)
Report a fatal error if Err is a failure value.
Attribute unwrap(LLVMAttributeRef Attr)
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
LLVMAttributeRef wrap(Attribute Attr)
const char * toString(DWARFSectionKind Kind)
void consumeError(Error Err)
Consume a Error without doing anything.
Implement std::hash so that hash_code can be used in STL containers.