27 assert(Ctx &&
"Expected non-null Ctx in diagnostic handler.");
28 std::string &Message = *
static_cast<std::string *
>(Ctx);
29 assert(Message.empty() &&
"Expected an empty string.");
31 Diag.
print(
nullptr, OS,
false,
67 "Expecting \\0 after magic number.");
74 "Expecting version number.");
80 "Mismatching remark version. Got %" PRId64
81 ", expected %" PRId64
".",
90 "Expecting string table size.");
98 StringRef Buf, std::optional<StringRef> ExternalFilePrependPath) {
104 std::unique_ptr<MemoryBuffer> SeparateBuf;
114 if (*StrTabSize != 0) {
116 "String table unsupported for YAML format.");
123 if (ExternalFilePrependPath)
124 FullPath = *ExternalFilePrependPath;
130 if (std::error_code EC = BufferOrErr.
getError())
134 SeparateBuf = std::move(*BufferOrErr);
135 Buf = SeparateBuf->getBuffer();
139 std::unique_ptr<YAMLRemarkParser> Result =
140 std::make_unique<YAMLRemarkParser>(Buf);
142 Result->SeparateBuf = std::move(SeparateBuf);
143 return std::move(Result);
170 "not a valid YAML file.");
175 return error(
"document root is not of mapping type.", *YAMLRoot);
177 std::unique_ptr<Remark> Result = std::make_unique<Remark>();
178 Remark &TheRemark = *Result;
184 return T.takeError();
195 if (KeyName ==
"Pass") {
199 return MaybeStr.takeError();
200 }
else if (KeyName ==
"Name") {
204 return MaybeStr.takeError();
205 }
else if (KeyName ==
"Function") {
209 return MaybeStr.takeError();
210 }
else if (KeyName ==
"Hotness") {
214 return MaybeU.takeError();
215 }
else if (KeyName ==
"DebugLoc") {
217 TheRemark.
Loc = *MaybeLoc;
219 return MaybeLoc.takeError();
220 }
else if (KeyName ==
"Args") {
223 return error(
"wrong value type for key.", RemarkField);
227 TheRemark.
Args.push_back(*MaybeArg);
229 return MaybeArg.takeError();
232 return error(
"unknown key.", RemarkField);
239 return error(
"Type, Pass, Name or Function missing.",
242 return std::move(Result);
255 return error(
"expected a remark tag.",
Node);
261 return Key->getRawValue();
263 return error(
"key is not a string.",
Node);
274 return error(
"expected a value of scalar type.",
Node);
277 Result =
Value->getRawValue();
279 Result.consume_front(
"\'");
280 Result.consume_back(
"\'");
289 return error(
"expected a value of scalar type.",
Node);
290 unsigned UnsignedValue = 0;
291 if (
Value->getValue(Tmp).getAsInteger(10, UnsignedValue))
292 return error(
"expected a value of integer type.", *
Value);
293 return UnsignedValue;
300 return error(
"expected a value of mapping type.",
Node);
302 std::optional<StringRef> File;
303 std::optional<unsigned> Line;
304 std::optional<unsigned> Column;
312 if (KeyName ==
"File") {
316 return MaybeStr.takeError();
317 }
else if (KeyName ==
"Column") {
321 return MaybeU.takeError();
322 }
else if (KeyName ==
"Line") {
326 return MaybeU.takeError();
328 return error(
"unknown entry in DebugLoc map.", DLNode);
333 if (!File || !Line || !Column)
334 return error(
"DebugLoc node incomplete.",
Node);
342 return error(
"expected a value of mapping type.",
Node);
344 std::optional<StringRef> KeyStr;
345 std::optional<StringRef> ValueStr;
346 std::optional<RemarkLocation>
Loc;
355 if (KeyName ==
"DebugLoc") {
358 return error(
"only one DebugLoc entry is allowed per argument.",
365 return MaybeLoc.takeError();
370 return error(
"only one string entry is allowed per argument.", ArgEntry);
374 ValueStr = *MaybeStr;
376 return MaybeStr.takeError();
383 return error(
"argument key is missing.", *ArgMap);
385 return error(
"argument value is missing.", *ArgMap);
407 return std::move(*MaybeResult);
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static Version parseVersion(StringRef Name)
This file defines the SmallString class.
This file implements the StringSwitch template, which mimics a switch() statement whose cases are str...
Represents either an error or a value T.
std::error_code getError() const
Lightweight error class with error context and mandatory checking.
static ErrorSuccess success()
Create a success value.
Tagged union holding either a T or a Error.
Error takeError()
Take ownership of the stored error.
static ErrorOr< std::unique_ptr< MemoryBuffer > > getFile(const Twine &Filename, bool IsText=false, bool RequiresNullTerminator=true, bool IsVolatile=false, std::optional< Align > Alignment=std::nullopt)
Open the specified file as a MemoryBuffer, returning a new MemoryBuffer if successful,...
Instances of this class encapsulate one diagnostic report, allowing printing to a raw_ostream as a ca...
LLVM_ABI void print(const char *ProgName, raw_ostream &S, bool ShowColors=true, bool ShowKindLabel=true, bool ShowLocation=true) const
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
This owns the files read by a parser, handles include stacks, and handles diagnostic wrangling.
void * getDiagContext() const
DiagHandlerTy getDiagHandler() const
void setDiagHandler(DiagHandlerTy DH, void *Ctx=nullptr)
Specify a diagnostic handler to be invoked every time PrintMessage is called.
StringRef - Represent a constant reference to a string, i.e.
bool starts_with(StringRef Prefix) const
Check if this string starts with the given Prefix.
constexpr bool empty() const
empty - Check if the string is empty.
StringRef drop_front(size_t N=1) const
Return a StringRef equal to 'this' but with the first N elements dropped.
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).
bool consume_front(char Prefix)
Returns true if this StringRef has the given prefix and removes that prefix.
A switch()-like statement whose cases are string literals.
StringSwitch & Case(StringLiteral S, T Value)
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
LLVM Value Representation.
A raw_ostream that writes to an std::string.
A block scalar node is an opaque datum that can be presented as a series of zero or more Unicode scal...
StringRef getValue() const
Gets the value of this node as a StringRef.
A YAML Stream is a sequence of Documents.
Node * getRoot()
Parse and return the root level node.
Represents a YAML map created from either a block map for a flow map.
Abstract base class for all Nodes.
This class represents a YAML stream potentially containing multiple documents.
LLVM_ABI void printError(Node *N, const Twine &Msg, SourceMgr::DiagKind Kind=SourceMgr::DK_Error)
value_type read(const void *memory, endianness endian)
Read a value of a particular endianness from memory.
LLVM_ABI void append(SmallVectorImpl< char > &path, const Twine &a, const Twine &b="", const Twine &c="", const Twine &d="")
Append to path.
This is an optimization pass for GlobalISel generic memory operations.
Error createFileError(const Twine &F, Error E)
Concatenate a source file path and/or name with an Error.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
Error createStringError(std::error_code EC, char const *Fmt, const Ts &... Vals)
Create formatted StringError object.
FunctionAddr VTableAddr uintptr_t uintptr_t Version
LLVM_ATTRIBUTE_VISIBILITY_DEFAULT AnalysisKey InnerAnalysisManagerProxy< AnalysisManagerT, IRUnitT, ExtraArgTs... >::Key
Error make_error(ArgTs &&... Args)
Make a Error instance representing failure using the given error info type.