[cfe-commits] r112066 - in /cfe/trunk: include/clang/Sema/Action.h include/clang/Sema/Sema.h lib/Parse/Parser.cpp lib/Sema/Sema.cpp
Douglas Gregor
dgregor at apple.com
Wed Aug 25 11:07:12 PDT 2010
Author: dgregor
Date: Wed Aug 25 13:07:12 2010
New Revision: 112066
URL: http://llvm.org/viewvc/llvm-project?rev=112066&view=rev
Log:
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.
Modified:
cfe/trunk/include/clang/Sema/Action.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Parse/Parser.cpp
cfe/trunk/lib/Sema/Sema.cpp
Modified: cfe/trunk/include/clang/Sema/Action.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Action.h?rev=112066&r1=112065&r2=112066&view=diff
==============================================================================
--- cfe/trunk/include/clang/Sema/Action.h (original)
+++ cfe/trunk/include/clang/Sema/Action.h Wed Aug 25 13:07:12 2010
@@ -574,7 +574,7 @@
/// 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.
Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=112066&r1=112065&r2=112066&view=diff
==============================================================================
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Wed Aug 25 13:07:12 2010
@@ -829,7 +829,7 @@
/// 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.
Modified: cfe/trunk/lib/Parse/Parser.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/Parser.cpp?rev=112066&r1=112065&r2=112066&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/Parser.cpp (original)
+++ cfe/trunk/lib/Parse/Parser.cpp Wed Aug 25 13:07:12 2010
@@ -324,13 +324,13 @@
/// 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
Modified: cfe/trunk/lib/Sema/Sema.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.cpp?rev=112066&r1=112065&r2=112066&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/Sema.cpp (original)
+++ cfe/trunk/lib/Sema/Sema.cpp Wed Aug 25 13:07:12 2010
@@ -48,7 +48,7 @@
BlockScopeInfo::~BlockScopeInfo() { }
-void Sema::ActOnTranslationUnitScope(SourceLocation Loc, Scope *S) {
+void Sema::ActOnTranslationUnitScope(Scope *S) {
TUScope = S;
PushDeclContext(S, Context.getTranslationUnitDecl());
More information about the cfe-commits
mailing list