MCPcopy Create free account
hub / github.com/GANGE666/xVMP / parseAttributeBlock

Method parseAttributeBlock

src/lib/Bitcode/Reader/BitcodeReader.cpp:1247–1301  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1245}
1246
1247Error BitcodeReader::parseAttributeBlock() {
1248 if (Stream.EnterSubBlock(bitc::PARAMATTR_BLOCK_ID))
1249 return error("Invalid record");
1250
1251 if (!MAttributes.empty())
1252 return error("Invalid multiple blocks");
1253
1254 SmallVector<uint64_t, 64> Record;
1255
1256 SmallVector<AttributeList, 8> Attrs;
1257
1258 // Read all the records.
1259 while (true) {
1260 BitstreamEntry Entry = Stream.advanceSkippingSubblocks();
1261
1262 switch (Entry.Kind) {
1263 case BitstreamEntry::SubBlock: // Handled for us already.
1264 case BitstreamEntry::Error:
1265 return error("Malformed block");
1266 case BitstreamEntry::EndBlock:
1267 return Error::success();
1268 case BitstreamEntry::Record:
1269 // The interesting case.
1270 break;
1271 }
1272
1273 // Read a record.
1274 Record.clear();
1275 switch (Stream.readRecord(Entry.ID, Record)) {
1276 default: // Default behavior: ignore.
1277 break;
1278 case bitc::PARAMATTR_CODE_ENTRY_OLD: // ENTRY: [paramidx0, attr0, ...]
1279 // FIXME: Remove in 4.0.
1280 if (Record.size() & 1)
1281 return error("Invalid record");
1282
1283 for (unsigned i = 0, e = Record.size(); i != e; i += 2) {
1284 AttrBuilder B;
1285 decodeLLVMAttributesForBitcode(B, Record[i+1]);
1286 Attrs.push_back(AttributeList::get(Context, Record[i], B));
1287 }
1288
1289 MAttributes.push_back(AttributeList::get(Context, Attrs));
1290 Attrs.clear();
1291 break;
1292 case bitc::PARAMATTR_CODE_ENTRY: // ENTRY: [attrgrp0, attrgrp1, ...]
1293 for (unsigned i = 0, e = Record.size(); i != e; ++i)
1294 Attrs.push_back(MAttributeGroups[Record[i]]);
1295
1296 MAttributes.push_back(AttributeList::get(Context, Attrs));
1297 Attrs.clear();
1298 break;
1299 }
1300 }
1301}
1302
1303// Returns Attribute::None on unrecognized codes.
1304static Attribute::AttrKind getAttrFromCode(uint64_t Code) {

Callers

nothing calls this directly

Calls 11

successFunction · 0.85
EnterSubBlockMethod · 0.80
errorFunction · 0.70
getFunction · 0.50
emptyMethod · 0.45
clearMethod · 0.45
readRecordMethod · 0.45
sizeMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected