================
@@ -18,9 +18,12 @@
 using namespace clang;
 using namespace clang::CIRGen;
 
-CIRGenFunctionInfo *CIRGenFunctionInfo::create() {
-  // For now we just create an empty CIRGenFunctionInfo.
-  CIRGenFunctionInfo *fi = new CIRGenFunctionInfo();
+CIRGenFunctionInfo *CIRGenFunctionInfo::create(CanQualType resultType) {
+  void *buffer = operator new(totalSizeToAlloc<ArgInfo>(1));
----------------
andykaylor wrote:

This is happening in `CGFunctionInfo::create()` in the classic codegen, and I 
think also in `Decl::operator new()`, but I understand that doesn't necessarily 
mean that it's safe. I couldn't find any instances of ASTContext::Allocate 
being used in the classic codegen. Is it safe to use it here?

I think that we are currently leaking these allocations. The pointers get 
stored in CIRGenTypes::functionInfos (a FoldingSet). In the incubator, they get 
deleted in the CIRGenTypes destructor, but it looks like that implementation is 
missing here. For the sake of discussion, this is the code that should be 
deleting this memory.

```
CIRGenTypes::~CIRGenTypes() {
  for (llvm::FoldingSet<CIRGenFunctionInfo>::iterator I = FunctionInfos.begin(),
                                                      E = FunctionInfos.end();
       I != E;)
    delete &*I++;
}
```

https://github.com/llvm/llvm-project/pull/135552
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to