namespace clang {
class Preprocessor;
class ASTConsumer;
- class TranslationUnit;
+ class ASTContext;
/// ParseAST - Parse the entire file specified, notifying the ASTConsumer as
- /// the file is parsed. This inserts the parsed decls into TU.
+ /// the file is parsed. This inserts the parsed decls into the translation unit
+ /// held by Ctx.
///
void ParseAST(Preprocessor &pp, ASTConsumer *C,
- TranslationUnit &TU, bool PrintStats = false);
+ ASTContext &Ctx, bool PrintStats = false);
} // end namespace clang
//===----------------------------------------------------------------------===//
/// ParseAST - Parse the entire file specified, notifying the ASTConsumer as
-/// the file is parsed. This inserts the parsed decls into TU.
+/// the file is parsed. This inserts the parsed decls into the translation unit
+/// held by Ctx.
///
void clang::ParseAST(Preprocessor &PP, ASTConsumer *Consumer,
- TranslationUnit &TU, bool PrintStats) {
+ ASTContext &Ctx, bool PrintStats) {
// Collect global stats on Decls/Stmts (until we have a module streamer).
if (PrintStats) {
Decl::CollectingStats(true);
Stmt::CollectingStats(true);
}
- Sema S(PP, TU.getContext(), *Consumer);
+ Sema S(PP, Ctx, *Consumer);
Parser P(PP, S);
PP.EnterMainSourceFile();
// Initialize the parser.
P.Initialize();
- Consumer->Initialize(TU.getContext());
+ Consumer->Initialize(Ctx);
Parser::DeclTy *ADecl;
}
};
- Consumer->HandleTranslationUnit(TU.getContext());
+ Consumer->HandleTranslationUnit(Ctx);
if (PrintStats) {
fprintf(stderr, "\nSTATISTICS:\n");
P.getActions().PrintStats();
- TU.getContext().PrintStats();
+ Ctx.PrintStats();
Decl::PrintStats();
Stmt::PrintStats();
Consumer->PrintStats();
if (Consumer) {
llvm::OwningPtr<ASTContext> ContextOwner;
- llvm::OwningPtr<TranslationUnit> TranslationUnitOwner;
ContextOwner.reset(new ASTContext(PP.getLangOptions(),
PP.getSourceManager(),
PP.getIdentifierTable(),
PP.getSelectorTable(),
/* FreeMemory = */ !DisableFree));
- TranslationUnitOwner.reset(new TranslationUnit(*ContextOwner.get()));
- ParseAST(PP, Consumer.get(), *TranslationUnitOwner.get(), Stats);
+ ParseAST(PP, Consumer.get(), *ContextOwner.get(), Stats);
// If in -disable-free mode, don't deallocate these when they go out of
// scope.
- if (DisableFree) {
+ if (DisableFree)
ContextOwner.take();
- TranslationUnitOwner.take();
- }
}
if (VerifyDiagnostics)