summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/ParseAST.cpp
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2008-10-16 16:54:18 +0000
committerDaniel Dunbar <daniel@zuster.org>2008-10-16 16:54:18 +0000
commit33d29b3eae38b5dcc6d2f38bfe10d64ff669dff7 (patch)
tree00e3e57b6af472ad9ab9f06ce7cc8b4a19052423 /clang/lib/Sema/ParseAST.cpp
parent89656d2298ed069a12ffa2d7ce875d3d6d4f9a37 (diff)
downloadbcm5719-llvm-33d29b3eae38b5dcc6d2f38bfe10d64ff669dff7.tar.gz
bcm5719-llvm-33d29b3eae38b5dcc6d2f38bfe10d64ff669dff7.zip
Add --disable-free flag to clang.
- Disables the freeing of the ASTContext and the TranslationUnit after parsing & sema. - Primarily for timing the impact on -fsyntax-only timings. llvm-svn: 57643
Diffstat (limited to 'clang/lib/Sema/ParseAST.cpp')
-rw-r--r--clang/lib/Sema/ParseAST.cpp31
1 files changed, 20 insertions, 11 deletions
diff --git a/clang/lib/Sema/ParseAST.cpp b/clang/lib/Sema/ParseAST.cpp
index fc350968272..567cfc27630 100644
--- a/clang/lib/Sema/ParseAST.cpp
+++ b/clang/lib/Sema/ParseAST.cpp
@@ -26,26 +26,30 @@ using namespace clang;
/// ParseAST - Parse the entire file specified, notifying the ASTConsumer as
/// the file is parsed. This takes ownership of the ASTConsumer and
/// ultimately deletes it.
-void clang::ParseAST(Preprocessor &PP, ASTConsumer *Consumer, bool PrintStats) {
+///
+/// \param FreeMemory If false, the memory used for AST elements is
+/// not released.
+void clang::ParseAST(Preprocessor &PP, ASTConsumer *Consumer,
+ bool PrintStats, bool FreeMemory) {
// Collect global stats on Decls/Stmts (until we have a module streamer).
if (PrintStats) {
Decl::CollectingStats(true);
Stmt::CollectingStats(true);
}
- ASTContext Context(PP.getLangOptions(), PP.getSourceManager(),
- PP.getTargetInfo(),
- PP.getIdentifierTable(), PP.getSelectorTable());
-
- TranslationUnit TU(Context);
- Sema S(PP, Context, *Consumer);
+ ASTContext *Context =
+ new ASTContext(PP.getLangOptions(), PP.getSourceManager(),
+ PP.getTargetInfo(),
+ PP.getIdentifierTable(), PP.getSelectorTable());
+ TranslationUnit *TU = new TranslationUnit(*Context);
+ Sema S(PP, *Context, *Consumer);
Parser P(PP, S);
PP.EnterMainSourceFile();
// Initialize the parser.
P.Initialize();
- Consumer->InitializeTU(TU);
+ Consumer->InitializeTU(*TU);
Parser::DeclTy *ADecl;
@@ -55,17 +59,17 @@ void clang::ParseAST(Preprocessor &PP, ASTConsumer *Consumer, bool PrintStats) {
// skipping something.
if (ADecl) {
Decl* D = static_cast<Decl*>(ADecl);
- TU.AddTopLevelDecl(D); // TranslationUnit now owns the Decl.
+ TU->AddTopLevelDecl(D); // TranslationUnit now owns the Decl.
Consumer->HandleTopLevelDecl(D);
}
};
- Consumer->HandleTranslationUnit(TU);
+ Consumer->HandleTranslationUnit(*TU);
if (PrintStats) {
fprintf(stderr, "\nSTATISTICS:\n");
P.getActions().PrintStats();
- Context.PrintStats();
+ Context->PrintStats();
Decl::PrintStats();
Stmt::PrintStats();
Consumer->PrintStats();
@@ -73,4 +77,9 @@ void clang::ParseAST(Preprocessor &PP, ASTConsumer *Consumer, bool PrintStats) {
Decl::CollectingStats(false);
Stmt::CollectingStats(false);
}
+
+ if (FreeMemory) {
+ delete TU;
+ delete Context;
+ }
}
OpenPOWER on IntegriCloud