/// Paired begin/end actions for all types. Receives all record data,
/// including the fixed-length record prefix.
- Error visitTypeBegin(const CVRecord<TypeLeafKind> &Record) override;
+ Expected<TypeLeafKind>
+ visitTypeBegin(const CVRecord<TypeLeafKind> &Record) override;
Error visitTypeEnd(const CVRecord<TypeLeafKind> &Record) override;
#define TYPE_RECORD(EnumName, EnumVal, Name) \
return Error::success();
}
- virtual Error visitTypeBegin(const CVRecord<TypeLeafKind> &Record) override {
+ virtual Expected<TypeLeafKind>
+ visitTypeBegin(const CVRecord<TypeLeafKind> &Record) override {
+ TypeLeafKind Kind = Record.Type;
for (auto Visitor : Pipeline) {
- if (auto EC = Visitor->visitTypeBegin(Record))
- return EC;
+ if (auto ExpectedKind = Visitor->visitTypeBegin(Record))
+ Kind = *ExpectedKind;
+ else
+ return ExpectedKind.takeError();
}
- return Error::success();
+ return Kind;
}
virtual Error visitTypeEnd(const CVRecord<TypeLeafKind> &Record) override {
for (auto Visitor : Pipeline) {
}
/// Paired begin/end actions for all types. Receives all record data,
- /// including the fixed-length record prefix.
- virtual Error visitTypeBegin(const CVRecord<TypeLeafKind> &Record) {
- return Error::success();
+ /// including the fixed-length record prefix. visitTypeBegin() should return
+ /// the type of the Record, or an error if it cannot be determined.
+ virtual Expected<TypeLeafKind>
+ visitTypeBegin(const CVRecord<TypeLeafKind> &Record) {
+ return Record.Type;
}
virtual Error visitTypeEnd(const CVRecord<TypeLeafKind> &Record) {
return Error::success();
}
Error CVTypeVisitor::visitTypeRecord(const CVRecord<TypeLeafKind> &Record) {
- if (auto EC = Callbacks.visitTypeBegin(Record))
- return EC;
+ TypeLeafKind Kind;
+ if (auto ExpectedKind = Callbacks.visitTypeBegin(Record))
+ Kind = *ExpectedKind;
+ else
+ return ExpectedKind.takeError();
- switch (Record.Type) {
+ switch (Kind) {
default:
if (auto EC = Callbacks.visitUnknownType(Record))
return EC;
if (!ExpectedRecord) \
return ExpectedRecord.takeError(); \
auto &Record = *ExpectedRecord; \
- if (auto EC = Callbacks.visitTypeBegin(Record)) \
- return EC; \
+ auto ExpectedKind = Callbacks.visitTypeBegin(Record); \
+ if (!ExpectedKind || *ExpectedKind != Leaf) \
+ return ExpectedKind.takeError(); \
if (auto EC = visitKnownRecord<Name##Record>(Record, Callbacks)) \
return EC; \
if (auto EC = Callbacks.visitTypeEnd(Record)) \
return "UnknownLeaf";
}
-Error CVTypeDumper::visitTypeBegin(const CVRecord<TypeLeafKind> &Record) {
+Expected<TypeLeafKind>
+CVTypeDumper::visitTypeBegin(const CVRecord<TypeLeafKind> &Record) {
// Reset Name to the empty string. If the visitor sets it, we know it.
Name = "";
assert(!IsInFieldList);
IsInFieldList = true;
}
- return Error::success();
+ return Record.Type;
}
Error CVTypeDumper::visitTypeEnd(const CVRecord<TypeLeafKind> &Record) {
Error visitUnknownType(const CVRecord<TypeLeafKind> &Record) override;
- Error visitTypeBegin(const CVRecord<TypeLeafKind> &Record) override;
+ Expected<TypeLeafKind>
+ visitTypeBegin(const CVRecord<TypeLeafKind> &Record) override;
Error visitTypeEnd(const CVRecord<TypeLeafKind> &Record) override;
bool mergeStream(const CVTypeArray &Types);
} // end anonymous namespace
-Error TypeStreamMerger::visitTypeBegin(const CVRecord<TypeLeafKind> &Rec) {
+Expected<TypeLeafKind>
+TypeStreamMerger::visitTypeBegin(const CVRecord<TypeLeafKind> &Rec) {
if (Rec.Type == TypeLeafKind::LF_FIELDLIST) {
assert(!IsInFieldList);
IsInFieldList = true;
} else
BeginIndexMapSize = IndexMap.size();
- return Error::success();
+ return Rec.Type;
}
Error TypeStreamMerger::visitTypeEnd(const CVRecord<TypeLeafKind> &Rec) {
return verify(Rec);
}
- Error visitTypeBegin(const CVRecord<TypeLeafKind> &Rec) override {
+ Expected<TypeLeafKind>
+ visitTypeBegin(const CVRecord<TypeLeafKind> &Rec) override {
++Index;
RawRecord = &Rec;
- return Error::success();
+ return Rec.Type;
}
private:
}
}
-Error llvm::codeview::yaml::YamlTypeDumperCallbacks::visitTypeBegin(
+Expected<TypeLeafKind>
+llvm::codeview::yaml::YamlTypeDumperCallbacks::visitTypeBegin(
const CVRecord<TypeLeafKind> &CVR) {
+ // When we're outputting, `CVR.Type` already has the right value in it. But
+ // when we're inputting, we need to read the value. Since `CVR.Type` is const
+ // we do it into a temp variable.
TypeLeafKind K = CVR.Type;
YamlIO.mapRequired("Kind", K);
- return Error::success();
+ return K;
}
public:
YamlTypeDumperCallbacks(llvm::yaml::IO &IO) : YamlIO(IO) {}
- virtual Error visitTypeBegin(const CVRecord<TypeLeafKind> &Record) override;
+ virtual Expected<TypeLeafKind>
+ visitTypeBegin(const CVRecord<TypeLeafKind> &Record) override;
#define TYPE_RECORD(EnumName, EnumVal, Name) \
Error visitKnownRecord(const CVRecord<TypeLeafKind> &CVR, \