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

via cfe-commits cfe-commits at lists.llvm.org
Sat May 4 09:40:32 PDT 2024


================
@@ -3649,6 +3649,25 @@ FunctionProtoType::FunctionProtoType(QualType result, ArrayRef<QualType> params,
     auto &EllipsisLoc = *getTrailingObjects<SourceLocation>();
     EllipsisLoc = epi.EllipsisLoc;
   }
+
+  if (!epi.FunctionEffects.empty()) {
+    auto &ExtraBits = *getTrailingObjects<FunctionTypeExtraBitfields>();
+    // TODO: bitfield overflow?
+    ExtraBits.NumFunctionEffects = epi.FunctionEffects.size();
+
+    ArrayRef<FunctionEffect> SrcFX = epi.FunctionEffects.effects();
+    auto *DestFX = getTrailingObjects<FunctionEffect>();
+    std::copy(SrcFX.begin(), SrcFX.end(), DestFX);
----------------
Sirraide wrote:

```suggestion
    std::uninitialized_copy(SrcFX.begin(), SrcFX.end(), DestFX);
```
I think you’re supposed to do this since this is copying into uninitialised memory; that’s at least how code using `TrailingObjects` typically does it. 

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


More information about the cfe-commits mailing list