Skip to content

Commit 6aea36f

Browse files
committed
Follow-on fixes for get/isIntegerConstantExpression
1 parent 8632931 commit 6aea36f

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

clang/lib/Sema/SemaType.cpp

+11-8
Original file line numberDiff line numberDiff line change
@@ -7689,14 +7689,17 @@ static bool isPermittedNeonBaseType(QualType &Ty,
76897689
static bool verifyValidIntegerConstantExpr(Sema &S, const ParsedAttr &Attr,
76907690
llvm::APSInt &Result) {
76917691
const auto *AttrExpr = Attr.getArgAsExpr(0);
7692-
if (AttrExpr->isTypeDependent() || AttrExpr->isValueDependent() ||
7693-
!AttrExpr->isIntegerConstantExpr(Result, S.Context)) {
7694-
S.Diag(Attr.getLoc(), diag::err_attribute_argument_type)
7695-
<< Attr << AANT_ArgumentIntegerConstant << AttrExpr->getSourceRange();
7696-
Attr.setInvalid();
7697-
return false;
7692+
if (!AttrExpr->isTypeDependent() && !AttrExpr->isValueDependent()) {
7693+
if (Optional<llvm::APSInt> Res =
7694+
AttrExpr->getIntegerConstantExpr(S.Context)) {
7695+
Result = *Res;
7696+
return true;
7697+
}
76987698
}
7699-
return true;
7699+
S.Diag(Attr.getLoc(), diag::err_attribute_argument_type)
7700+
<< Attr << AANT_ArgumentIntegerConstant << AttrExpr->getSourceRange();
7701+
Attr.setInvalid();
7702+
return false;
77007703
}
77017704

77027705
/// HandleNeonVectorTypeAttr - The "neon_vector_type" and
@@ -7737,7 +7740,7 @@ static void HandleNeonVectorTypeAttr(QualType &CurType, const ParsedAttr &Attr,
77377740

77387741
// The total size of the vector must be 64 or 128 bits.
77397742
unsigned typeSize = static_cast<unsigned>(S.Context.getTypeSize(CurType));
7740-
unsigned numElts = static_cast<unsigned>(numEltsInt->getZExtValue());
7743+
unsigned numElts = static_cast<unsigned>(numEltsInt.getZExtValue());
77417744
unsigned vecSize = typeSize * numElts;
77427745
if (vecSize != 64 && vecSize != 128) {
77437746
S.Diag(Attr.getLoc(), diag::err_attribute_bad_neon_vector_size) << CurType;

0 commit comments

Comments
 (0)