[clang] nonblocking/nonallocating attributes (was: nolock/noalloc) (PR #84983)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Apr 9 08:58:48 PDT 2024
================
@@ -5016,3 +5024,254 @@ void AutoType::Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context) {
Profile(ID, Context, getDeducedType(), getKeyword(), isDependentType(),
getTypeConstraintConcept(), getTypeConstraintArguments());
}
+
+FunctionEffect::FunctionEffect(Type T)
+ : Type_(static_cast<unsigned>(T)), Flags_(0), Padding(0) {
+ switch (T) {
+ case Type::NonBlocking:
+ Flags_ = FE_InferrableOnCallees | FE_ExcludeThrow | FE_ExcludeCatch |
+ FE_ExcludeObjCMessageSend | FE_ExcludeStaticLocalVars |
+ FE_ExcludeThreadLocalVars;
+ break;
+
+ case Type::NonAllocating:
+ // Same as NonBlocking, except without FE_ExcludeStaticLocalVars
+ Flags_ = FE_InferrableOnCallees | FE_ExcludeThrow | FE_ExcludeCatch |
+ FE_ExcludeObjCMessageSend | FE_ExcludeThreadLocalVars;
+ break;
+ default:
+ break;
+ }
+}
+
+StringRef FunctionEffect::name() const {
+ switch (type()) {
+ default:
+ return "";
+ case Type::NonBlocking:
+ return "nonblocking";
+ case Type::NonAllocating:
+ return "nonallocating";
+ }
+}
+
+bool FunctionEffect::diagnoseConversion(bool Adding, QualType OldType,
----------------
Sirraide wrote:
I don’t think a function should be called `diagnoseX` if it doesn’t issue a diagnostic. This only seems to check whether the conversion is valid; something like `shouldDiagnoseX` or `isValidX` or something else in that vein would probably be better in this case.
https://github.com/llvm/llvm-project/pull/84983
More information about the cfe-commits
mailing list