Search code examples
c++clangllvm

How can I code generate unused declarations with Clang?


I'm looking to code generate an llvm::Module from some C++ code.

Specifically, I will be mixing code generated by Clang and code from another source. Unfortunately, Clang's CodeGenModule class appears to insist on only generating a declaration into the Module if there is a definition which uses it.

How can I convince the CodeGenModule to generate these declarations anyway?


Solution

  • Apparently, -femit-all-decls does not actually emit all the decls, so I had to modify Clang's source code to actually emit all the decls.