diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2010-07-21 17:36:39 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2010-07-21 17:36:39 +0000 |
commit | 5f371ee49c11ced954ee2c805ff1adfdcef94774 (patch) | |
tree | b1a65e519ac69e82a0834d74531768d2da40e95a /lib/Rewrite/RewriteObjC.cpp | |
parent | f69ea958964ab0452299f1df68ce469b67d18d3a (diff) |
Fix a rewriter bug which originates in SemaInit involving
Constructor Initialization which computes Source Location
differently now. Fixes radar 8213998.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@109018 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Rewrite/RewriteObjC.cpp')
-rw-r--r-- | lib/Rewrite/RewriteObjC.cpp | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/lib/Rewrite/RewriteObjC.cpp b/lib/Rewrite/RewriteObjC.cpp index 351667e32f..2743a2bdc1 100644 --- a/lib/Rewrite/RewriteObjC.cpp +++ b/lib/Rewrite/RewriteObjC.cpp @@ -5098,7 +5098,14 @@ void RewriteObjC::RewriteByRefVar(VarDecl *ND) { startLoc = E->getLocStart(); startLoc = SM->getInstantiationLoc(startLoc); endBuf = SM->getCharacterData(startLoc); - + if (dyn_cast<CXXConstructExpr>(E)) { + // Hack alter! + // SemaInit sets startLoc to beginning of the initialized variable when + // rhs involvs copy construction initialization. Must compensate for this. + if (char *atEqual = strchr(endBuf, '=')) + endBuf = atEqual + 1; + } + ByrefType += " " + Name; ByrefType += " = {(void*)"; ByrefType += utostr(isa); @@ -5125,11 +5132,11 @@ void RewriteObjC::RewriteByRefVar(VarDecl *ND) { // // double __block BYREFVAR = 1.34, BYREFVAR2 = 1.37; // - const char *startBuf = SM->getCharacterData(startLoc); - const char *semiBuf = strchr(startBuf, ';'); + const char *startInitializerBuf = SM->getCharacterData(startLoc); + const char *semiBuf = strchr(startInitializerBuf, ';'); assert((*semiBuf == ';') && "RewriteByRefVar: can't find ';'"); SourceLocation semiLoc = - startLoc.getFileLocWithOffset(semiBuf-startBuf); + startLoc.getFileLocWithOffset(semiBuf-startInitializerBuf); InsertText(semiLoc, "}"); } |