From: Fariborz Jahanian Date: Fri, 4 Jan 2008 23:04:08 +0000 (+0000) Subject: Minor changes as suggested by Chris L. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=335a2d4122e41343fe11a775889b8bec5b14be60;p=clang Minor changes as suggested by Chris L. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@45598 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/AST/StmtSerialization.cpp b/AST/StmtSerialization.cpp index 53dabbd018..aa45c62dd3 100644 --- a/AST/StmtSerialization.cpp +++ b/AST/StmtSerialization.cpp @@ -564,18 +564,18 @@ ForStmt* ForStmt::CreateImpl(Deserializer& D) { } void ObjcForCollectionStmt::EmitImpl(Serializer& S) const { - S.Emit(ForCollectionLoc); + S.Emit(ForLoc); S.EmitOwnedPtr(getElement()); S.EmitOwnedPtr(getCollection()); S.EmitOwnedPtr(getBody()); } ObjcForCollectionStmt* ObjcForCollectionStmt::CreateImpl(Deserializer& D) { - SourceLocation ForCollectionLoc = SourceLocation::ReadVal(D); + SourceLocation ForLoc = SourceLocation::ReadVal(D); Stmt* Element = D.ReadOwnedPtr(); Expr* Collection = D.ReadOwnedPtr(); Stmt* Body = D.ReadOwnedPtr(); - return new ObjcForCollectionStmt(Element,Collection,Body,ForCollectionLoc); + return new ObjcForCollectionStmt(Element,Collection,Body,ForLoc); } void GotoStmt::EmitImpl(Serializer& S) const { diff --git a/Parse/ParseDecl.cpp b/Parse/ParseDecl.cpp index a2a3f3e7c0..dccc00e671 100644 --- a/Parse/ParseDecl.cpp +++ b/Parse/ParseDecl.cpp @@ -296,7 +296,7 @@ ParseInitDeclaratorListAfterFirstDeclarator(Declarator &D) { ConsumeToken(); return Actions.FinalizeDeclaratorGroup(CurScope, LastDeclInGroup); } - if (D.getContext() == Declarator::ForContext && isObjCForCollectionInKW()) { + if (D.getContext() == Declarator::ForContext && isTokIdentifier_in()) { return Actions.FinalizeDeclaratorGroup(CurScope, LastDeclInGroup); } Diag(Tok, diag::err_parse_error); diff --git a/Parse/ParseObjc.cpp b/Parse/ParseObjc.cpp index c17e35e6f4..2c6a9ceb94 100644 --- a/Parse/ParseObjc.cpp +++ b/Parse/ParseObjc.cpp @@ -493,15 +493,12 @@ bool Parser::isObjCPropertyAttribute() { /// objc-for-collection-in: 'in' /// -bool Parser::isObjCForCollectionInKW() { +bool Parser::isTokIdentifier_in() const { // FIXME: May have to do additional look-ahead to only allow for // valid tokens following an 'in'; such as an identifier, unary operators, // '[' etc. - if (getLang().ObjC2 && Tok.is(tok::identifier)) { - const IdentifierInfo *II = Tok.getIdentifierInfo(); - return II == ObjCForCollectionInKW; - } - return false; + return (getLang().ObjC2 && Tok.is(tok::identifier) && + Tok.getIdentifierInfo() == ObjCForCollectionInKW); } /// ParseObjcTypeQualifierList - This routine parses the objective-c's type diff --git a/Parse/ParseStmt.cpp b/Parse/ParseStmt.cpp index 762e499d81..e55c3f905d 100644 --- a/Parse/ParseStmt.cpp +++ b/Parse/ParseStmt.cpp @@ -759,7 +759,7 @@ Parser::StmtResult Parser::ParseForStatement() { DeclTy *aBlockVarDecl = ParseDeclaration(Declarator::ForContext); StmtResult stmtResult = Actions.ActOnDeclStmt(aBlockVarDecl); FirstPart = stmtResult.isInvalid ? 0 : stmtResult.Val; - if ((foreach = isObjCForCollectionInKW())) { + if ((foreach = isTokIdentifier_in())) { ConsumeToken(); // consume 'in' Value = ParseExpression(); if (!Value.isInvalid) @@ -778,7 +778,7 @@ Parser::StmtResult Parser::ParseForStatement() { if (Tok.is(tok::semi)) { ConsumeToken(); } - else if ((foreach = isObjCForCollectionInKW())) { + else if ((foreach = isTokIdentifier_in())) { ConsumeToken(); // consume 'in' Value = ParseExpression(); if (!Value.isInvalid) diff --git a/include/clang/AST/Stmt.h b/include/clang/AST/Stmt.h index 58d61f61cc..445b8e4844 100644 --- a/include/clang/AST/Stmt.h +++ b/include/clang/AST/Stmt.h @@ -579,7 +579,7 @@ public: class ObjcForCollectionStmt : public Stmt { enum { ELEM, COLLECTION, BODY, END_EXPR }; Stmt* SubExprs[END_EXPR]; // SubExprs[ELEM] is an expression or declstmt. - SourceLocation ForCollectionLoc; + SourceLocation ForLoc; public: ObjcForCollectionStmt(Stmt *Elem, Expr *Collect, Stmt *Body, SourceLocation FCL) @@ -587,7 +587,7 @@ public: SubExprs[ELEM] = Elem; SubExprs[COLLECTION] = reinterpret_cast(Collect); SubExprs[BODY] = Body; - ForCollectionLoc = FCL; + ForLoc = FCL; } Stmt *getElement() { return SubExprs[ELEM]; } @@ -603,7 +603,7 @@ public: const Stmt *getBody() const { return SubExprs[BODY]; } virtual SourceRange getSourceRange() const { - return SourceRange(ForCollectionLoc, SubExprs[BODY]->getLocEnd()); + return SourceRange(ForLoc, SubExprs[BODY]->getLocEnd()); } static bool classof(const Stmt *T) { return T->getStmtClass() == ObjcForCollectionStmtClass; diff --git a/include/clang/Parse/Parser.h b/include/clang/Parse/Parser.h index 40531b68b4..e74c38508f 100644 --- a/include/clang/Parse/Parser.h +++ b/include/clang/Parse/Parser.h @@ -294,7 +294,7 @@ private: bool isObjCPropertyAttribute(); IdentifierInfo *ObjCForCollectionInKW; - bool isObjCForCollectionInKW(); + bool isTokIdentifier_in() const; TypeTy *ParseObjCTypeName(ObjcDeclSpec &DS); void ParseObjCMethodRequirement();