]> granicus.if.org Git - clang/commitdiff
make sure that ParseAST invokes the action for end of translation unit.
authorChris Lattner <sabre@nondot.org>
Sat, 23 Aug 2008 03:19:52 +0000 (03:19 +0000)
committerChris Lattner <sabre@nondot.org>
Sat, 23 Aug 2008 03:19:52 +0000 (03:19 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55222 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Parse/Action.h
lib/Parse/Parser.cpp
lib/Sema/Sema.cpp
lib/Sema/Sema.h

index 55ef67d177aaad63d4a3663579cca19e130ad97b..2da798241f0839246d9a6bfede0d7c762244ceca 100644 (file)
@@ -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() {}
   
   //===--------------------------------------------------------------------===//
index 417cc10bfb5d39d6a49897e8031aee69afa1c38b..a5fe551bfecc92270133cfec3154f952fe05fc90 100644 (file)
@@ -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:
index c2f73d2f80976505addf81ae1c62a8ffc05bc556..a73743fef69c659363778ef29e38389138dea88c 100644 (file)
@@ -129,6 +129,14 @@ void Sema::DeleteStmt(StmtTy *S) {
   delete static_cast<Stmt*>(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.
 //===----------------------------------------------------------------------===//
index a088bd3879a9a496e0c702afbc3ad553509577e3..c5ab94a7e4c853e7429537ef3a17fd0029b03be3 100644 (file)
@@ -197,6 +197,8 @@ public:
   virtual void DeleteExpr(ExprTy *E);
   virtual void DeleteStmt(StmtTy *S);
 
+  virtual void ActOnEndOfTranslationUnit();
+  
   //===--------------------------------------------------------------------===//
   // Type Analysis / Processing: SemaType.cpp.
   //