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);
//
// 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, "}");
}
--- /dev/null
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
+// rdar : // 8213998
+
+typedef unsigned int NSUInteger;
+
+typedef struct _NSRange {
+ NSUInteger location;
+ NSUInteger length;
+} NSRange;
+
+static __inline NSRange NSMakeRange(NSUInteger loc, NSUInteger len) {
+ NSRange r;
+ r.location = loc;
+ r.length = len;
+ return r;
+}
+
+void bar() {
+ __block NSRange previousRange = NSMakeRange(0, 0);
+ void (^blk)() = ^{
+ previousRange = NSMakeRange(1, 0);
+ };
+}