================
@@ -322,6 +322,57 @@ static Attr *handleUnlikely(Sema &S, Stmt *St, const
ParsedAttr &A,
return ::new (S.Context) UnlikelyAttr(S.Context, A);
}
+CodeAlignAttr *Sema::BuildCodeAlignAttr(const AttributeCommonInfo &CI,
+ Expr *E) {
+ if (!E->isValueDependent()) {
+ llvm::APSInt ArgVal;
+ ExprResult Res = VerifyIntegerConstantExpression(E, &ArgVal);
+ if (Res.isInvalid())
+ return nullptr;
+ E = Res.get();
+
+ // This attribute requires a strictly positive value.
+ if (ArgVal <= 0) {
+ Diag(E->getExprLoc(), diag::err_attribute_requires_positive_integer)
+ << CI << /*positive*/ 0;
+ return nullptr;
+ }
+
+ // This attribute requires an integer argument which is a constant power of
+ // two between 1 and 4096 inclusive.
+ int AlignValue = ArgVal.getSExtValue();
+ if (AlignValue > CodeAlignAttr::getMaxValue() || !ArgVal.isPowerOf2()) {
+ Diag(CI.getLoc(), diag::err_attribute_power_of_two_in_range)
----------------
smanna12 wrote:
Done
https://github.com/llvm/llvm-project/pull/70762
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits