#include "clang/Basic/LangOptions.h"
#include "clang/Frontend/DiagnosticOptions.h"
#include "clang/Frontend/HeaderSearchOptions.h"
+#include "clang/Frontend/PreprocessorOptions.h"
#include "llvm/ADT/StringMap.h"
#include <string>
/// Options controlling the diagnostic engine.
DiagnosticOptions DiagOpts;
- /// Set of target-specific code generation features to enable/disable.
- llvm::StringMap<bool> TargetFeatures;
+ /// Options controlling the #include directive.
+ HeaderSearchOptions HeaderSearchOpts;
/// Options controlling the language variant.
LangOptions LangOpts;
- /// Options controlling the #include directive.
- HeaderSearchOptions HeaderSearchOpts;
+ /// Options controlling the preprocessor (aside from #include handling).
+ PreprocessorOptions PreprocessorOpts;
+
+ /// Set of target-specific code generation features to enable/disable.
+ llvm::StringMap<bool> TargetFeatures;
public:
CompilerInvocation() {}
DiagnosticOptions &getDiagnosticOpts() { return DiagOpts; }
const DiagnosticOptions &getDiagnosticOpts() const { return DiagOpts; }
- llvm::StringMap<bool> &getTargetFeatures() { return TargetFeatures; }
- const llvm::StringMap<bool> &getTargetFeatures() const {
- return TargetFeatures;
+ HeaderSearchOptions &getHeaderSearchOpts() { return HeaderSearchOpts; }
+ const HeaderSearchOptions &getHeaderSearchOpts() const {
+ return HeaderSearchOpts;
}
LangOptions &getLangOpts() { return LangOpts; }
const LangOptions &getLangOpts() const { return LangOpts; }
- HeaderSearchOptions &getHeaderSearchOpts() { return HeaderSearchOpts; }
- const HeaderSearchOptions &getHeaderSearchOpts() const {
- return HeaderSearchOpts;
+ PreprocessorOptions &getPreprocessorOpts() { return PreprocessorOpts; }
+ const PreprocessorOptions &getPreprocessorOpts() const {
+ return PreprocessorOpts;
+ }
+
+ llvm::StringMap<bool> &getTargetFeatures() { return TargetFeatures; }
+ const llvm::StringMap<bool> &getTargetFeatures() const {
+ return TargetFeatures;
}
};
Opts.UseStandardIncludes = !nostdinc;
}
-void InitializePreprocessorOptions(PreprocessorOptions &InitOpts) {
+static void InitializePreprocessorOptions(PreprocessorOptions &InitOpts) {
// Use predefines?
InitOpts.setUsePredefines(!UndefMacros);
//===----------------------------------------------------------------------===//
static Preprocessor *
-CreatePreprocessor(Diagnostic &Diags,const LangOptions &LangInfo,
- TargetInfo &Target, SourceManager &SourceMgr,
- HeaderSearch &HeaderInfo) {
+CreatePreprocessor(Diagnostic &Diags, const LangOptions &LangInfo,
+ const PreprocessorOptions &PPOpts, TargetInfo &Target,
+ SourceManager &SourceMgr, HeaderSearch &HeaderInfo) {
PTHManager *PTHMgr = 0;
if (!TokenCache.empty() && !ImplicitIncludePTH.empty()) {
fprintf(stderr, "error: cannot use both -token-cache and -include-pth "
PP->setPTHManager(PTHMgr);
}
- PreprocessorOptions InitOpts;
- InitializePreprocessorOptions(InitOpts);
- InitializePreprocessor(*PP, InitOpts);
+ InitializePreprocessor(*PP, PPOpts);
return PP;
}
// Initialize the header search options.
InitializeIncludePaths(Opts.getHeaderSearchOpts(), Argv0, Opts.getLangOpts());
+
+ // Initialize the other preprocessor options.
+ InitializePreprocessorOptions(Opts.getPreprocessorOpts());
}
int main(int argc, char **argv) {
CompOpts.getLangOpts(), Triple);
// Set up the preprocessor with these options.
- llvm::OwningPtr<Preprocessor> PP(CreatePreprocessor(Diags,
- CompOpts.getLangOpts(),
- *Target, SourceMgr,
- HeaderInfo));
+ llvm::OwningPtr<Preprocessor>
+ PP(CreatePreprocessor(Diags, CompOpts.getLangOpts(),
+ CompOpts.getPreprocessorOpts(), *Target, SourceMgr,
+ HeaderInfo));
// Handle generating dependencies, if requested.
if (!DependencyFile.empty()) {