Move InitializePreprocessor() to lib/Frontend from clang-cc


This is a patch for

It moves InitializePreprocessor() functionality to its own file under lib/Frontend from clang-cc.cpp.

This allows users of the clang libraries to properly initialize all the expected macros without copying and pasting 500 lines of code from clang-cc.cpp.

Not included are changes to Makefiles and such to properly add the new InitializePreprocessor.cpp file to the build system, since I do not know what is needed there.


InitPP.diff (42.4 KB)

Hi Alexei,

This looks generally fine, except that we really prefer libfrontend to not use cl::opt at all. We want all the command line option processing stuff to be in clang-cc, not in any lib directories. Can you refactor the code to populate a class from the command line options and pass that in instead?



All right, I’ll try.


Here’s an updated patch.


InitPP2.diff (45.1 KB)

Thanks Alexei, getting better. Minor nit picks:

+//===— InitPreprocessor.h - InitializePreprocessor function. –- C++ --===//


InitPP3.diff (44.9 KB)

Looks great, applied!

Thanks Alexei,