summaryrefslogtreecommitdiffstats
path: root/clang/Driver/clang.cpp
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2008-06-06 22:42:39 +0000
committerTed Kremenek <kremenek@apple.com>2008-06-06 22:42:39 +0000
commit92611db88ff61cfa04b15dad7543fdc6295412b4 (patch)
treedcd155de824590bec6b444cd00604a6093c6228e /clang/Driver/clang.cpp
parentaf44b8329674ca509ab4dad57f7f034958d00380 (diff)
downloadbcm5719-llvm-92611db88ff61cfa04b15dad7543fdc6295412b4.tar.gz
bcm5719-llvm-92611db88ff61cfa04b15dad7543fdc6295412b4.zip
Use a common SourceManager when processing multiple files. This allows us to cache the contents of source files already loaded from disk.
llvm-svn: 52066
Diffstat (limited to 'clang/Driver/clang.cpp')
-rw-r--r--clang/Driver/clang.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/clang/Driver/clang.cpp b/clang/Driver/clang.cpp
index 5eec67ca879..6f7e1a256b1 100644
--- a/clang/Driver/clang.cpp
+++ b/clang/Driver/clang.cpp
@@ -1459,6 +1459,8 @@ int main(int argc, char **argv) {
exit(1);
}
+ llvm::OwningPtr<SourceManager> SourceMgr;
+
for (unsigned i = 0, e = InputFilenames.size(); i != e; ++i) {
const std::string &InFile = InputFilenames[i];
@@ -1467,7 +1469,10 @@ int main(int argc, char **argv) {
else {
/// Create a SourceManager object. This tracks and owns all the file
/// buffers allocated to a translation unit.
- SourceManager SourceMgr;
+ if (!SourceMgr)
+ SourceMgr.reset(new SourceManager());
+ else
+ SourceMgr->clearIDTables();
// Initialize language options, inferring file types from input filenames.
LangOptions LangInfo;
@@ -1490,7 +1495,7 @@ int main(int argc, char **argv) {
// Set up the preprocessor with these options.
DriverPreprocessorFactory PPFactory(InFile, Diags, LangInfo, *Target,
- SourceMgr, HeaderInfo);
+ *SourceMgr.get(), HeaderInfo);
llvm::OwningPtr<Preprocessor> PP(PPFactory.CreatePreprocessor());
@@ -1498,13 +1503,14 @@ int main(int argc, char **argv) {
continue;
ProcessInputFile(*PP, PPFactory, InFile);
- HeaderInfo.ClearFileInfo();
+ HeaderInfo.ClearFileInfo();
if (Stats)
- SourceMgr.PrintStats();
+ SourceMgr->PrintStats();
}
}
+
delete Target;
unsigned NumDiagnostics = Diags.getNumDiagnostics();
OpenPOWER on IntegriCloud