================
@@ -322,6 +322,90 @@ 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 an integer argument which is a constant power of
+ // two between 1 and 4096 inclusive.
+ // Check if an expression resulting in a negative/positive cases that take
+ // more than 64 bits.
+ // Print the actual alignment value passing to the attribute if it is less
+ // than 64 bits otherwise print the expression.
+ if (ArgVal < CodeAlignAttr::MinimumAlignment ||
+ (ArgVal < CodeAlignAttr::MaximumAlignment && !ArgVal.isPowerOf2())) {
+ if (!ArgVal.trySExtValue()) {
----------------
erichkeane wrote:
```suggestion
if (std::optional<int64_t> Value = ArgVal.trySExtValue()) {
```
Invert the cases here so you can use the value that you got out of the
`trySExtValue`.
https://github.com/llvm/llvm-project/pull/70762
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits