From: Chris Lattner Date: Sat, 23 Aug 2008 03:19:52 +0000 (+0000) Subject: make sure that ParseAST invokes the action for end of translation unit. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9299f3fa85796613cc787a2062c9562d07c8613e;p=clang make sure that ParseAST invokes the action for end of translation unit. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55222 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Parse/Action.h b/include/clang/Parse/Action.h index 55ef67d177..2da798241f 100644 --- a/include/clang/Parse/Action.h +++ b/include/clang/Parse/Action.h @@ -181,6 +181,9 @@ public: return 0; } + /// ActOnEndOfTranslationUnit - This is called at the very end of the + /// translation unit when EOF is reached and all but the top-level scope is + /// popped. virtual void ActOnEndOfTranslationUnit() {} //===--------------------------------------------------------------------===// diff --git a/lib/Parse/Parser.cpp b/lib/Parse/Parser.cpp index 417cc10bfb..a5fe551bfe 100644 --- a/lib/Parse/Parser.cpp +++ b/lib/Parse/Parser.cpp @@ -274,7 +274,10 @@ void Parser::Initialize() { /// action tells us to. This returns true if the EOF was encountered. bool Parser::ParseTopLevelDecl(DeclTy*& Result) { Result = 0; - if (Tok.is(tok::eof)) return true; + if (Tok.is(tok::eof)) { + Actions.ActOnEndOfTranslationUnit(); + return true; + } Result = ParseExternalDeclaration(); return false; @@ -293,8 +296,6 @@ void Parser::ParseTranslationUnit() { ExitScope(); assert(CurScope == 0 && "Scope imbalance!"); - - Actions.ActOnEndOfTranslationUnit(); } /// ParseExternalDeclaration: diff --git a/lib/Sema/Sema.cpp b/lib/Sema/Sema.cpp index c2f73d2f80..a73743fef6 100644 --- a/lib/Sema/Sema.cpp +++ b/lib/Sema/Sema.cpp @@ -129,6 +129,14 @@ void Sema::DeleteStmt(StmtTy *S) { delete static_cast(S); } +/// ActOnEndOfTranslationUnit - This is called at the very end of the +/// translation unit when EOF is reached and all but the top-level scope is +/// popped. +void Sema::ActOnEndOfTranslationUnit() { + +} + + //===----------------------------------------------------------------------===// // Helper functions. //===----------------------------------------------------------------------===// diff --git a/lib/Sema/Sema.h b/lib/Sema/Sema.h index a088bd3879..c5ab94a7e4 100644 --- a/lib/Sema/Sema.h +++ b/lib/Sema/Sema.h @@ -197,6 +197,8 @@ public: virtual void DeleteExpr(ExprTy *E); virtual void DeleteStmt(StmtTy *S); + virtual void ActOnEndOfTranslationUnit(); + //===--------------------------------------------------------------------===// // Type Analysis / Processing: SemaType.cpp. //