aboutsummaryrefslogtreecommitdiff
path: root/lib/Frontend/RewriteObjC.cpp
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2010-01-28 01:41:20 +0000
committerFariborz Jahanian <fjahanian@apple.com>2010-01-28 01:41:20 +0000
commit7e20ffe322866f6a2e820e054da9bd0f6e9b0af4 (patch)
tree173f75690abae9bd5484c729cf6ee7902e841a79 /lib/Frontend/RewriteObjC.cpp
parentce7024e8a3793b05861a4904ecdb1272924ada14 (diff)
Fixes a rewrite bug rewriting nested ivars reference.
(Radar 7583971). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94724 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Frontend/RewriteObjC.cpp')
-rw-r--r--lib/Frontend/RewriteObjC.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/Frontend/RewriteObjC.cpp b/lib/Frontend/RewriteObjC.cpp
index c56055599b..68d9b27c40 100644
--- a/lib/Frontend/RewriteObjC.cpp
+++ b/lib/Frontend/RewriteObjC.cpp
@@ -167,7 +167,7 @@ namespace {
virtual void HandleTranslationUnit(ASTContext &C);
- void ReplaceStmt(Stmt *Old, Stmt *New) {
+ void ReplaceStmt(Stmt *Old, Stmt *New, int Size=0) {
Stmt *ReplacingStmt = ReplacedNodes[Old];
if (ReplacingStmt)
@@ -177,7 +177,7 @@ namespace {
return; // Used when rewriting the assignment of a property setter.
// If replacement succeeded or warning disabled return with no warning.
- if (!Rewrite.ReplaceStmt(Old, New)) {
+ if (!Rewrite.ReplaceStmt(Old, New, Size)) {
ReplacedNodes[Old] = New;
return;
}
@@ -1247,8 +1247,12 @@ Stmt *RewriteObjC::RewriteObjCIvarRefExpr(ObjCIvarRefExpr *IV,
// delete IV; leak for now, see RewritePropertySetter() usage for more info.
return ME;
}
-
- ReplaceStmt(IV->getBase(), PE);
+ // Get the old text, only to get its size.
+ std::string SStr;
+ llvm::raw_string_ostream S(SStr);
+ IV->getBase()->printPretty(S, *Context, 0, PrintingPolicy(LangOpts));
+ // Get the new text
+ ReplaceStmt(IV->getBase(), PE, S.str().size());
// Cannot delete IV->getBase(), since PE points to it.
// Replace the old base with the cast. This is important when doing
// embedded rewrites. For example, [newInv->_container addObject:0].