[cfe-commits] r49873 - /cfe/trunk/Driver/clang.cpp
Ted Kremenek
kremenek at apple.com
Thu Apr 17 14:38:34 PDT 2008
Author: kremenek
Date: Thu Apr 17 16:38:34 2008
New Revision: 49873
URL: http://llvm.org/viewvc/llvm-project?rev=49873&view=rev
Log:
Generate the Preprocessor using a local PreprocessorFactory object.
While this adds no extra functionality now, we will soon pass the
PreprocessorFactory object to some ASTConsumers.
Modified:
cfe/trunk/Driver/clang.cpp
Modified: cfe/trunk/Driver/clang.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/clang.cpp?rev=49873&r1=49872&r2=49873&view=diff
==============================================================================
--- cfe/trunk/Driver/clang.cpp (original)
+++ cfe/trunk/Driver/clang.cpp Thu Apr 17 16:38:34 2008
@@ -1009,6 +1009,32 @@
}
}
+//===----------------------------------------------------------------------===//
+// Driver PreprocessorFactory - For lazily generating preprocessors ...
+//===----------------------------------------------------------------------===//
+
+namespace {
+class VISIBILITY_HIDDEN DriverPreprocessorFactory : public PreprocessorFactory {
+ Diagnostic &Diags;
+ const LangOptions &LangInfo;
+ TargetInfo &Target;
+ SourceManager &SourceMgr;
+ HeaderSearch &HeaderInfo;
+
+public:
+ DriverPreprocessorFactory(Diagnostic &diags, const LangOptions &opts,
+ TargetInfo &target, SourceManager &SM,
+ HeaderSearch &Headers)
+ : Diags(diags), LangInfo(opts), Target(target),
+ SourceMgr(SM), HeaderInfo(Headers) {}
+
+ virtual ~DriverPreprocessorFactory() {}
+
+ virtual Preprocessor* CreatePreprocessor() {
+ return new Preprocessor(Diags, LangInfo, Target, SourceMgr, HeaderInfo);
+ }
+};
+}
//===----------------------------------------------------------------------===//
// Basic Parser driver
@@ -1361,13 +1387,16 @@
InitializeIncludePaths(argv[0], HeaderInfo, FileMgr, LangInfo);
// Set up the preprocessor with these options.
- Preprocessor PP(Diags, LangInfo, *Target, SourceMgr, HeaderInfo);
+ DriverPreprocessorFactory PPFactory(Diags, LangInfo, *Target,
+ SourceMgr, HeaderInfo);
+ llvm::OwningPtr<Preprocessor> PP(PPFactory.CreatePreprocessor());
+
std::vector<char> PredefineBuffer;
- if (!InitializePreprocessor(PP, InFile, PredefineBuffer))
+ if (!InitializePreprocessor(*PP, InFile, PredefineBuffer))
continue;
- ProcessInputFile(PP, InFile);
+ ProcessInputFile(*PP, InFile);
HeaderInfo.ClearFileInfo();
if (Stats)
More information about the cfe-commits
mailing list