[cfe-commits] r52066 - in /cfe/trunk: Driver/clang.cpp include/clang/Basic/SourceManager.h
Ted Kremenek
kremenek at apple.com
Fri Jun 6 15:42:39 PDT 2008
Author: kremenek
Date: Fri Jun 6 17:42:39 2008
New Revision: 52066
URL: http://llvm.org/viewvc/llvm-project?rev=52066&view=rev
Log:
Use a common SourceManager when processing multiple files. This allows us to cache the contents of source files already loaded from disk.
Modified:
cfe/trunk/Driver/clang.cpp
cfe/trunk/include/clang/Basic/SourceManager.h
Modified: cfe/trunk/Driver/clang.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/clang.cpp?rev=52066&r1=52065&r2=52066&view=diff
==============================================================================
--- cfe/trunk/Driver/clang.cpp (original)
+++ cfe/trunk/Driver/clang.cpp Fri Jun 6 17:42:39 2008
@@ -1459,6 +1459,8 @@
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 @@
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 @@
// 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 @@
continue;
ProcessInputFile(*PP, PPFactory, InFile);
- HeaderInfo.ClearFileInfo();
+ HeaderInfo.ClearFileInfo();
if (Stats)
- SourceMgr.PrintStats();
+ SourceMgr->PrintStats();
}
}
+
delete Target;
unsigned NumDiagnostics = Diags.getNumDiagnostics();
Modified: cfe/trunk/include/clang/Basic/SourceManager.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/SourceManager.h?rev=52066&r1=52065&r2=52066&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/SourceManager.h (original)
+++ cfe/trunk/include/clang/Basic/SourceManager.h Fri Jun 6 17:42:39 2008
@@ -231,6 +231,7 @@
~SourceManager() {}
void clearIDTables() {
+ MainFileID = 0;
FileIDs.clear();
MacroIDs.clear();
LastLineNoFileIDQuery = ~0U;
More information about the cfe-commits
mailing list