summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/ParseAST.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-03-28 01:37:17 +0000
committerChris Lattner <sabre@nondot.org>2009-03-28 01:37:17 +0000
commit84bcc4795e5bae96ae547421d8615471bbc87148 (patch)
tree0aeb629d592e1851c12783950417597b17799e1e /clang/lib/Sema/ParseAST.cpp
parent8b7b1b1aee8685c34130f7e4a8457a52558af034 (diff)
downloadbcm5719-llvm-84bcc4795e5bae96ae547421d8615471bbc87148.tar.gz
bcm5719-llvm-84bcc4795e5bae96ae547421d8615471bbc87148.zip
simplify ParseAST by sucking -disable-free handling logic up into
clang.cpp llvm-svn: 67890
Diffstat (limited to 'clang/lib/Sema/ParseAST.cpp')
-rw-r--r--clang/lib/Sema/ParseAST.cpp28
1 files changed, 6 insertions, 22 deletions
diff --git a/clang/lib/Sema/ParseAST.cpp b/clang/lib/Sema/ParseAST.cpp
index 6923476aeba..6b40d7fd185 100644
--- a/clang/lib/Sema/ParseAST.cpp
+++ b/clang/lib/Sema/ParseAST.cpp
@@ -25,40 +25,24 @@ using namespace clang;
//===----------------------------------------------------------------------===//
/// ParseAST - Parse the entire file specified, notifying the ASTConsumer as
-/// the file is parsed.
+/// the file is parsed. This inserts the parsed decls into TU.
///
-/// \param TU If 0, then memory used for AST elements will be allocated only
-/// for the duration of the ParseAST() call. In this case, the client should
-/// not access any AST elements after ParseAST() returns.
void clang::ParseAST(Preprocessor &PP, ASTConsumer *Consumer,
- TranslationUnit *TU, bool PrintStats) {
+ TranslationUnit &TU, bool PrintStats) {
// Collect global stats on Decls/Stmts (until we have a module streamer).
if (PrintStats) {
Decl::CollectingStats(true);
Stmt::CollectingStats(true);
}
- llvm::OwningPtr<ASTContext> ContextOwner;
- llvm::OwningPtr<TranslationUnit> TranslationUnitOwner;
- if (TU == 0) {
- ASTContext *Context = new ASTContext(PP.getLangOptions(),
- PP.getSourceManager(),
- PP.getTargetInfo(),
- PP.getIdentifierTable(),
- PP.getSelectorTable());
- ContextOwner.reset(Context);
- TU = new TranslationUnit(*Context);
- TranslationUnitOwner.reset(TU);
- }
-
- Sema S(PP, TU->getContext(), *Consumer);
+ Sema S(PP, TU.getContext(), *Consumer);
Parser P(PP, S);
PP.EnterMainSourceFile();
// Initialize the parser.
P.Initialize();
- Consumer->InitializeTU(*TU);
+ Consumer->InitializeTU(TU);
Parser::DeclTy *ADecl;
@@ -72,12 +56,12 @@ void clang::ParseAST(Preprocessor &PP, ASTConsumer *Consumer,
}
};
- Consumer->HandleTranslationUnit(*TU);
+ Consumer->HandleTranslationUnit(TU);
if (PrintStats) {
fprintf(stderr, "\nSTATISTICS:\n");
P.getActions().PrintStats();
- TU->getContext().PrintStats();
+ TU.getContext().PrintStats();
Decl::PrintStats();
Stmt::PrintStats();
Consumer->PrintStats();
OpenPOWER on IntegriCloud