[clang] 6aea36f - Follow-on fixes for get/isIntegerConstantExpression
David Blaikie via cfe-commits
cfe-commits at lists.llvm.org
Tue Jul 21 21:52:45 PDT 2020
Author: David Blaikie
Date: 2020-07-21T21:51:59-07:00
New Revision: 6aea36fb98ed1e0c89cd6e3a24b76339a75aef68
URL: https://github.com/llvm/llvm-project/commit/6aea36fb98ed1e0c89cd6e3a24b76339a75aef68
DIFF: https://github.com/llvm/llvm-project/commit/6aea36fb98ed1e0c89cd6e3a24b76339a75aef68.diff
LOG: Follow-on fixes for get/isIntegerConstantExpression
Added:
Modified:
clang/lib/Sema/SemaType.cpp
Removed:
################################################################################
diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index 09def48a158e..3d6c249c2c17 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -7689,14 +7689,17 @@ static bool isPermittedNeonBaseType(QualType &Ty,
static bool verifyValidIntegerConstantExpr(Sema &S, const ParsedAttr &Attr,
llvm::APSInt &Result) {
const auto *AttrExpr = Attr.getArgAsExpr(0);
- if (AttrExpr->isTypeDependent() || AttrExpr->isValueDependent() ||
- !AttrExpr->isIntegerConstantExpr(Result, S.Context)) {
- S.Diag(Attr.getLoc(), diag::err_attribute_argument_type)
- << Attr << AANT_ArgumentIntegerConstant << AttrExpr->getSourceRange();
- Attr.setInvalid();
- return false;
+ if (!AttrExpr->isTypeDependent() && !AttrExpr->isValueDependent()) {
+ if (Optional<llvm::APSInt> Res =
+ AttrExpr->getIntegerConstantExpr(S.Context)) {
+ Result = *Res;
+ return true;
+ }
}
- return true;
+ S.Diag(Attr.getLoc(), diag::err_attribute_argument_type)
+ << Attr << AANT_ArgumentIntegerConstant << AttrExpr->getSourceRange();
+ Attr.setInvalid();
+ return false;
}
/// HandleNeonVectorTypeAttr - The "neon_vector_type" and
@@ -7737,7 +7740,7 @@ static void HandleNeonVectorTypeAttr(QualType &CurType, const ParsedAttr &Attr,
// The total size of the vector must be 64 or 128 bits.
unsigned typeSize = static_cast<unsigned>(S.Context.getTypeSize(CurType));
- unsigned numElts = static_cast<unsigned>(numEltsInt->getZExtValue());
+ unsigned numElts = static_cast<unsigned>(numEltsInt.getZExtValue());
unsigned vecSize = typeSize * numElts;
if (vecSize != 64 && vecSize != 128) {
S.Diag(Attr.getLoc(), diag::err_attribute_bad_neon_vector_size) << CurType;
More information about the cfe-commits
mailing list