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

Doug Wyatt via cfe-commits cfe-commits at lists.llvm.org
Mon May 6 10:03:44 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(
----------------
dougsonos wrote:

Thanks. With the unexpanded pack: During initial parsing of the function type, it's seen as dependent and represented that way, holding onto the condition.

Is there a way at this time to detect that the expression is not only dependent but an unexpanded pack? Maybe it's as simple as `E->containsUnexpandedParameterPack()`? That looks promising, but it's bugging me that there are no (obvious) precedents for this.

If I add `void g() { f<true, false>(); }` there is a second attempt to resolve the expression but it is still dependent, so clearly there is an error here. But I can imagine cases where it takes more than one level of template instantiation for a dependent expression to be resolved.

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


More information about the cfe-commits mailing list