[cfe-commits] r43048 - in /cfe/trunk: Driver/RewriteTest.cpp Parse/ParseObjc.cpp Rewrite/Rewriter.cpp Sema/Sema.h Sema/SemaExpr.cpp include/clang/AST/Expr.h include/clang/Parse/Action.h include/clang/Parse/Parser.h
Chris Lattner
sabre at nondot.org
Tue Oct 16 15:51:17 PDT 2007
Author: lattner
Date: Tue Oct 16 17:51:17 2007
New Revision: 43048
URL: http://llvm.org/viewvc/llvm-project?rev=43048&view=rev
Log:
Fix location processing of @encode: the range should include the @ sign.
@selector probably gets this wrong also.
Modified:
cfe/trunk/Driver/RewriteTest.cpp
cfe/trunk/Parse/ParseObjc.cpp
cfe/trunk/Rewrite/Rewriter.cpp
cfe/trunk/Sema/Sema.h
cfe/trunk/Sema/SemaExpr.cpp
cfe/trunk/include/clang/AST/Expr.h
cfe/trunk/include/clang/Parse/Action.h
cfe/trunk/include/clang/Parse/Parser.h
Modified: cfe/trunk/Driver/RewriteTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/RewriteTest.cpp?rev=43048&r1=43047&r2=43048&view=diff
==============================================================================
--- cfe/trunk/Driver/RewriteTest.cpp (original)
+++ cfe/trunk/Driver/RewriteTest.cpp Tue Oct 16 17:51:17 2007
@@ -114,7 +114,7 @@
printf("BLAH!");
}
- Rewrite.RemoveText(Exp->getEncLoc(), Size);
+ Rewrite.RemoveText(Exp->getAtLoc(), Size);
#endif
}
Modified: cfe/trunk/Parse/ParseObjc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Parse/ParseObjc.cpp?rev=43048&r1=43047&r2=43048&view=diff
==============================================================================
--- cfe/trunk/Parse/ParseObjc.cpp (original)
+++ cfe/trunk/Parse/ParseObjc.cpp Tue Oct 16 17:51:17 2007
@@ -1125,16 +1125,16 @@
}
switch (Tok.getIdentifierInfo()->getObjCKeywordID()) {
- case tok::objc_encode:
- return ParsePostfixExpressionSuffix(ParseObjCEncodeExpression());
- case tok::objc_protocol:
- return ParsePostfixExpressionSuffix(ParseObjCProtocolExpression());
- case tok::objc_selector:
- return ParsePostfixExpressionSuffix(ParseObjCSelectorExpression());
- default:
- Diag(AtLoc, diag::err_unexpected_at);
- SkipUntil(tok::semi);
- break;
+ case tok::objc_encode:
+ return ParsePostfixExpressionSuffix(ParseObjCEncodeExpression(AtLoc));
+ case tok::objc_protocol:
+ return ParsePostfixExpressionSuffix(ParseObjCProtocolExpression());
+ case tok::objc_selector:
+ return ParsePostfixExpressionSuffix(ParseObjCSelectorExpression());
+ default:
+ Diag(AtLoc, diag::err_unexpected_at);
+ SkipUntil(tok::semi);
+ break;
}
return 0;
@@ -1259,7 +1259,7 @@
/// objc-encode-expression:
/// @encode ( type-name )
-Parser::ExprResult Parser::ParseObjCEncodeExpression() {
+Parser::ExprResult Parser::ParseObjCEncodeExpression(SourceLocation AtLoc) {
assert(Tok.isObjCAtKeyword(tok::objc_encode) && "Not an @encode expression!");
SourceLocation EncLoc = ConsumeToken();
@@ -1275,7 +1275,7 @@
SourceLocation RParenLoc = MatchRHSPunctuation(tok::r_paren, LParenLoc);
- return Actions.ParseObjCEncodeExpression(EncLoc, LParenLoc, Ty,
+ return Actions.ParseObjCEncodeExpression(AtLoc, EncLoc, LParenLoc, Ty,
RParenLoc);
}
Modified: cfe/trunk/Rewrite/Rewriter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Rewrite/Rewriter.cpp?rev=43048&r1=43047&r2=43048&view=diff
==============================================================================
--- cfe/trunk/Rewrite/Rewriter.cpp (original)
+++ cfe/trunk/Rewrite/Rewriter.cpp Tue Oct 16 17:51:17 2007
@@ -183,7 +183,17 @@
return I->second;
}
+/// RemoveText - Remove the specified text region. This method is only valid
+/// on a rewritable source location.
+void Rewriter::RemoveText(SourceLocation Start, unsigned Length) {
+ unsigned FileID;
+ unsigned StartOffs = getLocationOffsetAndFileID(Start, FileID);
+ getEditBuffer(FileID).RemoveText(StartOffs, Length);
+}
+/// ReplaceText - This method replaces a range of characters in the input
+/// buffer with a new string. This is effectively a combined "remove/insert"
+/// operation.
void Rewriter::ReplaceText(SourceLocation Start, unsigned OrigLength,
const char *NewStr, unsigned NewLength) {
assert(isRewritable(Start) && "Not a rewritable location!");
Modified: cfe/trunk/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/Sema.h?rev=43048&r1=43047&r2=43048&view=diff
==============================================================================
--- cfe/trunk/Sema/Sema.h (original)
+++ cfe/trunk/Sema/Sema.h Tue Oct 16 17:51:17 2007
@@ -440,6 +440,7 @@
// ParseObjCStringLiteral - Parse Objective-C string literals.
virtual ExprResult ParseObjCStringLiteral(ExprTy *string);
virtual ExprResult ParseObjCEncodeExpression(SourceLocation AtLoc,
+ SourceLocation EncodeLoc,
SourceLocation LParenLoc,
TypeTy *Ty,
SourceLocation RParenLoc);
Modified: cfe/trunk/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/SemaExpr.cpp?rev=43048&r1=43047&r2=43048&view=diff
==============================================================================
--- cfe/trunk/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/Sema/SemaExpr.cpp Tue Oct 16 17:51:17 2007
@@ -1910,6 +1910,7 @@
}
Sema::ExprResult Sema::ParseObjCEncodeExpression(SourceLocation AtLoc,
+ SourceLocation EncodeLoc,
SourceLocation LParenLoc,
TypeTy *Ty,
SourceLocation RParenLoc) {
Modified: cfe/trunk/include/clang/AST/Expr.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=43048&r1=43047&r2=43048&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/trunk/include/clang/AST/Expr.h Tue Oct 16 17:51:17 2007
@@ -1071,16 +1071,16 @@
/// ObjCEncodeExpr, used for @encode in Objective-C.
class ObjCEncodeExpr : public Expr {
QualType EncType;
- SourceLocation EncLoc, RParenLoc;
+ SourceLocation AtLoc, RParenLoc;
public:
ObjCEncodeExpr(QualType T, QualType ET,
- SourceLocation enc, SourceLocation rp)
- : Expr(ObjCEncodeExprClass, T), EncType(ET), EncLoc(enc), RParenLoc(rp) {}
+ SourceLocation at, SourceLocation rp)
+ : Expr(ObjCEncodeExprClass, T), EncType(ET), AtLoc(at), RParenLoc(rp) {}
- SourceLocation getEncLoc() const { return EncLoc; }
+ SourceLocation getAtLoc() const { return AtLoc; }
SourceLocation getRParenLoc() const { return RParenLoc; }
- SourceRange getSourceRange() const { return SourceRange(EncLoc, RParenLoc); }
+ SourceRange getSourceRange() const { return SourceRange(AtLoc, RParenLoc); }
QualType getEncodedType() const { return EncType; }
Modified: cfe/trunk/include/clang/Parse/Action.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Action.h?rev=43048&r1=43047&r2=43048&view=diff
==============================================================================
--- cfe/trunk/include/clang/Parse/Action.h (original)
+++ cfe/trunk/include/clang/Parse/Action.h Tue Oct 16 17:51:17 2007
@@ -587,7 +587,8 @@
return 0;
}
- virtual ExprResult ParseObjCEncodeExpression(SourceLocation EncLoc,
+ virtual ExprResult ParseObjCEncodeExpression(SourceLocation AtLoc,
+ SourceLocation EncLoc,
SourceLocation LParenLoc,
TypeTy *Ty,
SourceLocation RParenLoc) {
Modified: cfe/trunk/include/clang/Parse/Parser.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=43048&r1=43047&r2=43048&view=diff
==============================================================================
--- cfe/trunk/include/clang/Parse/Parser.h (original)
+++ cfe/trunk/include/clang/Parse/Parser.h Tue Oct 16 17:51:17 2007
@@ -362,7 +362,7 @@
// Objective-C Expressions
ExprResult ParseObjCAtExpression(SourceLocation AtLocation);
ExprResult ParseObjCStringLiteral();
- ExprResult ParseObjCEncodeExpression();
+ ExprResult ParseObjCEncodeExpression(SourceLocation AtLoc);
ExprResult ParseObjCSelectorExpression();
ExprResult ParseObjCProtocolExpression();
ExprResult ParseObjCMessageExpression();
More information about the cfe-commits
mailing list