26 assert(Ctx &&
"Expected non-null Ctx in diagnostic handler.");
27 std::string &Message = *
static_cast<std::string *
>(Ctx);
28 assert(Message.empty() &&
"Expected an empty string.");
30 Diag.
print(
nullptr, OS,
false,
67 "Expecting \\0 after magic number.");
72 if (Buf.
size() <
sizeof(uint64_t))
74 "Expecting version number.");
77 support::endian::read<uint64_t, support::little, support::unaligned>(
81 "Mismatching remark version. Got %" PRId64
82 ", expected %" PRId64
".",
89 if (Buf.
size() <
sizeof(uint64_t))
91 "Expecting string table size.");
93 support::endian::read<uint64_t, support::little, support::unaligned>(
100 uint64_t StrTabSize) {
101 if (Buf.
size() < StrTabSize)
103 "Expecting string table.");
120 std::unique_ptr<MemoryBuffer> SeparateBuf;
131 if (*StrTabSize != 0) {
134 "String table already provided.");
138 StrTab = std::move(*MaybeStrTab);
145 if (ExternalFilePrependPath)
146 FullPath = *ExternalFilePrependPath;
152 if (std::error_code EC = BufferOrErr.
getError())
156 SeparateBuf = std::move(*BufferOrErr);
157 Buf = SeparateBuf->getBuffer();
161 std::unique_ptr<YAMLRemarkParser> Result =
163 ? std::make_unique<YAMLStrTabRemarkParser>(Buf, std::move(*StrTab))
164 : std::make_unique<YAMLRemarkParser>(Buf);
166 Result->SeparateBuf = std::move(SeparateBuf);
167 return std::move(Result);
179 return make_error<YAMLParseError>(Message,
SM,
Stream, Node);
198 "not a valid YAML file.");
203 return error(
"document root is not of mapping type.", *YAMLRoot);
205 std::unique_ptr<Remark> Result = std::make_unique<Remark>();
206 Remark &TheRemark = *Result;
214 TheRemark.RemarkType = *
T;
223 if (KeyName ==
"Pass") {
225 TheRemark.PassName = *MaybeStr;
228 }
else if (KeyName ==
"Name") {
230 TheRemark.RemarkName = *MaybeStr;
232 return MaybeStr.takeError();
233 }
else if (KeyName ==
"Function") {
235 TheRemark.FunctionName = *MaybeStr;
237 return MaybeStr.takeError();
238 }
else if (KeyName ==
"Hotness") {
240 TheRemark.Hotness = *MaybeU;
242 return MaybeU.takeError();
243 }
else if (KeyName ==
"DebugLoc") {
245 TheRemark.Loc = *MaybeLoc;
247 return MaybeLoc.takeError();
248 }
else if (KeyName ==
"Args") {
251 return error(
"wrong value type for key.", RemarkField);
255 TheRemark.Args.push_back(*MaybeArg);
257 return MaybeArg.takeError();
260 return error(
"unknown key.", RemarkField);
265 if (TheRemark.RemarkType ==
Type::Unknown || TheRemark.PassName.empty() ||
266 TheRemark.RemarkName.empty() || TheRemark.FunctionName.empty())
267 return error(
"Type, Pass, Name or Function missing.",
270 return std::move(Result);
283 return error(
"expected a remark tag.", Node);
288 if (
auto *
Key = dyn_cast<yaml::ScalarNode>(Node.
getKey()))
289 return Key->getRawValue();
291 return error(
"key is not a string.", Node);
297 return error(
"expected a value of scalar type.", Node);
300 if (Result.
front() ==
'\'')
303 if (Result.
back() ==
'\'')
313 return error(
"expected a value of scalar type.", Node);
314 unsigned UnsignedValue = 0;
315 if (
Value->getValue(Tmp).getAsInteger(10, UnsignedValue))
316 return error(
"expected a value of integer type.", *
Value);
317 return UnsignedValue;
324 return error(
"expected a value of mapping type.", Node);
336 if (KeyName ==
"File") {
340 return MaybeStr.takeError();
341 }
else if (KeyName ==
"Column") {
345 return MaybeU.takeError();
346 }
else if (KeyName ==
"Line") {
350 return MaybeU.takeError();
352 return error(
"unknown entry in DebugLoc map.", DLNode);
357 if (!File || !Line || !Column)
358 return error(
"DebugLoc node incomplete.", Node);
366 return error(
"expected a value of mapping type.", Node);
379 if (KeyName ==
"DebugLoc") {
382 return error(
"only one DebugLoc entry is allowed per argument.",
389 return MaybeLoc.takeError();
394 return error(
"only one string entry is allowed per argument.", ArgEntry);
398 ValueStr = *MaybeStr;
400 return MaybeStr.takeError();
407 return error(
"argument key is missing.", *ArgMap);
409 return error(
"argument value is missing.", *ArgMap);
411 return Argument{*KeyStr, *ValueStr, Loc};
416 return make_error<EndOfFileError>();
427 return std::move(*MaybeResult);
433 return error(
"expected a value of scalar type.", Node);
440 return MaybeStrID.takeError();
445 return Str.takeError();
447 if (Result.
front() ==
'\'')
450 if (Result.
back() ==
'\'')
Represents either an error or a value T.
This class represents lattice values for constants.
StringRef getRawTag() const
Get the tag as it was written in the document.
void print(const char *ProgName, raw_ostream &S, bool ShowColors=true, bool ShowKindLabel=true) const
DiagHandlerTy getDiagHandler() const
LLVM_NODISCARD bool startswith(StringRef Prefix) const
Check if this string starts with the given Prefix.
bool consume_front(StringRef Prefix)
Returns true if this StringRef has the given prefix and removes that prefix.
Represents a YAML sequence created from either a block sequence for a flow sequence.
Node * getKey()
Parse and return the key.
document_iterator begin()
Error takeError()
Take ownership of the stored error.
StringSwitch & Case(StringLiteral S, T Value)
void append(SmallVectorImpl< char > &path, const Twine &a, const Twine &b="", const Twine &c="", const Twine &d="")
Append to path.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
LLVM_NODISCARD StringRef drop_front(size_t N=1) const
Return a StringRef equal to 'this' but with the first N elements dropped.
LLVM_NODISCARD R Default(T Value)
std::error_code make_error_code(BitcodeError E)
Tagged union holding either a T or a Error.
Node * getRoot()
Parse and return the root level node.
LLVM_NODISCARD size_t size() const
size - Get the string size.
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
A switch()-like statement whose cases are string literals.
void setDiagHandler(DiagHandlerTy DH, void *Ctx=nullptr)
Specify a diagnostic handler to be invoked every time PrintMessage is called.
void printError(Node *N, const Twine &Msg)
Instrumentation for Order File
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
std::error_code getError() const
amdgpu Simplify well known AMD library false FunctionCallee Value * Arg
This owns the files read by a parser, handles include stacks, and handles diagnostic wrangling...
LLVM_NODISCARD char back() const
back - Get the last character in the string.
A scalar node is an opaque datum that can be presented as a series of zero or more Unicode scalar val...
static ErrorSuccess success()
Create a success value.
Node * getValue()
Parse and return the value.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
This class represents a YAML stream potentially containing multiple documents.
void * getDiagContext() const
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
Represents a YAML map created from either a block map for a flow map.
static ErrorOr< std::unique_ptr< MemoryBuffer > > getFile(const Twine &Filename, int64_t FileSize=-1, bool RequiresNullTerminator=true, bool IsVolatile=false)
Open the specified file as a MemoryBuffer, returning a new MemoryBuffer if successful, otherwise returning null.
LLVM_NODISCARD const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
LLVM_NODISCARD char front() const
front - Get the first character in the string.
A raw_ostream that writes to an std::string.
LLVM Value Representation.
Error createFileError(const Twine &F, Error E)
Concatenate a source file path and/or name with an Error.
LLVM_NODISCARD StringRef drop_back(size_t N=1) const
Return a StringRef equal to 'this' but with the last N elements dropped.
Lightweight error class with error context and mandatory checking.
StringRef - Represent a constant reference to a string, i.e.
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
A YAML Stream is a sequence of Documents.
Error createStringError(std::error_code EC, char const *Fmt, const Ts &... Vals)
Create formatted StringError object.
Abstract base class for all Nodes.
Instances of this class encapsulate one diagnostic report, allowing printing to a raw_ostream as a ca...