.addAttribute(Attribute::NoAlias)
.addAttribute(Attribute::NoCapture)
.addAttribute(Attribute::NonNull)
+ .addAttribute(Attribute::ReadNone)
+ .addAttribute(Attribute::ReadOnly)
+ .addAttribute(Attribute::SwiftError)
.addAlignmentAttr(1) // the int here is ignored
.addDereferenceableAttr(1) // the int here is ignored
.addDereferenceableOrNullAttr(1) // the int here is ignored
- .addAttribute(Attribute::ReadNone)
- .addAttribute(Attribute::ReadOnly)
.addPreallocatedAttr(Ty)
.addInAllocaAttr(Ty)
.addByValAttr(Ty)
V);
AttrBuilder IncompatibleAttrs = AttributeFuncs::typeIncompatible(Ty);
- Assert(!AttrBuilder(Attrs).overlaps(IncompatibleAttrs),
- "Wrong types for attribute: " +
- AttributeSet::get(Context, IncompatibleAttrs).getAsString(),
- V);
+ for (Attribute Attr : Attrs) {
+ if (!Attr.isStringAttribute() &&
+ IncompatibleAttrs.contains(Attr.getKindAsEnum())) {
+ CheckFailed("Attribute '" + Attr.getAsString() +
+ "' applied to incompatible type!", V);
+ return;
+ }
+ }
if (PointerType *PTy = dyn_cast<PointerType>(Ty)) {
if (Attrs.hasAttribute(Attribute::ByVal)) {
"Attribute 'inalloca' type does not match parameter!", V);
}
}
- } else {
- Assert(!Attrs.hasAttribute(Attribute::ByVal),
- "Attribute 'byval' only applies to parameters with pointer type!",
- V);
- Assert(!Attrs.hasAttribute(Attribute::ByRef),
- "Attribute 'byref' only applies to parameters with pointer type!",
- V);
- Assert(!Attrs.hasAttribute(Attribute::SwiftError),
- "Attribute 'swifterror' only applies to parameters "
- "with pointer type!",
- V);
}
}
; RUN: not llvm-as < %s -o /dev/null 2>&1 | FileCheck %s
-; CHECK: Wrong types for attribute: nest noalias nocapture nonnull readnone readonly byref(i32) byval(i32) inalloca(i32) preallocated(i32) sret(i32) align 1 dereferenceable(1) dereferenceable_or_null(1)
+; CHECK: Attribute 'align 4' applied to incompatible type!
; CHECK-NEXT: @align_non_pointer1
define void @align_non_pointer1(i32 align 4 %a) {
ret void
}
-; CHECK: Wrong types for attribute: nest noalias nocapture noundef nonnull readnone readonly signext zeroext byref(void) byval(void) inalloca(void) preallocated(void) sret(void) align 1 dereferenceable(1) dereferenceable_or_null(1)
+; CHECK: Attribute 'align 4' applied to incompatible type!
; CHECK-NEXT: @align_non_pointer2
define align 4 void @align_non_pointer2(i32 %a) {
ret void
ret void
}
-; CHECK: Wrong types for attribute: nest noalias nocapture nonnull readnone readonly byref(i32) byval(i32) inalloca(i32) preallocated(i32) sret(i32) align 1 dereferenceable(1) dereferenceable_or_null(1)
+; CHECK: Attribute 'byref(i32)' applied to incompatible type!
; CHECK-NEXT: void (i32)* @byref_non_pointer
define void @byref_non_pointer(i32 byref(i32)) {
ret void
; RUN: not llvm-as < %s -o /dev/null 2>&1 | FileCheck %s
-; CHECK: Wrong types for attribute: nest noalias nocapture nonnull readnone readonly byref(i32) byval(i32) inalloca(i32) preallocated(i32) sret(i32) align 1 dereferenceable(1) dereferenceable_or_null(1)
+; CHECK: Attribute 'byval(i32)' applied to incompatible type!
; CHECK-NEXT: void (i32)* @h
declare void @h(i32 byval(i32) %num)
ret void
}
-; CHECK: Wrong types for attribute:
+; CHECK: Attribute 'inalloca(i8)' applied to incompatible type!
; CHECK-NEXT: void (i8)* @inalloca_not_pointer
-define void @inalloca_not_pointer(i8 byref(i8)) {
+define void @inalloca_not_pointer(i8 inalloca(i8)) {
ret void
}
; RUN: not llvm-as < %s -o /dev/null 2>&1 | FileCheck %s
-; CHECK: Wrong types for attribute: nest noalias nocapture noundef nonnull readnone readonly signext zeroext byref(void) byval(void) inalloca(void) preallocated(void) sret(void) align 1 dereferenceable(1) dereferenceable_or_null(1)
+; CHECK: Attribute 'noundef' applied to incompatible type!
; CHECK-NEXT: @noundef_void
define noundef void @noundef_void() {
ret void
ret void
}
-; CHECK: Wrong types for attribute:
+; CHECK: Attribute 'preallocated(i32)' applied to incompatible type!
; CHECK-NEXT: void (i32)* @not_pointer
declare void @not_pointer(i32 preallocated(i32))
declare void @b(i32* %a, i32* %b, i32* sret(i32) %c)
; CHECK: Attribute 'sret' is not on first or second parameter!
-; CHECK: Wrong types for attribute:
+; CHECK: Attribute 'sret(i32)' applied to incompatible type!
; CHECK-NEXT: void (i32)* @not_ptr
declare void @not_ptr(i32 sret(i32) %x)
; CHECK: Cannot have multiple 'swifterror' parameters!
declare void @a(i32** swifterror %a, i32** swifterror %b)
-; CHECK: Attribute 'swifterror' only applies to parameters with pointer type!
+; CHECK: Attribute 'swifterror' applied to incompatible type!
declare void @b(i32 swifterror %a)
; CHECK: Attribute 'swifterror' only applies to parameters with pointer to pointer type!