[cfe-commits] r76622 - in /cfe/trunk: include/clang/Parse/Parser.h lib/Sema/SemaCXXScopeSpec.cpp
Douglas Gregor
dgregor at apple.com
Tue Jul 21 11:59:29 PDT 2009
Author: dgregor
Date: Tue Jul 21 13:59:28 2009
New Revision: 76622
URL: http://llvm.org/viewvc/llvm-project?rev=76622&view=rev
Log:
Make Sema::ActOnCXXEnterDeclaratorScope robust against failures to compute
the declaration context, as occurs with out-of-line class template member
definitions.
Modified:
cfe/trunk/include/clang/Parse/Parser.h
cfe/trunk/lib/Sema/SemaCXXScopeSpec.cpp
Modified: cfe/trunk/include/clang/Parse/Parser.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=76622&r1=76621&r2=76622&view=diff
==============================================================================
--- cfe/trunk/include/clang/Parse/Parser.h (original)
+++ cfe/trunk/include/clang/Parse/Parser.h Tue Jul 21 13:59:28 2009
@@ -1089,7 +1089,8 @@
assert(!EnteredScope && "Already entered the scope!");
assert(SS.isSet() && "C++ scope was not set!");
P.Actions.ActOnCXXEnterDeclaratorScope(P.CurScope, SS);
- EnteredScope = true;
+ if (!SS.isInvalid())
+ EnteredScope = true;
}
~DeclaratorScopeObj() {
Modified: cfe/trunk/lib/Sema/SemaCXXScopeSpec.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCXXScopeSpec.cpp?rev=76622&r1=76621&r2=76622&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaCXXScopeSpec.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCXXScopeSpec.cpp Tue Jul 21 13:59:28 2009
@@ -286,7 +286,10 @@
/// The 'SS' should be a non-empty valid CXXScopeSpec.
void Sema::ActOnCXXEnterDeclaratorScope(Scope *S, const CXXScopeSpec &SS) {
assert(SS.isSet() && "Parser passed invalid CXXScopeSpec.");
- EnterDeclaratorContext(S, computeDeclContext(SS));
+ if (DeclContext *DC = computeDeclContext(SS))
+ EnterDeclaratorContext(S, DC);
+ else
+ const_cast<CXXScopeSpec&>(SS).setScopeRep(0);
}
/// ActOnCXXExitDeclaratorScope - Called when a declarator that previously
@@ -296,6 +299,8 @@
/// defining scope.
void Sema::ActOnCXXExitDeclaratorScope(Scope *S, const CXXScopeSpec &SS) {
assert(SS.isSet() && "Parser passed invalid CXXScopeSpec.");
- assert(S->getEntity() == computeDeclContext(SS) && "Context imbalance!");
- ExitDeclaratorContext(S);
+ assert((SS.isInvalid() || S->getEntity() == computeDeclContext(SS)) &&
+ "Context imbalance!");
+ if (!SS.isInvalid())
+ ExitDeclaratorContext(S);
}
More information about the cfe-commits
mailing list