CharUnits &EndOffset) {
bool DetermineForCompleteObject = refersToCompleteObject(LVal);
+ auto CheckedHandleSizeof = [&](QualType Ty, CharUnits &Result) {
+ if (Ty.isNull() || Ty->isIncompleteType() || Ty->isFunctionType())
+ return false;
+ return HandleSizeof(Info, ExprLoc, Ty, Result);
+ };
+
// We want to evaluate the size of the entire object. This is a valid fallback
// for when Type=1 and the designator is invalid, because we're asked for an
// upper-bound.
return false;
QualType BaseTy = getObjectType(LVal.getLValueBase());
- return !BaseTy.isNull() && HandleSizeof(Info, ExprLoc, BaseTy, EndOffset);
+ return CheckedHandleSizeof(BaseTy, EndOffset);
}
// We want to evaluate the size of a subobject.
}
CharUnits BytesPerElem;
- if (!HandleSizeof(Info, ExprLoc, Designator.MostDerivedType, BytesPerElem))
+ if (!CheckedHandleSizeof(Designator.MostDerivedType, BytesPerElem))
return false;
// According to the GCC documentation, we want the size of the subobject
// CHECK: store i32 14
gi = __builtin_object_size(sa->sa_data, 3);
}
+
+extern char incomplete_char_array[];
+// CHECK-LABEL: @incomplete_and_function_types
+int incomplete_and_function_types() {
+ // CHECK: call i64 @llvm.objectsize.i64.p0i8
+ gi = __builtin_object_size(incomplete_char_array, 0);
+ // CHECK: call i64 @llvm.objectsize.i64.p0i8
+ gi = __builtin_object_size(incomplete_char_array, 1);
+ // CHECK: call i64 @llvm.objectsize.i64.p0i8
+ gi = __builtin_object_size(incomplete_char_array, 2);
+ // CHECK: store i32 0
+ gi = __builtin_object_size(incomplete_char_array, 3);
+}