aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/clang/Parse/Action.h3
-rw-r--r--lib/Parse/Parser.cpp7
-rw-r--r--lib/Sema/Sema.cpp8
-rw-r--r--lib/Sema/Sema.h2
4 files changed, 17 insertions, 3 deletions
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<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.
//===----------------------------------------------------------------------===//
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.
//