LLVM 20.0.0git
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | List of all members
llvm::remarks::YAMLRemarkParser Struct Reference

Regular YAML to Remark parser. More...

#include "Remarks/YAMLRemarkParser.h"

Inheritance diagram for llvm::remarks::YAMLRemarkParser:
Inheritance graph
[legend]

Public Member Functions

 YAMLRemarkParser (StringRef Buf)
 
Expected< std::unique_ptr< Remark > > next () override
 If no error occurs, this returns a valid Remark object.
 
- Public Member Functions inherited from llvm::remarks::RemarkParser
 RemarkParser (Format ParserFormat)
 
virtual Expected< std::unique_ptr< Remark > > next ()=0
 If no error occurs, this returns a valid Remark object.
 
virtual ~RemarkParser ()=default
 

Static Public Member Functions

static bool classof (const RemarkParser *P)
 

Public Attributes

std::optional< ParsedStringTableStrTab
 The string table used for parsing strings.
 
std::string LastErrorMessage
 Last error message that can come from the YAML parser diagnostics.
 
SourceMgr SM
 Source manager for better error messages.
 
yaml::Stream Stream
 Stream for yaml parsing.
 
yaml::document_iterator YAMLIt
 Iterator in the YAML stream.
 
std::unique_ptr< MemoryBufferSeparateBuf
 If we parse remark metadata in separate mode, we need to open a new file and parse that.
 
- Public Attributes inherited from llvm::remarks::RemarkParser
Format ParserFormat
 The format of the parser.
 
std::string ExternalFilePrependPath
 Path to prepend when opening an external remark file.
 

Protected Member Functions

 YAMLRemarkParser (StringRef Buf, std::optional< ParsedStringTable > StrTab)
 
Error error ()
 Create a YAMLParseError error from an existing error generated by the YAML parser.
 
Error error (StringRef Message, yaml::Node &Node)
 Create a YAMLParseError error referencing a specific node.
 
Expected< std::unique_ptr< Remark > > parseRemark (yaml::Document &Remark)
 Parse a YAML remark to a remarks::Remark object.
 
Expected< TypeparseType (yaml::MappingNode &Node)
 Parse the type of a remark to an enum type.
 
Expected< StringRefparseKey (yaml::KeyValueNode &Node)
 Parse one key to a string.
 
virtual Expected< StringRefparseStr (yaml::KeyValueNode &Node)
 Parse one value to a string.
 
Expected< unsignedparseUnsigned (yaml::KeyValueNode &Node)
 Parse one value to an unsigned.
 
Expected< RemarkLocationparseDebugLoc (yaml::KeyValueNode &Node)
 Parse a debug location.
 
Expected< ArgumentparseArg (yaml::Node &Node)
 Parse an argument.
 

Detailed Description

Regular YAML to Remark parser.

Definition at line 48 of file YAMLRemarkParser.h.

Constructor & Destructor Documentation

◆ YAMLRemarkParser() [1/2]

YAMLRemarkParser::YAMLRemarkParser ( StringRef  Buf)

Definition at line 168 of file YAMLRemarkParser.cpp.

◆ YAMLRemarkParser() [2/2]

YAMLRemarkParser::YAMLRemarkParser ( StringRef  Buf,
std::optional< ParsedStringTable StrTab 
)
protected

Definition at line 171 of file YAMLRemarkParser.cpp.

Member Function Documentation

◆ classof()

static bool llvm::remarks::YAMLRemarkParser::classof ( const RemarkParser P)
inlinestatic

Definition at line 68 of file YAMLRemarkParser.h.

References P, and llvm::remarks::YAML.

◆ error() [1/2]

Error YAMLRemarkParser::error ( )
protected

Create a YAMLParseError error from an existing error generated by the YAML parser.

If there is no error, this returns Success.

Definition at line 180 of file YAMLRemarkParser.cpp.

References LastErrorMessage, and llvm::Error::success().

Referenced by parseArg(), parseDebugLoc(), parseKey(), parseRemark(), parseStr(), llvm::remarks::YAMLStrTabRemarkParser::parseStr(), parseType(), and parseUnsigned().

◆ error() [2/2]

Error YAMLRemarkParser::error ( StringRef  Message,
yaml::Node Node 
)
protected

Create a YAMLParseError error referencing a specific node.

Definition at line 176 of file YAMLRemarkParser.cpp.

References SM, and Stream.

◆ next()

Expected< std::unique_ptr< Remark > > YAMLRemarkParser::next ( )
overridevirtual

If no error occurs, this returns a valid Remark object.

If an error of type EndOfFileError occurs, it is safe to recover from it by stopping the parsing. If any other error occurs, it should be propagated to the user. The pointer should never be null.

Implements llvm::remarks::RemarkParser.

Definition at line 416 of file YAMLRemarkParser.cpp.

References llvm::yaml::Stream::end(), parseRemark(), Stream, llvm::Expected< T >::takeError(), and YAMLIt.

◆ parseArg()

Expected< Argument > YAMLRemarkParser::parseArg ( yaml::Node Node)
protected

Parse an argument.

Definition at line 365 of file YAMLRemarkParser.cpp.

References error(), parseDebugLoc(), parseKey(), parseStr(), and llvm::Expected< T >::takeError().

Referenced by parseRemark().

◆ parseDebugLoc()

Expected< RemarkLocation > YAMLRemarkParser::parseDebugLoc ( yaml::KeyValueNode Node)
protected

Parse a debug location.

Definition at line 323 of file YAMLRemarkParser.cpp.

References error(), parseKey(), parseStr(), parseUnsigned(), and llvm::Expected< T >::takeError().

Referenced by parseArg(), and parseRemark().

◆ parseKey()

Expected< StringRef > YAMLRemarkParser::parseKey ( yaml::KeyValueNode Node)
protected

Parse one key to a string.

Definition at line 285 of file YAMLRemarkParser.cpp.

References error().

Referenced by parseArg(), parseDebugLoc(), and parseRemark().

◆ parseRemark()

Expected< std::unique_ptr< Remark > > YAMLRemarkParser::parseRemark ( yaml::Document Remark)
protected

◆ parseStr()

Expected< StringRef > YAMLRemarkParser::parseStr ( yaml::KeyValueNode Node)
protectedvirtual

Parse one value to a string.

Reimplemented in llvm::remarks::YAMLStrTabRemarkParser.

Definition at line 292 of file YAMLRemarkParser.cpp.

References error(), and llvm::yaml::BlockScalarNode::getValue().

Referenced by parseArg(), parseDebugLoc(), and parseRemark().

◆ parseType()

Expected< Type > YAMLRemarkParser::parseType ( yaml::MappingNode Node)
protected

◆ parseUnsigned()

Expected< unsigned > YAMLRemarkParser::parseUnsigned ( yaml::KeyValueNode Node)
protected

Parse one value to an unsigned.

Definition at line 311 of file YAMLRemarkParser.cpp.

References error().

Referenced by parseDebugLoc(), parseRemark(), and llvm::remarks::YAMLStrTabRemarkParser::parseStr().

Member Data Documentation

◆ LastErrorMessage

std::string llvm::remarks::YAMLRemarkParser::LastErrorMessage

Last error message that can come from the YAML parser diagnostics.

We need this for catching errors in the constructor.

Definition at line 53 of file YAMLRemarkParser.h.

Referenced by error().

◆ SeparateBuf

std::unique_ptr<MemoryBuffer> llvm::remarks::YAMLRemarkParser::SeparateBuf

If we parse remark metadata in separate mode, we need to open a new file and parse that.

Definition at line 62 of file YAMLRemarkParser.h.

◆ SM

SourceMgr llvm::remarks::YAMLRemarkParser::SM

Source manager for better error messages.

Definition at line 55 of file YAMLRemarkParser.h.

Referenced by error().

◆ Stream

yaml::Stream llvm::remarks::YAMLRemarkParser::Stream

Stream for yaml parsing.

Definition at line 57 of file YAMLRemarkParser.h.

Referenced by error(), and next().

◆ StrTab

std::optional<ParsedStringTable> llvm::remarks::YAMLRemarkParser::StrTab

The string table used for parsing strings.

Definition at line 50 of file YAMLRemarkParser.h.

Referenced by llvm::remarks::YAMLStrTabRemarkParser::parseStr().

◆ YAMLIt

yaml::document_iterator llvm::remarks::YAMLRemarkParser::YAMLIt

Iterator in the YAML stream.

Definition at line 59 of file YAMLRemarkParser.h.

Referenced by next().


The documentation for this struct was generated from the following files: