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 53dabbd..aa45c62 100644
--- a/AST/StmtSerialization.cpp
+++ b/AST/StmtSerialization.cpp
@@ -564,18 +564,18 @@
}
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<Stmt>();
Expr* Collection = D.ReadOwnedPtr<Expr>();
Stmt* Body = D.ReadOwnedPtr<Stmt>();
- 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 a2a3f3e..dccc00e 100644
--- a/Parse/ParseDecl.cpp
+++ b/Parse/ParseDecl.cpp
@@ -296,7 +296,7 @@
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 c17e35e..2c6a9ce 100644
--- a/Parse/ParseObjc.cpp
+++ b/Parse/ParseObjc.cpp
@@ -493,15 +493,12 @@
/// 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 762e499..e55c3f9 100644
--- a/Parse/ParseStmt.cpp
+++ b/Parse/ParseStmt.cpp
@@ -759,7 +759,7 @@
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 @@
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 58d61f6..445b8e4 100644
--- a/include/clang/AST/Stmt.h
+++ b/include/clang/AST/Stmt.h
@@ -579,7 +579,7 @@
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 @@
SubExprs[ELEM] = Elem;
SubExprs[COLLECTION] = reinterpret_cast<Stmt*>(Collect);
SubExprs[BODY] = Body;
- ForCollectionLoc = FCL;
+ ForLoc = FCL;
}
Stmt *getElement() { return SubExprs[ELEM]; }
@@ -603,7 +603,7 @@
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 40531b6..e74c385 100644
--- a/include/clang/Parse/Parser.h
+++ b/include/clang/Parse/Parser.h
@@ -294,7 +294,7 @@
bool isObjCPropertyAttribute();
IdentifierInfo *ObjCForCollectionInKW;
- bool isObjCForCollectionInKW();
+ bool isTokIdentifier_in() const;
TypeTy *ParseObjCTypeName(ObjcDeclSpec &DS);
void ParseObjCMethodRequirement();