in LLVM we have the LLVMContext
, which is the unit of storage, and we have the llvm::Module
, which is where new symbols (functions and types) are built.
my question is; what is the right llvm abstraction to use for compilation units? is the Module
? or is this actually meant for a bigger scope, i.e: a shared library target
It seems to me that a compilation unit must satisfy an all-or-nothing result; either it compiles all its content without errors, or either there are errors and it needs to be fixed and built again before any symbols in the CU are usable. In my head, this is the definition of what a compilation unit should represent
if module is the right abstraction for the CU, how do i present the symbols in other (correctly compiled) Module
objects to a new module about to be built, in order that it is able to find those? do i need to add declarations or is there some other expedite way for this?
a point to a relevant line in clang
would be of great help
The Module is the correct abstraction for a compile unit. You can link together modules to do whole program analysis from there.