3

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?

Unheilig
  • 16,196
  • 193
  • 68
  • 98
Puppy
  • 144,682
  • 38
  • 256
  • 465
  • [This](https://stackoverflow.com/a/50581553) answer is clearer. To summarize, Clang emits function declarations lazily at their first use. There appear to be no flags or options to easily generate unused function declarations but only modify Clang's source code to change this behavior. – C.Y Apr 07 '22 at 10:20

1 Answers1

-1

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.

plasmacel
  • 8,183
  • 7
  • 53
  • 101
Puppy
  • 144,682
  • 38
  • 256
  • 465