summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-07-22 06:05:44 +0000
committerChris Lattner <sabre@nondot.org>2007-07-22 06:05:44 +0000
commit6b4db176eaf5b7fd28d0e4abfee2652047fd9df0 (patch)
tree9e93f40811a7433c07550a9f6ecd54bf02618a1f
parente34b2c298ae2fa7cb559364f70c78f0e6cc840c4 (diff)
downloadbcm5719-llvm-6b4db176eaf5b7fd28d0e4abfee2652047fd9df0.tar.gz
bcm5719-llvm-6b4db176eaf5b7fd28d0e4abfee2652047fd9df0.zip
when running in -E mode on multiple files, there is no reason to accumulate
fileid's and macroid's across files. Clearing between files keeps the tables smaller and slightly speeds up compilation. llvm-svn: 40383
-rw-r--r--clang/Driver/clang.cpp15
-rw-r--r--clang/include/clang/Basic/SourceManager.h5
2 files changed, 20 insertions, 0 deletions
diff --git a/clang/Driver/clang.cpp b/clang/Driver/clang.cpp
index 4ef7400c343..6016b9a50af 100644
--- a/clang/Driver/clang.cpp
+++ b/clang/Driver/clang.cpp
@@ -770,6 +770,7 @@ static void ProcessInputFile(Preprocessor &PP, unsigned MainFileID,
TextDiagnostics &OurDiagnosticClient,
HeaderSearch &HeaderInfo,
const LangOptions &LangInfo) {
+ bool ClearSourceMgr = false;
switch (ProgAction) {
default:
fprintf(stderr, "Unexpected program action!\n");
@@ -783,6 +784,7 @@ static void ProcessInputFile(Preprocessor &PP, unsigned MainFileID,
PP.DumpToken(Tok, true);
fprintf(stderr, "\n");
} while (Tok.getKind() != tok::eof);
+ ClearSourceMgr = true;
break;
}
case RunPreprocessorOnly: { // Just lex as fast as we can, no output.
@@ -792,19 +794,23 @@ static void ProcessInputFile(Preprocessor &PP, unsigned MainFileID,
do {
PP.Lex(Tok);
} while (Tok.getKind() != tok::eof);
+ ClearSourceMgr = true;
break;
}
case PrintPreprocessedInput: // -E mode.
DoPrintPreprocessedInput(MainFileID, PP, LangInfo);
+ ClearSourceMgr = true;
break;
case ParseNoop: // -parse-noop
ParseFile(PP, new MinimalAction(), MainFileID);
+ ClearSourceMgr = true;
break;
case ParsePrintCallbacks:
ParseFile(PP, CreatePrintParserActionsAction(), MainFileID);
+ ClearSourceMgr = true;
break;
case ParseSyntaxOnly: // -fsyntax-only
case ParseAST:
@@ -826,8 +832,17 @@ static void ProcessInputFile(Preprocessor &PP, unsigned MainFileID,
PP.PrintStats();
PP.getIdentifierTable().PrintStats();
HeaderInfo.PrintStats();
+ if (ClearSourceMgr)
+ SourceMgr.PrintStats();
fprintf(stderr, "\n");
}
+
+ // For a multi-file compilation, some things are ok with nuking the source
+ // manager tables, other require stable fileid/macroid's across multiple
+ // files.
+ if (ClearSourceMgr) {
+ SourceMgr.clearIDTables();
+ }
}
static llvm::cl::list<std::string>
diff --git a/clang/include/clang/Basic/SourceManager.h b/clang/include/clang/Basic/SourceManager.h
index 414b1789a75..f06a6fbf54a 100644
--- a/clang/include/clang/Basic/SourceManager.h
+++ b/clang/include/clang/Basic/SourceManager.h
@@ -158,6 +158,11 @@ public:
SourceManager() {}
~SourceManager();
+ void clearIDTables() {
+ FileIDs.clear();
+ MacroIDs.clear();
+ }
+
/// createFileID - Create a new FileID that represents the specified file
/// being #included from the specified IncludePosition. This returns 0 on
/// error and translates NULL into standard input.
OpenPOWER on IntegriCloud