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

Doug Wyatt via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 10 09:59:08 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,
----------------
dougsonos wrote:

Thanks, will rename all of the `diagnoseX` methods to `shouldDiagnoseX`.

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


More information about the cfe-commits mailing list