[clang] nolock/noalloc attributes (PR #84983)

via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 12 16:22:57 PDT 2024


================
@@ -7754,6 +7905,145 @@ QualType DecayedType::getPointeeType() const {
 void FixedPointValueToString(SmallVectorImpl<char> &Str, llvm::APSInt Val,
                              unsigned Scale);
 
+// ------------------------------------------------------------------------------
+
+// TODO: Should FunctionEffect be located elsewhere, where Decl is not
+// forward-declared?
+class Decl;
+class CXXMethodDecl;
+
+/// Represents an abstract function effect.
+class FunctionEffect {
+public:
+  enum EffectType {
+    kGeneric,
+    kNoLockTrue,
+    kNoAllocTrue,
+  };
+
+  /// Flags describing behaviors of the effect.
+  using Flags = unsigned;
+  enum FlagBit : unsigned {
+    // Some effects require verification, e.g. nolock(true); others might not?
+    // (no example yet)
+    kRequiresVerification = 0x1,
----------------
Sirraide wrote:

Nit: I don’t think we really do `k...` constants anymore in Clang. If making this an unscoped enum works better, then we usually either do something like `FE_RequiresVerification` (`FE` for `FunctionEffect` perhaps), or, since this is declared in a class, you might be able to get away with just calling it `RequiresVerification`, but I’d have to check how we’re handling similar enums elsewhere in Clang.

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


More information about the cfe-commits mailing list