mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-24 01:56:05 +00:00

Main motivation: including `llvm/CodeGen/CommandFlags.h` in `CommonLinkerContext.h` means that the declaration of `llvm::Reloc` is visible in any file that includes `CommonLinkerContext.h`. Since our cpp files have both `using namespace llvm` and `using namespace lld::macho`, this results in conflicts with `lld::macho::Reloc`. I suppose we could put `llvm::Reloc` into a nested namespace, but in general, I think we should avoid transitively including too many header files in a very widely used header like `CommonLinkerContext.h`. RegisterCodeGenFlags' ctor initializes a bunch of function-`static` structures and does nothing else, so it should be fine to "initialize" it as a temporary stack variable rather than as a file static. Reviewed By: aganea Differential Revision: https://reviews.llvm.org/D119913