[cfe-commits] r130293 - in /cfe/trunk: include/clang/Parse/Parser.h lib/Parse/ParseDecl.cpp lib/Parse/ParseExprCXX.cpp lib/Parse/ParseStmt.cpp
Douglas Gregor
dgregor at apple.com
Tue Apr 26 22:41:15 PDT 2011
Author: dgregor
Date: Wed Apr 27 00:41:15 2011
New Revision: 130293
URL: http://llvm.org/viewvc/llvm-project?rev=130293&view=rev
Log:
Simplify the parser's handling of Sema::ClassifyName() for types, by
creating a type-annotation token rather than jumping into the
declaration parsing.
Modified:
cfe/trunk/include/clang/Parse/Parser.h
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/lib/Parse/ParseExprCXX.cpp
cfe/trunk/lib/Parse/ParseStmt.cpp
Modified: cfe/trunk/include/clang/Parse/Parser.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=130293&r1=130292&r2=130293&view=diff
==============================================================================
--- cfe/trunk/include/clang/Parse/Parser.h (original)
+++ cfe/trunk/include/clang/Parse/Parser.h Wed Apr 27 00:41:15 2011
@@ -149,7 +149,7 @@
/// ColonProtectionRAIIObject RAII object.
bool ColonIsSacred;
- /// \brief When true, we are directly inside an Ojective-C messsage
+ /// \brief When true, we are directly inside an Objective-C messsage
/// send expression.
///
/// This is managed by the \c InMessageExpressionRAIIObject class, and
Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=130293&r1=130292&r2=130293&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Wed Apr 27 00:41:15 2011
@@ -2954,9 +2954,6 @@
case tok::kw_virtual:
case tok::kw_explicit:
- // typedef-name
- case tok::annot_typename:
-
// static_assert-declaration
case tok::kw__Static_assert:
@@ -2971,6 +2968,11 @@
case tok::less:
return getLang().ObjC1;
+ // typedef-name
+ case tok::annot_typename:
+ return !DisambiguatingWithExpression ||
+ !isStartOfObjCClassMessageMissingOpenBracket();
+
case tok::kw___declspec:
case tok::kw___cdecl:
case tok::kw___stdcall:
Modified: cfe/trunk/lib/Parse/ParseExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExprCXX.cpp?rev=130293&r1=130292&r2=130293&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseExprCXX.cpp (original)
+++ cfe/trunk/lib/Parse/ParseExprCXX.cpp Wed Apr 27 00:41:15 2011
@@ -956,8 +956,7 @@
case tok::kw_char16_t:
case tok::kw_char32_t:
case tok::kw_bool:
- // FIXME: C++0x decltype support.
- // GNU typeof support.
+ case tok::kw_decltype:
case tok::kw_typeof:
return true;
Modified: cfe/trunk/lib/Parse/ParseStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseStmt.cpp?rev=130293&r1=130292&r2=130293&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseStmt.cpp (original)
+++ cfe/trunk/lib/Parse/ParseStmt.cpp Wed Apr 27 00:41:15 2011
@@ -114,7 +114,6 @@
}
if (Next.isNot(tok::coloncolon)) {
- // FIXME: Temporarily enable this code only for C.
CXXScopeSpec SS;
IdentifierInfo *Name = Tok.getIdentifierInfo();
SourceLocation NameLoc = Tok.getLocation();
@@ -147,63 +146,13 @@
// we're in a syntactic context we haven't handled yet.
break;
- case Sema::NC_Type: {
- // We have a type. In C, this means that we have a declaration.
- if (!getLang().CPlusPlus) {
- ParsedType Type = Classification.getType();
- const char *PrevSpec = 0;
- unsigned DiagID;
- ConsumeToken(); // the identifier
- ParsingDeclSpec DS(*this);
- DS.takeAttributesFrom(attrs);
- DS.SetTypeSpecType(DeclSpec::TST_typename, NameLoc, PrevSpec, DiagID,
- Type);
- DS.SetRangeStart(NameLoc);
- DS.SetRangeEnd(NameLoc);
-
- // In Objective-C, check whether this is the start of a class message
- // send that is missing an opening square bracket ('[').
- if (getLang().ObjC1 && Tok.is(tok::identifier) &&
- Type.get()->isObjCObjectOrInterfaceType() &&
- isColonOrRSquareBracket(NextToken())) {
- // Fake up a Declarator to use with ActOnTypeName.
- Declarator DeclaratorInfo(DS, Declarator::TypeNameContext);
- TypeResult Ty = Actions.ActOnTypeName(getCurScope(), DeclaratorInfo);
- if (Ty.isInvalid()) {
- SkipUntil(tok::r_brace, /*StopAtSemi=*/true, /*DontConsume=*/true);
- if (Tok.is(tok::semi))
- ConsumeToken();
- return StmtError();
- }
-
- ExprResult MsgExpr = ParseObjCMessageExpressionBody(SourceLocation(),
- SourceLocation(),
- Ty.get(), 0);
- return ParseExprStatement(attrs, MsgExpr);
- }
-
- // Objective-C supports syntax of the form 'id<proto1,proto2>' where
- // 'id' is a specific typedef and 'itf<proto1,proto2>' where 'itf' is
- // an Objective-C interface.
- if (Tok.is(tok::less) && getLang().ObjC1)
- ParseObjCProtocolQualifiers(DS);
-
- SourceLocation DeclStart = NameLoc, DeclEnd;
- DeclGroupPtrTy Decl = ParseSimpleDeclaration(DS, Stmts,
- Declarator::BlockContext,
- DeclEnd, true);
- return Actions.ActOnDeclStmt(Decl, DeclStart, DeclEnd);
- }
-
- // In C++, we might also have a functional-style cast. Just annotate
- // this as a type token.
+ case Sema::NC_Type:
Tok.setKind(tok::annot_typename);
setTypeAnnotation(Tok, Classification.getType());
Tok.setAnnotationEndLoc(NameLoc);
Tok.setLocation(NameLoc);
PP.AnnotateCachedTokens(Tok);
break;
- }
case Sema::NC_Expression:
ConsumeToken(); // the identifier
More information about the cfe-commits
mailing list