[clang] nonblocking/nonallocating attributes (was: nolock/noalloc) (PR #84983)

via cfe-commits cfe-commits at lists.llvm.org
Mon May 6 09:06:45 PDT 2024


================
@@ -7963,6 +7967,148 @@ static Attr *getCCTypeAttr(ASTContext &Ctx, ParsedAttr &Attr) {
   llvm_unreachable("unexpected attribute kind!");
 }
 
+ExprResult Sema::ActOnEffectExpression(Expr *CondExpr, FunctionEffectMode &Mode,
+                                       bool RequireConstexpr) {
+  // see checkFunctionConditionAttr, Sema::CheckCXXBooleanCondition
+  if (RequireConstexpr || !CondExpr->isTypeDependent()) {
+    ExprResult E = PerformContextuallyConvertToBool(CondExpr);
+    if (E.isInvalid())
+      return E;
+    CondExpr = E.get();
+    if (RequireConstexpr || !CondExpr->isValueDependent()) {
+      llvm::APSInt CondInt;
+      E = VerifyIntegerConstantExpression(
----------------
Sirraide wrote:

> Not quite sure how to construct a test that won't fail in uninteresting other ways

It’s fine if it does; I just want to make sure we don’t crash on a placeholder expression because that tends to be a recurring problem; the first one you have there is fine imo.

For unexpanded packs, I was thinking of something like this
```c++
template <bool ...val>
void f() [[clang::nonblocking(val /* NO ... here */)]] {} // error: unexpanded pack
```

which should be ill-formed imo.

https://github.com/llvm/llvm-project/pull/84983


More information about the cfe-commits mailing list