v.g.vassilev added inline comments.
================ Comment at: clang/lib/CodeGen/ModuleBuilder.cpp:179 + bool + HandleTopLevelStmts(const llvm::SmallVectorImpl<Stmt *> &Stmts) override { + if (Diags.hasErrorOccurred()) ---------------- Hi @rjmccall, this patch tries to add support for statements on the global scope. Essentially we'd like to support something like: ``` int i = 0; for (; i < 10; i++) { ... } namespace N {...} i++; ``` This patch sends statements between two top-level declarations in blocks to CodeGen. I doubt we'd like to dissect CodeGen too much to expose API which can take a statement and put it in the `__cxx_global_var_init`. The only way I see to minimize the changes to clang is to wrap these statements into a `FunctionDecl` and/or the expression statements into a `VarDecl` initializer and then use CodeGen to emit the relevant code. My hesitation is that if we form the `FunctionDecl` without entering function scope in the frontend, would there be a clean way to instruct CodeGen to run this function as part of the initializer lists. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D127284/new/ https://reviews.llvm.org/D127284 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits