Go to the documentation of this file.
25 assert(Ctx &&
"Expected non-null Ctx in diagnostic handler.");
26 std::string &Message = *
static_cast<std::string *
>(Ctx);
27 assert(Message.empty() &&
"Expected an empty string.");
29 Diag.
print(
nullptr, OS,
false,
66 "Expecting \\0 after magic number.");
73 "Expecting version number.");
76 support::endian::read<uint64_t, support::little, support::unaligned>(
80 "Mismatching remark version. Got %" PRId64
81 ", expected %" PRId64
".",
90 "Expecting string table size.");
92 support::endian::read<uint64_t, support::little, support::unaligned>(
100 if (Buf.
size() < StrTabSize)
102 "Expecting string table.");
119 std::unique_ptr<MemoryBuffer> SeparateBuf;
130 if (*StrTabSize != 0) {
133 "String table already provided.");
144 if (ExternalFilePrependPath)
145 FullPath = *ExternalFilePrependPath;
151 if (std::error_code EC = BufferOrErr.
getError())
156 Buf = SeparateBuf->getBuffer();
160 std::unique_ptr<YAMLRemarkParser> Result =
162 ? std::make_unique<YAMLStrTabRemarkParser>(Buf,
std::move(*StrTab))
163 : std::make_unique<YAMLRemarkParser>(Buf);
165 Result->SeparateBuf =
std::move(SeparateBuf);
175 SM(
setupSM(LastErrorMessage)), Stream(Buf, SM), YAMLIt(Stream.begin()) {}
178 return make_error<YAMLParseError>(Message,
SM,
Stream, Node);
197 "not a valid YAML file.");
200 auto *Root = dyn_cast<yaml::MappingNode>(YAMLRoot);
202 return error(
"document root is not of mapping type.", *YAMLRoot);
204 std::unique_ptr<Remark> Result = std::make_unique<Remark>();
205 Remark &TheRemark = *Result;
211 return T.takeError();
222 if (KeyName ==
"Pass") {
226 return MaybeStr.takeError();
227 }
else if (KeyName ==
"Name") {
231 return MaybeStr.takeError();
232 }
else if (KeyName ==
"Function") {
236 return MaybeStr.takeError();
237 }
else if (KeyName ==
"Hotness") {
241 return MaybeU.takeError();
242 }
else if (KeyName ==
"DebugLoc") {
244 TheRemark.
Loc = *MaybeLoc;
246 return MaybeLoc.takeError();
247 }
else if (KeyName ==
"Args") {
248 auto *
Args = dyn_cast<yaml::SequenceNode>(RemarkField.getValue());
250 return error(
"wrong value type for key.", RemarkField);
254 TheRemark.
Args.push_back(*MaybeArg);
256 return MaybeArg.takeError();
259 return error(
"unknown key.", RemarkField);
266 return error(
"Type, Pass, Name or Function missing.",
282 return error(
"expected a remark tag.", Node);
287 if (
auto *
Key = dyn_cast<yaml::ScalarNode>(Node.getKey()))
288 return Key->getRawValue();
290 return error(
"key is not a string.", Node);
294 auto *
Value = dyn_cast<yaml::ScalarNode>(Node.getValue());
296 return error(
"expected a value of scalar type.", Node);
299 if (Result.front() ==
'\'')
300 Result = Result.drop_front();
302 if (Result.back() ==
'\'')
303 Result = Result.drop_back();
310 auto *
Value = dyn_cast<yaml::ScalarNode>(Node.getValue());
312 return error(
"expected a value of scalar type.", Node);
313 unsigned UnsignedValue = 0;
314 if (
Value->getValue(Tmp).getAsInteger(10, UnsignedValue))
315 return error(
"expected a value of integer type.", *
Value);
316 return UnsignedValue;
321 auto *
DebugLoc = dyn_cast<yaml::MappingNode>(Node.getValue());
323 return error(
"expected a value of mapping type.", Node);
335 if (KeyName ==
"File") {
339 return MaybeStr.takeError();
340 }
else if (KeyName ==
"Column") {
344 return MaybeU.takeError();
345 }
else if (KeyName ==
"Line") {
349 return MaybeU.takeError();
351 return error(
"unknown entry in DebugLoc map.", DLNode);
356 if (!File || !Line || !Column)
357 return error(
"DebugLoc node incomplete.", Node);
363 auto *ArgMap = dyn_cast<yaml::MappingNode>(&Node);
365 return error(
"expected a value of mapping type.", Node);
378 if (KeyName ==
"DebugLoc") {
381 return error(
"only one DebugLoc entry is allowed per argument.",
388 return MaybeLoc.takeError();
393 return error(
"only one string entry is allowed per argument.", ArgEntry);
397 ValueStr = *MaybeStr;
399 return MaybeStr.takeError();
406 return error(
"argument key is missing.", *ArgMap);
408 return error(
"argument value is missing.", *ArgMap);
410 return Argument{*KeyStr, *ValueStr, Loc};
415 return make_error<EndOfFileError>();
430 auto *
Value = dyn_cast<yaml::ScalarNode>(Node.getValue());
432 return error(
"expected a value of scalar type.", Node);
439 return MaybeStrID.takeError();
444 return Str.takeError();
446 if (Result.front() ==
'\'')
447 Result = Result.drop_front();
449 if (Result.back() ==
'\'')
450 Result = Result.drop_back();
StringSwitch & Case(StringLiteral S, T Value)
A YAML Stream is a sequence of Documents.
LLVM_NODISCARD bool startswith(StringRef Prefix) const
Check if this string starts with the given Prefix.
This is an optimization pass for GlobalISel generic memory operations.
LLVM_NODISCARD R Default(T Value)
A raw_ostream that writes to an std::string.
Abstract base class for all Nodes.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
static ErrorSuccess success()
Create a success value.
bool consume_front(StringRef Prefix)
Returns true if this StringRef has the given prefix and removes that prefix.
Represents a YAML map created from either a block map for a flow map.
Tagged union holding either a T or a Error.
void append(SmallVectorImpl< char > &path, const Twine &a, const Twine &b="", const Twine &c="", const Twine &d="")
Append to path.
amdgpu Simplify well known AMD library false FunctionCallee Value * Arg
static ErrorOr< std::unique_ptr< MemoryBuffer > > getFile(const Twine &Filename, bool IsText=false, bool RequiresNullTerminator=true, bool IsVolatile=false)
Open the specified file as a MemoryBuffer, returning a new MemoryBuffer if successful,...
Error createFileError(const Twine &F, Error E)
Concatenate a source file path and/or name with an Error.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
Instances of this class encapsulate one diagnostic report, allowing printing to a raw_ostream as a ca...
std::error_code getError() const
void setDiagHandler(DiagHandlerTy DH, void *Ctx=nullptr)
Specify a diagnostic handler to be invoked every time PrintMessage is called.
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
constexpr LLVM_NODISCARD bool empty() const
empty - Check if the string is empty.
void print(const char *ProgName, raw_ostream &S, bool ShowColors=true, bool ShowKindLabel=true) const
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional move
void * getDiagContext() const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
DiagHandlerTy getDiagHandler() const
Node * getRoot()
Parse and return the root level node.
StringRef - Represent a constant reference to a string, i.e.
This owns the files read by a parser, handles include stacks, and handles diagnostic wrangling.
This class represents a YAML stream potentially containing multiple documents.
std::error_code make_error_code(BitcodeError E)
const CustomOperand< const MCSubtargetInfo & > Msg[]
constexpr LLVM_NODISCARD size_t size() const
size - Get the string size.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Error createStringError(std::error_code EC, char const *Fmt, const Ts &... Vals)
Create formatted StringError object.
LLVM_NODISCARD StringRef drop_front(size_t N=1) const
Return a StringRef equal to 'this' but with the first N elements dropped.
Lightweight error class with error context and mandatory checking.
Error takeError()
Take ownership of the stored error.
Represents either an error or a value T.
const LLVM_NODISCARD char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
A switch()-like statement whose cases are string literals.
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
LLVM Value Representation.