================ @@ -7963,6 +7968,154 @@ static Attr *getCCTypeAttr(ASTContext &Ctx, ParsedAttr &Attr) { llvm_unreachable("unexpected attribute kind!"); } +std::optional<FunctionEffectMode> +Sema::ActOnEffectExpression(Expr *CondExpr, StringRef AttributeName) { + auto BadExpr = [&]() { + Diag(CondExpr->getExprLoc(), diag::err_attribute_argument_type) + << ("'" + AttributeName.str() + "'") << AANT_ArgumentIntegerConstant + << CondExpr->getSourceRange(); + return std::nullopt; + }; + + if (CondExpr->isTypeDependent() || CondExpr->isValueDependent()) { + if (CondExpr->containsUnexpandedParameterPack()) + return BadExpr(); + return FunctionEffectMode::Dependent; + } + + std::optional<llvm::APSInt> ConditionValue = + CondExpr->getIntegerConstantExpr(Context); + if (!ConditionValue) + return BadExpr(); + return ConditionValue->getExtValue() ? FunctionEffectMode::True + : FunctionEffectMode::False; +} + +static bool +handleNonBlockingNonAllocatingTypeAttr(TypeProcessingState &TPState, + ParsedAttr &PAttr, QualType &QT, + FunctionTypeUnwrapper &Unwrapped) { + // Delay if this is not a function type. + if (!Unwrapped.isFunctionType()) + return false; + + Sema &S = TPState.getSema(); + + // Require FunctionProtoType + auto *FPT = Unwrapped.get()->getAs<FunctionProtoType>(); + if (FPT == nullptr) { + S.Diag(PAttr.getLoc(), diag::err_func_with_effects_no_prototype) + << PAttr.getAttrName()->getName(); + return true; + } + + // Parse the new attribute. + // non/blocking or non/allocating? Or conditional (computed)? + const bool IsNonBlocking = PAttr.getKind() == ParsedAttr::AT_NonBlocking || ---------------- AaronBallman wrote:
Our const correctness story is a story of sadness and woe, but we basically don't use top-level const in the project (`const foo *` is encouraged, `const foo * const` is not). And we rely on this to some extent with our uses of `const_cast` to cast away const presuming that the original definition is not actually `const`, so it's usually best to just consistently drop top-level const. https://github.com/llvm/llvm-project/pull/84983 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits