From: Fariborz Jahanian Date: Tue, 16 Oct 2007 23:21:02 +0000 (+0000) Subject: Fix location processing of @selector: the range should include the @ sign. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2a35fa9b5e0f9d9429c04adb2e1249b6fd425e7a;p=clang Fix location processing of @selector: the range should include the @ sign. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43051 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/Parse/ParseObjc.cpp b/Parse/ParseObjc.cpp index 4579650085..0b6f303a48 100644 --- a/Parse/ParseObjc.cpp +++ b/Parse/ParseObjc.cpp @@ -1128,9 +1128,9 @@ Parser::ExprResult Parser::ParseObjCAtExpression(SourceLocation AtLoc) { case tok::objc_encode: return ParsePostfixExpressionSuffix(ParseObjCEncodeExpression(AtLoc)); case tok::objc_protocol: - return ParsePostfixExpressionSuffix(ParseObjCProtocolExpression()); + return ParsePostfixExpressionSuffix(ParseObjCProtocolExpression(AtLoc)); case tok::objc_selector: - return ParsePostfixExpressionSuffix(ParseObjCSelectorExpression()); + return ParsePostfixExpressionSuffix(ParseObjCSelectorExpression(AtLoc)); default: Diag(AtLoc, diag::err_unexpected_at); SkipUntil(tok::semi); @@ -1282,7 +1282,7 @@ Parser::ExprResult Parser::ParseObjCEncodeExpression(SourceLocation AtLoc) { /// objc-protocol-expression /// @protocol ( protocol-name ) -Parser::ExprResult Parser::ParseObjCProtocolExpression() +Parser::ExprResult Parser::ParseObjCProtocolExpression(SourceLocation AtLoc) { SourceLocation ProtoLoc = ConsumeToken(); @@ -1309,7 +1309,7 @@ Parser::ExprResult Parser::ParseObjCProtocolExpression() /// objc-selector-expression /// @selector '(' objc-keyword-selector ')' -Parser::ExprResult Parser::ParseObjCSelectorExpression() +Parser::ExprResult Parser::ParseObjCSelectorExpression(SourceLocation AtLoc) { SourceLocation SelectorLoc = ConsumeToken(); @@ -1347,6 +1347,6 @@ Parser::ExprResult Parser::ParseObjCSelectorExpression() SourceLocation RParenLoc = MatchRHSPunctuation(tok::r_paren, LParenLoc); Selector Sel = PP.getSelectorTable().getSelector(KeyIdents.size(), &KeyIdents[0]); - return Actions.ParseObjCSelectorExpression(Sel, SelectorLoc, LParenLoc, + return Actions.ParseObjCSelectorExpression(Sel, AtLoc, SelectorLoc, LParenLoc, RParenLoc); } \ No newline at end of file diff --git a/Sema/Sema.h b/Sema/Sema.h index 5d36aced05..bb5d07fd6d 100644 --- a/Sema/Sema.h +++ b/Sema/Sema.h @@ -448,6 +448,7 @@ public: // ParseObjCSelectorExpression - Build selector expression for @selector virtual ExprResult ParseObjCSelectorExpression(Selector Sel, SourceLocation AtLoc, + SourceLocation SelLoc, SourceLocation LParenLoc, SourceLocation RParenLoc); diff --git a/Sema/SemaExpr.cpp b/Sema/SemaExpr.cpp index e016cbb368..a6a47adddb 100644 --- a/Sema/SemaExpr.cpp +++ b/Sema/SemaExpr.cpp @@ -1922,6 +1922,7 @@ Sema::ExprResult Sema::ParseObjCEncodeExpression(SourceLocation AtLoc, Sema::ExprResult Sema::ParseObjCSelectorExpression(Selector Sel, SourceLocation AtLoc, + SourceLocation SelLoc, SourceLocation LParenLoc, SourceLocation RParenLoc) { QualType t = GetObjcSelType(AtLoc); diff --git a/clang.xcodeproj/project.pbxproj b/clang.xcodeproj/project.pbxproj index b88c381faa..75d938806b 100644 --- a/clang.xcodeproj/project.pbxproj +++ b/clang.xcodeproj/project.pbxproj @@ -742,6 +742,7 @@ 08FB7793FE84155DC02AAC07 /* Project object */ = { isa = PBXProject; buildConfigurationList = 1DEB923508733DC60010E9CD /* Build configuration list for PBXProject "clang" */; + compatibilityVersion = "Xcode 2.4"; hasScannedForEncodings = 1; mainGroup = 08FB7794FE84155DC02AAC07 /* clang */; projectDirPath = ""; diff --git a/include/clang/AST/Expr.h b/include/clang/AST/Expr.h index 1b932deedc..64e47b4fe0 100644 --- a/include/clang/AST/Expr.h +++ b/include/clang/AST/Expr.h @@ -1099,21 +1099,23 @@ class ObjCSelectorExpr : public Expr { Selector SelName; - SourceLocation SelLoc, RParenLoc; + SourceLocation AtLoc, RParenLoc; public: ObjCSelectorExpr(QualType T, Selector selInfo, - SourceLocation selLoc, SourceLocation rp) + SourceLocation at, SourceLocation rp) : Expr(ObjCSelectorExprClass, T), SelName(selInfo), - SelLoc(selLoc), RParenLoc(rp) {} + AtLoc(at), RParenLoc(rp) {} const Selector &getSelector() const { return SelName; } Selector &getSelector() { return SelName; } + SourceLocation getAtLoc() const { return AtLoc; } + SourceLocation getRParenLoc() const { return RParenLoc; } + SourceRange getSourceRange() const { return SourceRange(AtLoc, RParenLoc); } + /// getNumArgs - Return the number of actual arguments to this call. unsigned getNumArgs() const { return SelName.getNumArgs(); } - SourceRange getSourceRange() const { return SourceRange(SelLoc, RParenLoc); } - static bool classof(const Stmt *T) { return T->getStmtClass() == ObjCSelectorExprClass; } diff --git a/include/clang/Parse/Action.h b/include/clang/Parse/Action.h index faadf17945..d68850582f 100644 --- a/include/clang/Parse/Action.h +++ b/include/clang/Parse/Action.h @@ -596,6 +596,7 @@ public: } virtual ExprResult ParseObjCSelectorExpression(Selector Sel, + SourceLocation AtLoc, SourceLocation SelLoc, SourceLocation LParenLoc, SourceLocation RParenLoc) { diff --git a/include/clang/Parse/Parser.h b/include/clang/Parse/Parser.h index bc249bb4df..8c0b8e47bf 100644 --- a/include/clang/Parse/Parser.h +++ b/include/clang/Parse/Parser.h @@ -363,8 +363,8 @@ private: ExprResult ParseObjCAtExpression(SourceLocation AtLocation); ExprResult ParseObjCStringLiteral(); ExprResult ParseObjCEncodeExpression(SourceLocation AtLoc); - ExprResult ParseObjCSelectorExpression(); - ExprResult ParseObjCProtocolExpression(); + ExprResult ParseObjCSelectorExpression(SourceLocation AtLoc); + ExprResult ParseObjCProtocolExpression(SourceLocation AtLoc); ExprResult ParseObjCMessageExpression(); //===--------------------------------------------------------------------===//