diff options
author | Douglas Gregor <dgregor@apple.com> | 2010-08-25 18:07:12 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2010-08-25 18:07:12 +0000 |
commit | c1a3e5e73859ece9f106ae9d84c78bef4111956a (patch) | |
tree | 69169d264ef6b775ba1ceedb90a9bf5286469997 | |
parent | 59a66946aa7723c7b14831aa50902d533baaa957 (diff) |
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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112066 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/clang/Sema/Action.h | 2 | ||||
-rw-r--r-- | include/clang/Sema/Sema.h | 2 | ||||
-rw-r--r-- | lib/Parse/Parser.cpp | 8 | ||||
-rw-r--r-- | lib/Sema/Sema.cpp | 2 |
4 files changed, 7 insertions, 7 deletions
diff --git a/include/clang/Sema/Action.h b/include/clang/Sema/Action.h index e7fb732c34..5fb6d1f00f 100644 --- a/include/clang/Sema/Action.h +++ b/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/include/clang/Sema/Sema.h b/include/clang/Sema/Sema.h index ba1122e1ee..491a38668a 100644 --- a/include/clang/Sema/Sema.h +++ b/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/lib/Parse/Parser.cpp b/lib/Parse/Parser.cpp index e277c3f80e..23c13ebf9d 100644 --- a/lib/Parse/Parser.cpp +++ b/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/lib/Sema/Sema.cpp b/lib/Sema/Sema.cpp index 31d6f0dd32..2e8827ddec 100644 --- a/lib/Sema/Sema.cpp +++ b/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()); |