[clang] [CIR] Add framework for CIR to LLVM IR lowering (PR #124650)

Andy Kaylor via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 28 09:34:52 PST 2025


================
@@ -55,6 +55,9 @@ class CIRGenerator : public clang::ASTConsumer {
   void Initialize(clang::ASTContext &astContext) override;
   bool HandleTopLevelDecl(clang::DeclGroupRef group) override;
   mlir::ModuleOp getModule() const;
+  std::unique_ptr<mlir::MLIRContext> takeContext() {
----------------
andykaylor wrote:

I'm not sure why it was implemented this way, but I agree with you. In the incubator implementation, the class we're taking it from uses it in the Initialize() function and then never again, but in the Initialize() function it passes this as a raw pointer to one of its contained objects, which keeps it throughout its lifetime. So, we need to keep it around for the lifetime of the generator one way or another. I don't think anything will use it after the point that we take it here, but I also don't see any harm in making it safer.

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


More information about the cfe-commits mailing list