[CodeGen] Keep track of decls that were deferred and have been emitted.
authorJun Zhang <jun@junz.org>
Wed, 13 Jul 2022 10:00:06 +0000 (18:00 +0800)
committerJun Zhang <jun@junz.org>
Wed, 13 Jul 2022 12:00:59 +0000 (20:00 +0800)
commit8082a00286380d0dafa05bfe5ddfe6075b9769f9
tree1f502867180971a4a6ed3b539dfdf3c1307ce955
parentb8d83e8004e4b70fa81e8582eb9f8443a0f3758c
[CodeGen] Keep track of decls that were deferred and have been emitted.

This patch adds a new field called EmittedDeferredDecls in CodeGenModule
that keeps track of decls that were deferred and have been emitted.

The intention of this patch is to solve issues in the incremental c++,
we'll lose info of decls that are lazily emitted when we undo their
usage.

See example below:

clang-repl> inline int foo() { return 42;}
clang-repl> int bar = foo();
clang-repl> %undo
clang-repl> int baz = foo();
JIT session error: Symbols not found: [ _Z3foov ]
error: Failed to materialize symbols: { (main, { baz, $.incr_module_2.inits.0,
orc_init_func.incr_module_2 }) }

Signed-off-by: Jun Zhang <jun@junz.org>
Differential Revision: https://reviews.llvm.org/D128782
clang/lib/CodeGen/CodeGenModule.cpp
clang/lib/CodeGen/CodeGenModule.h
clang/test/Interpreter/code-undo.cpp