summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-08-25 18:07:12 +0000
committerDouglas Gregor <dgregor@apple.com>2010-08-25 18:07:12 +0000
commitf11096c99ce40cfb7eb02f86a612133deb8c1b58 (patch)
tree8ff60c1c0264a2e00a624ed5eed1d695275d221c
parentea14705c8c7370be38523b0b808f084a6848608d (diff)
downloadbcm5719-llvm-f11096c99ce40cfb7eb02f86a612133deb8c1b58.tar.gz
bcm5719-llvm-f11096c99ce40cfb7eb02f86a612133deb8c1b58.zip
Initialize the translation-unit scope before lexing the first
token. The first token might be something that ends up triggering code completion, which in turn requires a valid Scope. Test case forthcoming. llvm-svn: 112066
-rw-r--r--clang/include/clang/Sema/Action.h2
-rw-r--r--clang/include/clang/Sema/Sema.h2
-rw-r--r--clang/lib/Parse/Parser.cpp8
-rw-r--r--clang/lib/Sema/Sema.cpp2
4 files changed, 7 insertions, 7 deletions
diff --git a/clang/include/clang/Sema/Action.h b/clang/include/clang/Sema/Action.h
index e7fb732c342..5fb6d1f00f8 100644
--- a/clang/include/clang/Sema/Action.h
+++ b/clang/include/clang/Sema/Action.h
@@ -574,7 +574,7 @@ public:
/// ActOnTranslationUnitScope - This callback is called once, immediately
/// after creating the translation unit scope (in Parser::Initialize).
- virtual void ActOnTranslationUnitScope(SourceLocation Loc, Scope *S) {}
+ virtual void ActOnTranslationUnitScope(Scope *S) {}
/// ParsedFreeStandingDeclSpec - This method is invoked when a declspec with
/// no declarator (e.g. "struct foo;") is parsed.
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index ba1122e1eee..491a38668ad 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -829,7 +829,7 @@ public:
/// Scope actions.
virtual void ActOnPopScope(SourceLocation Loc, Scope *S);
- virtual void ActOnTranslationUnitScope(SourceLocation Loc, Scope *S);
+ virtual void ActOnTranslationUnitScope(Scope *S);
/// ParsedFreeStandingDeclSpec - This method is invoked when a declspec with
/// no declarator (e.g. "struct foo;") is parsed.
diff --git a/clang/lib/Parse/Parser.cpp b/clang/lib/Parse/Parser.cpp
index e277c3f80e1..23c13ebf9d5 100644
--- a/clang/lib/Parse/Parser.cpp
+++ b/clang/lib/Parse/Parser.cpp
@@ -324,13 +324,13 @@ Parser::~Parser() {
/// Initialize - Warm up the parser.
///
void Parser::Initialize() {
- // Prime the lexer look-ahead.
- ConsumeToken();
-
// Create the translation unit scope. Install it as the current scope.
assert(getCurScope() == 0 && "A scope is already active?");
EnterScope(Scope::DeclScope);
- Actions.ActOnTranslationUnitScope(Tok.getLocation(), getCurScope());
+ Actions.ActOnTranslationUnitScope(getCurScope());
+
+ // Prime the lexer look-ahead.
+ ConsumeToken();
if (Tok.is(tok::eof) &&
!getLang().CPlusPlus) // Empty source file is an extension in C
diff --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp
index 31d6f0dd324..2e8827ddec9 100644
--- a/clang/lib/Sema/Sema.cpp
+++ b/clang/lib/Sema/Sema.cpp
@@ -48,7 +48,7 @@ void FunctionScopeInfo::Clear(unsigned NumErrors) {
BlockScopeInfo::~BlockScopeInfo() { }
-void Sema::ActOnTranslationUnitScope(SourceLocation Loc, Scope *S) {
+void Sema::ActOnTranslationUnitScope(Scope *S) {
TUScope = S;
PushDeclContext(S, Context.getTranslationUnitDecl());
OpenPOWER on IntegriCloud