[cfe-commits] r162303 - in /cfe/trunk: lib/Rewrite/RewriteModernObjC.cpp test/Rewriter/objc-modern-StretAPI-2.mm
Fariborz Jahanian
fjahanian at apple.com
Tue Aug 21 11:56:51 PDT 2012
Author: fjahanian
Date: Tue Aug 21 13:56:50 2012
New Revision: 162303
URL: http://llvm.org/viewvc/llvm-project?rev=162303&view=rev
Log:
Modern objc translator: Fixes a crash in rewriter when rewriting the API
for structure valued method messaging. // rdar://12142241
Added:
cfe/trunk/test/Rewriter/objc-modern-StretAPI-2.mm
Modified:
cfe/trunk/lib/Rewrite/RewriteModernObjC.cpp
Modified: cfe/trunk/lib/Rewrite/RewriteModernObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Rewrite/RewriteModernObjC.cpp?rev=162303&r1=162302&r2=162303&view=diff
==============================================================================
--- cfe/trunk/lib/Rewrite/RewriteModernObjC.cpp (original)
+++ cfe/trunk/lib/Rewrite/RewriteModernObjC.cpp Tue Aug 21 13:56:50 2012
@@ -3140,7 +3140,14 @@
str += "\t"; str += returnType.getAsString(Context->getPrintingPolicy());
str += " s;\n";
str += "};\n\n";
- SourceLocation FunLocStart = getFunctionSourceLocation(*this, CurFunctionDef);
+ SourceLocation FunLocStart;
+ if (CurFunctionDef)
+ FunLocStart = getFunctionSourceLocation(*this, CurFunctionDef);
+ else {
+ assert(CurMethodDef && "SynthMsgSendStretCallExpr - CurMethodDef is null");
+ FunLocStart = CurMethodDef->getLocStart();
+ }
+
InsertText(FunLocStart, str);
++stretCount;
Added: cfe/trunk/test/Rewriter/objc-modern-StretAPI-2.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Rewriter/objc-modern-StretAPI-2.mm?rev=162303&view=auto
==============================================================================
--- cfe/trunk/test/Rewriter/objc-modern-StretAPI-2.mm (added)
+++ cfe/trunk/test/Rewriter/objc-modern-StretAPI-2.mm Tue Aug 21 13:56:50 2012
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"Class=void*" -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
+// rdar://12142241
+
+extern "C" void *sel_registerName(const char *);
+typedef unsigned long size_t;
+
+typedef unsigned long NSUInteger;
+typedef struct _NSRange {
+ NSUInteger location;
+ NSUInteger length;
+} NSRange;
+
+
+ at interface NSIndexSet
+- (NSRange)rangeAtIndex:(NSUInteger)rangeIndex;
+ at end
+
+ at interface NSArray
+ at end
+
+ at implementation NSArray
+- (NSArray *)objectsAtIndexes:(NSIndexSet *)iset {
+
+ NSUInteger ridx = 0;
+ NSRange range = [iset rangeAtIndex:ridx];
+ return 0;
+}
+ at end
+
More information about the cfe-commits
mailing list