c2compiler
c2compiler copied to clipboard
Redundant code in `Builder.applyAttribute`
There is redundant code in the function Builder.applyAttribute, can it be removed or was there a reason to make a special case for PrintfFormat that was not completed?
fn void Builder.applyAttribute(Builder* b, Decl* d, const Attr* a) {
DeclKind dk = d.getKind();
switch (dk) {
case Function:
b.actOnFunctionAttr(d, a);
break;
case StructType:
b.actOnStructAttr(d, a);
break;
case EnumType:
b.actOnTypeAttr(d, a);
break;
case FunctionType:
// store in inner type also (for needed for type decl, other for when used)
// check result of first, otherwise we get the same error twice
if (!b.actOnTypeAttr(d, a)) return;
FunctionTypeDecl* ftd = cast<FunctionTypeDecl*>(d);
if (a.kind == AttrKind.PrintfFormat) {
b.applyAttribute(cast<Decl*>(ftd.getDecl()), a);
} else {
b.applyAttribute(cast<Decl*>(ftd.getDecl()), a);
}
break;
case AliasType:
b.actOnTypeAttr(d, a);
break;
case Variable:
b.actOnVarAttr(d, a);
break;
default:
assert(0);
return;
}
}
must be some leftover from the past..
fixed