std::vector<std::pair<std::string, bool/*isPTH*/> > Includes;
std::vector<std::string> MacroIncludes;
+ unsigned UsePredefines : 1; /// Initialize the preprocessor with the compiler
+ /// and target specific predefines.
+
public:
+ PreprocessorInitOptions() : UsePredefines(true) {}
+
+ bool getUsePredefines() const { return UsePredefines; }
+ void setUsePredefines(bool Value) {
+ UsePredefines = Value;
+ }
void addMacroDef(const std::string &Name) {
Macros.push_back(std::make_pair(Name, false));
/// environment ready to process a single file. This returns true on error.
///
bool InitializePreprocessor(Preprocessor &PP,
- const PreprocessorInitOptions& InitOptions,
- bool undef_macros);
+ const PreprocessorInitOptions& InitOptions);
} // end namespace clang
/// environment ready to process a single file. This returns true on error.
///
bool clang::InitializePreprocessor(Preprocessor &PP,
- const PreprocessorInitOptions &InitOpts,
- bool undef_macros) {
+ const PreprocessorInitOptions &InitOpts) {
std::vector<char> PredefineBuffer;
const char *LineDirective = "# 1 \"<built-in>\" 3\n";
LineDirective, LineDirective+strlen(LineDirective));
// Install things like __POWERPC__, __GNUC__, etc into the macro table.
- if (!undef_macros)
+ if (InitOpts.getUsePredefines())
InitializePredefinedMacros(PP.getTargetInfo(), PP.getLangOptions(),
PredefineBuffer);
// Preprocessor Initialization
//===----------------------------------------------------------------------===//
-// FIXME: Preprocessor builtins to support.
-// -A... - Play with #assertions
-// -undef - Undefine all predefined macros
-
static llvm::cl::opt<bool>
-undef_macros("undef", llvm::cl::value_desc("macro"), llvm::cl::desc("undef all system defines"));
+UndefMacros("undef", llvm::cl::value_desc("macro"),
+ llvm::cl::desc("undef all system defines"));
static llvm::cl::list<std::string>
D_macros("D", llvm::cl::value_desc("macro"), llvm::cl::Prefix,
}
void InitializePreprocessorInitOptions(PreprocessorInitOptions &InitOpts) {
+ // Use predefines?
+ InitOpts.setUsePredefines(!UndefMacros);
+
// Add macros from the command line.
unsigned d = 0, D = D_macros.size();
unsigned u = 0, U = U_macros.size();
PreprocessorInitOptions InitOpts;
InitializePreprocessorInitOptions(InitOpts);
- if (InitializePreprocessor(*PP, InitOpts, undef_macros))
+ if (InitializePreprocessor(*PP, InitOpts))
return 0;
return PP.take();