mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-12-01 16:51:27 +00:00
[Attributes] Assert correct attribute constructor is used (NFCI)
Assert that enum/int/type attributes go through the constructor they are supposed to use. To make sure this can't happen via invalid bitcode, explicitly verify that the attribute kind if correct there.
This commit is contained in:
1 parent
b4a6fa12d1
commit
3fb0621faf
3 files changed
+17
-2
No files matched your search
@@ -1599,12 +1599,16 @@ Error BitcodeReader::parseAttributeGroupBlock() {
|
||||
B.addStructRetAttr(nullptr);
|
||||
else if (Kind == Attribute::InAlloca)
|
||||
B.addInAllocaAttr(nullptr);
|
||||
|
||||
B.addAttribute(Kind);
|
||||
else if (Attribute::isEnumAttrKind(Kind))
|
||||
B.addAttribute(Kind);
|
||||
else
|
||||
return error("Not an enum attribute");
|
||||
} else if (Record[i] == 1) { // Integer attribute
|
||||
Attribute::AttrKind Kind;
|
||||
if (Error Err = parseAttrKind(Record[++i], &Kind))
|
||||
return Err;
|
||||
if (!Attribute::isIntAttrKind(Kind))
|
||||
return error("Not an int attribute");
|
||||
if (Kind == Attribute::Alignment)
|
||||
B.addAlignmentAttr(Record[++i]);
|
||||
else if (Kind == Attribute::StackAlignment)
|
||||
|
||||
Reference in new issue
Block a user