[clang] [clang] Add support for new loop attribute [[clang::code_align()]] (PR #70762)
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Mon Nov 6 10:55:16 PST 2023
================
@@ -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;
+ }
----------------
AaronBallman wrote:
This doesn't seem necessary as `0` is not a power of two in the correct range.
```suggestion
```
https://github.com/llvm/llvm-project/pull/70762
More information about the cfe-commits
mailing list