diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2021-07-10 18:36:00 +0200 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2021-07-12 20:49:38 +0200 |
commit | 5d1464cbfe907ba2e75fb97386164c1d30151f95 (patch) | |
tree | 85768b9a608a2f5f632126d30a61d793ade0309f /llvm/lib/Bitcode/Reader/BitcodeReader.cpp | |
parent | 6ebbf755b61539788919163853446e73fcff74c2 (diff) | |
download | llvm-5d1464cbfe907ba2e75fb97386164c1d30151f95.zip llvm-5d1464cbfe907ba2e75fb97386164c1d30151f95.tar.gz llvm-5d1464cbfe907ba2e75fb97386164c1d30151f95.tar.bz2 |
[Attributes] Make type attribute handling more generic (NFCI)
Followup to D105658 to make AttrBuilder automatically work with
new type attributes. TableGen is tweaked to emit First/LastTypeAttr
markers, based on which we can handle type attributes
programmatically.
Differential Revision: https://reviews.llvm.org/D105763
Diffstat (limited to 'llvm/lib/Bitcode/Reader/BitcodeReader.cpp')
-rw-r--r-- | llvm/lib/Bitcode/Reader/BitcodeReader.cpp | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp index 854243e..585527f 100644 --- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp @@ -1642,17 +1642,10 @@ Error BitcodeReader::parseAttributeGroupBlock() { Attribute::AttrKind Kind; if (Error Err = parseAttrKind(Record[++i], &Kind)) return Err; - if (Kind == Attribute::ByVal) { - B.addByValAttr(HasType ? getTypeByID(Record[++i]) : nullptr); - } else if (Kind == Attribute::StructRet) { - B.addStructRetAttr(HasType ? getTypeByID(Record[++i]) : nullptr); - } else if (Kind == Attribute::ByRef) { - B.addByRefAttr(getTypeByID(Record[++i])); - } else if (Kind == Attribute::Preallocated) { - B.addPreallocatedAttr(getTypeByID(Record[++i])); - } else if (Kind == Attribute::InAlloca) { - B.addInAllocaAttr(HasType ? getTypeByID(Record[++i]) : nullptr); - } + if (!Attribute::isTypeAttrKind(Kind)) + return error("Not a type attribute"); + + B.addTypeAttr(Kind, HasType ? getTypeByID(Record[++i]) : nullptr); } } |