mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 18:54:02 +01:00
[Remarks][NFC] Rename remarks::Parser to remarks::RemarkParser
llvm-svn: 366965
This commit is contained in:
parent
9d0871d80e
commit
ec43ff8462
@ -36,11 +36,11 @@ public:
|
||||
};
|
||||
|
||||
/// Parser used to parse a raw buffer to remarks::Remark objects.
|
||||
struct Parser {
|
||||
struct RemarkParser {
|
||||
/// The format of the parser.
|
||||
Format ParserFormat;
|
||||
|
||||
Parser(Format ParserFormat) : ParserFormat(ParserFormat) {}
|
||||
RemarkParser(Format ParserFormat) : ParserFormat(ParserFormat) {}
|
||||
|
||||
/// If no error occurs, this returns a valid Remark object.
|
||||
/// If an error of type EndOfFileError occurs, it is safe to recover from it
|
||||
@ -49,7 +49,7 @@ struct Parser {
|
||||
/// The pointer should never be null.
|
||||
virtual Expected<std::unique_ptr<Remark>> next() = 0;
|
||||
|
||||
virtual ~Parser() = default;
|
||||
virtual ~RemarkParser() = default;
|
||||
};
|
||||
|
||||
/// In-memory representation of the string table parsed from a buffer (e.g. the
|
||||
@ -73,12 +73,12 @@ struct ParsedStringTable {
|
||||
Expected<StringRef> operator[](size_t Index) const;
|
||||
};
|
||||
|
||||
Expected<std::unique_ptr<Parser>> createRemarkParser(Format ParserFormat,
|
||||
StringRef Buf);
|
||||
Expected<std::unique_ptr<RemarkParser>> createRemarkParser(Format ParserFormat,
|
||||
StringRef Buf);
|
||||
|
||||
Expected<std::unique_ptr<Parser>> createRemarkParser(Format ParserFormat,
|
||||
StringRef Buf,
|
||||
ParsedStringTable StrTab);
|
||||
Expected<std::unique_ptr<RemarkParser>>
|
||||
createRemarkParser(Format ParserFormat, StringRef Buf,
|
||||
ParsedStringTable StrTab);
|
||||
|
||||
} // end namespace remarks
|
||||
} // end namespace llvm
|
||||
|
@ -47,7 +47,7 @@ Expected<StringRef> ParsedStringTable::operator[](size_t Index) const {
|
||||
return StringRef(Buffer.data() + Offset, NextOffset - Offset - 1);
|
||||
}
|
||||
|
||||
Expected<std::unique_ptr<Parser>>
|
||||
Expected<std::unique_ptr<RemarkParser>>
|
||||
llvm::remarks::createRemarkParser(Format ParserFormat, StringRef Buf) {
|
||||
switch (ParserFormat) {
|
||||
case Format::YAML:
|
||||
@ -63,7 +63,7 @@ llvm::remarks::createRemarkParser(Format ParserFormat, StringRef Buf) {
|
||||
llvm_unreachable("unhandled ParseFormat");
|
||||
}
|
||||
|
||||
Expected<std::unique_ptr<Parser>>
|
||||
Expected<std::unique_ptr<RemarkParser>>
|
||||
llvm::remarks::createRemarkParser(Format ParserFormat, StringRef Buf,
|
||||
ParsedStringTable StrTab) {
|
||||
switch (ParserFormat) {
|
||||
@ -82,7 +82,7 @@ llvm::remarks::createRemarkParser(Format ParserFormat, StringRef Buf,
|
||||
|
||||
// Wrapper that holds the state needed to interact with the C API.
|
||||
struct CParser {
|
||||
std::unique_ptr<Parser> TheParser;
|
||||
std::unique_ptr<RemarkParser> TheParser;
|
||||
Optional<std::string> Err;
|
||||
|
||||
CParser(Format ParserFormat, StringRef Buf,
|
||||
@ -108,7 +108,7 @@ extern "C" LLVMRemarkParserRef LLVMRemarkParserCreateYAML(const void *Buf,
|
||||
extern "C" LLVMRemarkEntryRef
|
||||
LLVMRemarkParserGetNext(LLVMRemarkParserRef Parser) {
|
||||
CParser &TheCParser = *unwrap(Parser);
|
||||
remarks::Parser &TheParser = *TheCParser.TheParser;
|
||||
remarks::RemarkParser &TheParser = *TheCParser.TheParser;
|
||||
|
||||
Expected<std::unique_ptr<Remark>> MaybeRemark = TheParser.next();
|
||||
if (Error E = MaybeRemark.takeError()) {
|
||||
|
@ -59,7 +59,7 @@ YAMLRemarkParser::YAMLRemarkParser(StringRef Buf)
|
||||
|
||||
YAMLRemarkParser::YAMLRemarkParser(StringRef Buf,
|
||||
Optional<ParsedStringTable> StrTab)
|
||||
: Parser{Format::YAML}, StrTab(std::move(StrTab)), LastErrorMessage(),
|
||||
: RemarkParser{Format::YAML}, StrTab(std::move(StrTab)), LastErrorMessage(),
|
||||
SM(setupSM(LastErrorMessage)), Stream(Buf, SM), YAMLIt(Stream.begin()) {}
|
||||
|
||||
Error YAMLRemarkParser::error(StringRef Message, yaml::Node &Node) {
|
||||
|
@ -46,7 +46,7 @@ private:
|
||||
};
|
||||
|
||||
/// Regular YAML to Remark parser.
|
||||
struct YAMLRemarkParser : public Parser {
|
||||
struct YAMLRemarkParser : public RemarkParser {
|
||||
/// The string table used for parsing strings.
|
||||
Optional<ParsedStringTable> StrTab;
|
||||
/// Last error message that can come from the YAML parser diagnostics.
|
||||
@ -63,7 +63,7 @@ struct YAMLRemarkParser : public Parser {
|
||||
|
||||
Expected<std::unique_ptr<Remark>> next() override;
|
||||
|
||||
static bool classof(const Parser *P) {
|
||||
static bool classof(const RemarkParser *P) {
|
||||
return P->ParserFormat == Format::YAML;
|
||||
}
|
||||
|
||||
@ -96,7 +96,7 @@ struct YAMLStrTabRemarkParser : public YAMLRemarkParser {
|
||||
YAMLStrTabRemarkParser(StringRef Buf, ParsedStringTable StrTab)
|
||||
: YAMLRemarkParser(Buf, std::move(StrTab)) {}
|
||||
|
||||
static bool classof(const Parser *P) {
|
||||
static bool classof(const RemarkParser *P) {
|
||||
return P->ParserFormat == Format::YAMLStrTab;
|
||||
}
|
||||
|
||||
|
@ -163,7 +163,7 @@ static bool readLocationInfo(LocationInfoTy &LocationInfo) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Expected<std::unique_ptr<remarks::Parser>> MaybeParser =
|
||||
Expected<std::unique_ptr<remarks::RemarkParser>> MaybeParser =
|
||||
remarks::createRemarkParser(*Format, (*Buf)->getBuffer());
|
||||
if (!MaybeParser) {
|
||||
handleAllErrors(MaybeParser.takeError(), [&](const ErrorInfoBase &PE) {
|
||||
@ -171,7 +171,7 @@ static bool readLocationInfo(LocationInfoTy &LocationInfo) {
|
||||
});
|
||||
return false;
|
||||
}
|
||||
remarks::Parser &Parser = **MaybeParser;
|
||||
remarks::RemarkParser &Parser = **MaybeParser;
|
||||
|
||||
while (true) {
|
||||
Expected<std::unique_ptr<remarks::Remark>> MaybeRemark = Parser.next();
|
||||
|
@ -14,12 +14,12 @@
|
||||
using namespace llvm;
|
||||
|
||||
template <size_t N> void parseGood(const char (&Buf)[N]) {
|
||||
Expected<std::unique_ptr<remarks::Parser>> MaybeParser =
|
||||
Expected<std::unique_ptr<remarks::RemarkParser>> MaybeParser =
|
||||
remarks::createRemarkParser(remarks::Format::YAML, {Buf, N - 1});
|
||||
EXPECT_FALSE(errorToBool(MaybeParser.takeError()));
|
||||
EXPECT_TRUE(*MaybeParser != nullptr);
|
||||
|
||||
remarks::Parser &Parser = **MaybeParser;
|
||||
remarks::RemarkParser &Parser = **MaybeParser;
|
||||
Expected<std::unique_ptr<remarks::Remark>> Remark = Parser.next();
|
||||
EXPECT_FALSE(errorToBool(Remark.takeError())); // Check for parsing errors.
|
||||
EXPECT_TRUE(*Remark != nullptr); // At least one remark.
|
||||
@ -31,12 +31,12 @@ template <size_t N> void parseGood(const char (&Buf)[N]) {
|
||||
|
||||
template <size_t N>
|
||||
bool parseExpectError(const char (&Buf)[N], const char *Error) {
|
||||
Expected<std::unique_ptr<remarks::Parser>> MaybeParser =
|
||||
Expected<std::unique_ptr<remarks::RemarkParser>> MaybeParser =
|
||||
remarks::createRemarkParser(remarks::Format::YAML, {Buf, N - 1});
|
||||
EXPECT_FALSE(errorToBool(MaybeParser.takeError()));
|
||||
EXPECT_TRUE(*MaybeParser != nullptr);
|
||||
|
||||
remarks::Parser &Parser = **MaybeParser;
|
||||
remarks::RemarkParser &Parser = **MaybeParser;
|
||||
Expected<std::unique_ptr<remarks::Remark>> Remark = Parser.next();
|
||||
EXPECT_FALSE(Remark); // Check for parsing errors.
|
||||
|
||||
@ -354,12 +354,12 @@ TEST(YAMLRemarks, Contents) {
|
||||
" - String: ' because its definition is unavailable'\n"
|
||||
"\n";
|
||||
|
||||
Expected<std::unique_ptr<remarks::Parser>> MaybeParser =
|
||||
Expected<std::unique_ptr<remarks::RemarkParser>> MaybeParser =
|
||||
remarks::createRemarkParser(remarks::Format::YAML, Buf);
|
||||
EXPECT_FALSE(errorToBool(MaybeParser.takeError()));
|
||||
EXPECT_TRUE(*MaybeParser != nullptr);
|
||||
|
||||
remarks::Parser &Parser = **MaybeParser;
|
||||
remarks::RemarkParser &Parser = **MaybeParser;
|
||||
Expected<std::unique_ptr<remarks::Remark>> MaybeRemark = Parser.next();
|
||||
EXPECT_FALSE(
|
||||
errorToBool(MaybeRemark.takeError())); // Check for parsing errors.
|
||||
@ -525,13 +525,13 @@ TEST(YAMLRemarks, ContentsStrTab) {
|
||||
115);
|
||||
|
||||
remarks::ParsedStringTable StrTab(StrTabBuf);
|
||||
Expected<std::unique_ptr<remarks::Parser>> MaybeParser =
|
||||
Expected<std::unique_ptr<remarks::RemarkParser>> MaybeParser =
|
||||
remarks::createRemarkParser(remarks::Format::YAMLStrTab, Buf,
|
||||
std::move(StrTab));
|
||||
EXPECT_FALSE(errorToBool(MaybeParser.takeError()));
|
||||
EXPECT_TRUE(*MaybeParser != nullptr);
|
||||
|
||||
remarks::Parser &Parser = **MaybeParser;
|
||||
remarks::RemarkParser &Parser = **MaybeParser;
|
||||
Expected<std::unique_ptr<remarks::Remark>> MaybeRemark = Parser.next();
|
||||
EXPECT_FALSE(
|
||||
errorToBool(MaybeRemark.takeError())); // Check for parsing errors.
|
||||
@ -601,13 +601,13 @@ TEST(YAMLRemarks, ParsingBadStringTableIndex) {
|
||||
StringRef StrTabBuf = StringRef("inline");
|
||||
|
||||
remarks::ParsedStringTable StrTab(StrTabBuf);
|
||||
Expected<std::unique_ptr<remarks::Parser>> MaybeParser =
|
||||
Expected<std::unique_ptr<remarks::RemarkParser>> MaybeParser =
|
||||
remarks::createRemarkParser(remarks::Format::YAMLStrTab, Buf,
|
||||
std::move(StrTab));
|
||||
EXPECT_FALSE(errorToBool(MaybeParser.takeError()));
|
||||
EXPECT_TRUE(*MaybeParser != nullptr);
|
||||
|
||||
remarks::Parser &Parser = **MaybeParser;
|
||||
remarks::RemarkParser &Parser = **MaybeParser;
|
||||
Expected<std::unique_ptr<remarks::Remark>> MaybeRemark = Parser.next();
|
||||
EXPECT_FALSE(MaybeRemark); // Expect an error here.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user