[clang] nonblocking/nonallocating attributes (was: nolock/noalloc) (PR #84983)
Doug Wyatt via cfe-commits
cfe-commits at lists.llvm.org
Wed Apr 10 09:41:25 PDT 2024
================
@@ -4429,6 +4433,218 @@ class FunctionNoProtoType : public FunctionType, public llvm::FoldingSetNode {
}
};
+// ------------------------------------------------------------------------------
+
+// TODO: Should FunctionEffect be located elsewhere, where Decl is not
+// forward-declared?
+class Decl;
+class CXXMethodDecl;
+class FunctionEffectSet;
+class TypeSourceInfo;
+
+/// Represents an abstract function effect.
+class FunctionEffect {
+public:
+ /// Identifies the particular type of effect.
+ enum class Type {
+ None = 0,
+ NonBlocking,
+ NonAllocating,
+ };
+
+ /// Flags describing behaviors of the effect.
+ // (Why not a struct with bitfields? There's one function that would like to
+ // test a caller-specified bit. There are some potential optimizations that
+ // would OR together the bits of multiple effects.)
+ using Flags = unsigned;
+ enum FlagBit : unsigned {
+ // Can verification inspect callees' implementations? (e.g. nonblocking:
+ // yes, tcb+types: no)
+ FE_InferrableOnCallees = 0x1,
+
+ // Language constructs which effects can diagnose as disallowed.
+ FE_ExcludeThrow = 0x2,
+ FE_ExcludeCatch = 0x4,
+ FE_ExcludeObjCMessageSend = 0x8,
+ FE_ExcludeStaticLocalVars = 0x10,
+ FE_ExcludeThreadLocalVars = 0x20
+ };
+
+ /// Describes the result of effects differing between a base class's virtual
+ /// method and an overriding method in a subclass.
+ enum class OverrideResult {
+ Ignore,
+ Warn,
+ Propagate // Base method's effects are merged with those of the override.
+ };
+
+private:
+ // For uniqueness, currently only Type_ is significant.
+
+ LLVM_PREFERRED_TYPE(Type)
+ unsigned Type_ : 2;
+ Flags Flags_ : 8; // A constant function of Type but cached here.
+
+ // Expansion: for hypothetical TCB+types, there could be one Type for TCB,
+ // then ~16(?) bits "Subtype" to map to a specific named TCB. Subtype would
+ // be considered for uniqueness.
+
+ // Since this struct is serialized as if it were a uint32_t, it's important
+ // to pad and explicitly zero the extra bits.
+ [[maybe_unused]] unsigned Padding : 22;
+
+public:
+ using CalleeDeclOrType =
+ llvm::PointerUnion<const Decl *, const FunctionProtoType *>;
----------------
dougsonos wrote:
Thanks. It turns out to be unused, an artifact of a previous implementation.
https://github.com/llvm/llvm-project/pull/84983
More information about the cfe-commits
mailing list