@@ -912,26 +912,33 @@ void COFFDumper::initializeFileAndStringTables(BinaryStreamReader &Reader) {
912
912
// The section consists of a number of subsection in the following format:
913
913
// |SubSectionType|SubSectionSize|Contents...|
914
914
uint32_t SubType, SubSectionSize;
915
- error (Reader.readInteger (SubType));
916
- error (Reader.readInteger (SubSectionSize));
915
+
916
+ if (Error E = Reader.readInteger (SubType))
917
+ reportError (std::move (E), Obj->getFileName ());
918
+ if (Error E = Reader.readInteger (SubSectionSize))
919
+ reportError (std::move (E), Obj->getFileName ());
917
920
918
921
StringRef Contents;
919
- error (Reader.readFixedString (Contents, SubSectionSize));
922
+ if (Error E = Reader.readFixedString (Contents, SubSectionSize))
923
+ reportError (std::move (E), Obj->getFileName ());
920
924
921
925
BinaryStreamRef ST (Contents, support::little);
922
926
switch (DebugSubsectionKind (SubType)) {
923
927
case DebugSubsectionKind::FileChecksums:
924
- error (CVFileChecksumTable.initialize (ST));
928
+ if (Error E = CVFileChecksumTable.initialize (ST))
929
+ reportError (std::move (E), Obj->getFileName ());
925
930
break ;
926
931
case DebugSubsectionKind::StringTable:
927
- error (CVStringTable.initialize (ST));
932
+ if (Error E = CVStringTable.initialize (ST))
933
+ reportError (std::move (E), Obj->getFileName ());
928
934
break ;
929
935
default :
930
936
break ;
931
937
}
932
938
933
939
uint32_t PaddedSize = alignTo (SubSectionSize, 4 );
934
- error (Reader.skip (PaddedSize - SubSectionSize));
940
+ if (Error E = Reader.skip (PaddedSize - SubSectionSize))
941
+ reportError (std::move (E), Obj->getFileName ());
935
942
}
936
943
}
937
944
@@ -949,7 +956,9 @@ void COFFDumper::printCodeViewSymbolSection(StringRef SectionName,
949
956
W.printNumber (" Section" , SectionName, Obj->getSectionID (Section));
950
957
951
958
uint32_t Magic;
952
- error (consume (Data, Magic));
959
+ if (Error E = consume (Data, Magic))
960
+ reportError (std::move (E), Obj->getFileName ());
961
+
953
962
W.printHex (" Magic" , Magic);
954
963
if (Magic != COFF::DEBUG_SECTION_MAGIC)
955
964
return error (object_error::parse_failed);
@@ -962,8 +971,10 @@ void COFFDumper::printCodeViewSymbolSection(StringRef SectionName,
962
971
// The section consists of a number of subsection in the following format:
963
972
// |SubSectionType|SubSectionSize|Contents...|
964
973
uint32_t SubType, SubSectionSize;
965
- error (consume (Data, SubType));
966
- error (consume (Data, SubSectionSize));
974
+ if (Error E = consume (Data, SubType))
975
+ reportError (std::move (E), Obj->getFileName ());
976
+ if (Error E = consume (Data, SubSectionSize))
977
+ reportError (std::move (E), Obj->getFileName ());
967
978
968
979
ListScope S (W, " Subsection" );
969
980
// Dump the subsection as normal even if the ignore bit is set.
@@ -1038,7 +1049,8 @@ void COFFDumper::printCodeViewSymbolSection(StringRef SectionName,
1038
1049
BinaryStreamReader SR (Contents, llvm::support::little);
1039
1050
1040
1051
DebugFrameDataSubsectionRef FrameData;
1041
- error (FrameData.initialize (SR));
1052
+ if (Error E = FrameData.initialize (SR))
1053
+ reportError (std::move (E), Obj->getFileName ());
1042
1054
1043
1055
StringRef LinkageName;
1044
1056
error (resolveSymbolName (Obj->getCOFFSection (Section), SectionContents,
@@ -1100,7 +1112,8 @@ void COFFDumper::printCodeViewSymbolSection(StringRef SectionName,
1100
1112
BinaryStreamReader Reader (FunctionLineTables[Name], support::little);
1101
1113
1102
1114
DebugLinesSubsectionRef LineInfo;
1103
- error (LineInfo.initialize (Reader));
1115
+ if (Error E = LineInfo.initialize (Reader))
1116
+ reportError (std::move (E), Obj->getFileName ());
1104
1117
1105
1118
W.printHex (" Flags" , LineInfo.header ()->Flags );
1106
1119
W.printHex (" CodeSize" , LineInfo.header ()->CodeSize );
@@ -1154,9 +1167,9 @@ void COFFDumper::printCodeViewSymbolsSubsection(StringRef Subsection,
1154
1167
error (object_error::parse_failed);
1155
1168
}
1156
1169
1157
- if (auto EC = CVSD.dump (Symbols)) {
1170
+ if (Error E = CVSD.dump (Symbols)) {
1158
1171
W.flush ();
1159
- error (std::move (EC ));
1172
+ reportError (std::move (E), Obj-> getFileName ( ));
1160
1173
}
1161
1174
CompilationCPUType = CVSD.getCompilationCPUType ();
1162
1175
W.flush ();
@@ -1165,7 +1178,8 @@ void COFFDumper::printCodeViewSymbolsSubsection(StringRef Subsection,
1165
1178
void COFFDumper::printCodeViewFileChecksums (StringRef Subsection) {
1166
1179
BinaryStreamRef Stream (Subsection, llvm::support::little);
1167
1180
DebugChecksumsSubsectionRef Checksums;
1168
- error (Checksums.initialize (Stream));
1181
+ if (Error E = Checksums.initialize (Stream))
1182
+ reportError (std::move (E), Obj->getFileName ());
1169
1183
1170
1184
for (auto &FC : Checksums) {
1171
1185
DictScope S (W, " FileChecksum" );
@@ -1184,7 +1198,8 @@ void COFFDumper::printCodeViewFileChecksums(StringRef Subsection) {
1184
1198
void COFFDumper::printCodeViewInlineeLines (StringRef Subsection) {
1185
1199
BinaryStreamReader SR (Subsection, llvm::support::little);
1186
1200
DebugInlineeLinesSubsectionRef Lines;
1187
- error (Lines.initialize (SR));
1201
+ if (Error E = Lines.initialize (SR))
1202
+ reportError (std::move (E), Obj->getFileName ());
1188
1203
1189
1204
for (auto &Line : Lines) {
1190
1205
DictScope S (W, " InlineeSourceLine" );
@@ -1232,7 +1247,9 @@ void COFFDumper::mergeCodeViewTypes(MergingTypeTableBuilder &CVIDs,
1232
1247
if (SectionName == " .debug$T" ) {
1233
1248
StringRef Data = unwrapOrError (Obj->getFileName (), S.getContents ());
1234
1249
uint32_t Magic;
1235
- error (consume (Data, Magic));
1250
+ if (Error E = consume (Data, Magic))
1251
+ reportError (std::move (E), Obj->getFileName ());
1252
+
1236
1253
if (Magic != 4 )
1237
1254
error (object_error::parse_failed);
1238
1255
@@ -1248,14 +1265,14 @@ void COFFDumper::mergeCodeViewTypes(MergingTypeTableBuilder &CVIDs,
1248
1265
if (GHash) {
1249
1266
std::vector<GloballyHashedType> Hashes =
1250
1267
GloballyHashedType::hashTypes (Types);
1251
- if (auto EC =
1268
+ if (Error E =
1252
1269
mergeTypeAndIdRecords (GlobalCVIDs, GlobalCVTypes, SourceToDest,
1253
1270
Types, Hashes, PCHSignature))
1254
- return error (std::move (EC ));
1271
+ return reportError (std::move (E), Obj-> getFileName ( ));
1255
1272
} else {
1256
- if (auto EC = mergeTypeAndIdRecords (CVIDs, CVTypes, SourceToDest, Types,
1273
+ if (Error E = mergeTypeAndIdRecords (CVIDs, CVTypes, SourceToDest, Types,
1257
1274
PCHSignature))
1258
- return error (std::move (EC ));
1275
+ return reportError (std::move (E), Obj-> getFileName ( ));
1259
1276
}
1260
1277
}
1261
1278
}
@@ -1271,15 +1288,19 @@ void COFFDumper::printCodeViewTypeSection(StringRef SectionName,
1271
1288
W.printBinaryBlock (" Data" , Data);
1272
1289
1273
1290
uint32_t Magic;
1274
- error (consume (Data, Magic));
1291
+ if (Error E = consume (Data, Magic))
1292
+ reportError (std::move (E), Obj->getFileName ());
1293
+
1275
1294
W.printHex (" Magic" , Magic);
1276
1295
if (Magic != COFF::DEBUG_SECTION_MAGIC)
1277
1296
return error (object_error::parse_failed);
1278
1297
1279
1298
Types.reset (Data, 100 );
1280
1299
1281
1300
TypeDumpVisitor TDV (Types, &W, opts::CodeViewSubsectionBytes);
1282
- error (codeview::visitTypeStream (Types, TDV));
1301
+ if (Error E = codeview::visitTypeStream (Types, TDV))
1302
+ reportError (std::move (E), Obj->getFileName ());
1303
+
1283
1304
W.flush ();
1284
1305
}
1285
1306
@@ -1504,7 +1525,7 @@ void COFFDumper::printSymbol(const SymbolRef &Sym) {
1504
1525
error (EC);
1505
1526
Expected<StringRef> Res = getSectionName (Obj, AuxNumber, Assoc);
1506
1527
if (!Res)
1507
- error (Res.takeError ());
1528
+ reportError (Res.takeError (), Obj-> getFileName ());
1508
1529
AssocName = *Res;
1509
1530
1510
1531
W.printNumber (" AssocSection" , AssocName, AuxNumber);
@@ -1906,7 +1927,8 @@ void llvm::dumpCodeViewMergedTypes(ScopedPrinter &Writer,
1906
1927
{
1907
1928
ListScope S (Writer, " MergedTypeStream" );
1908
1929
TypeDumpVisitor TDV (TpiTypes, &Writer, opts::CodeViewSubsectionBytes);
1909
- error (codeview::visitTypeStream (TpiTypes, TDV));
1930
+ if (Error Err = codeview::visitTypeStream (TpiTypes, TDV))
1931
+ reportError (std::move (Err), " <?>" );
1910
1932
Writer.flush ();
1911
1933
}
1912
1934
@@ -1917,7 +1939,8 @@ void llvm::dumpCodeViewMergedTypes(ScopedPrinter &Writer,
1917
1939
ListScope S (Writer, " MergedIDStream" );
1918
1940
TypeDumpVisitor TDV (TpiTypes, &Writer, opts::CodeViewSubsectionBytes);
1919
1941
TDV.setIpiTypes (IpiTypes);
1920
- error (codeview::visitTypeStream (IpiTypes, TDV));
1942
+ if (Error Err = codeview::visitTypeStream (IpiTypes, TDV))
1943
+ reportError (std::move (Err), " <?>" );
1921
1944
Writer.flush ();
1922
1945
}
1923
1946
}
0 commit comments