aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Rewrite/Frontend/RewriteModernObjC.cpp4
-rw-r--r--test/Rewriter/rewrite-modern-throw.m26
2 files changed, 29 insertions, 1 deletions
diff --git a/lib/Rewrite/Frontend/RewriteModernObjC.cpp b/lib/Rewrite/Frontend/RewriteModernObjC.cpp
index 34ffd22723..f688603411 100644
--- a/lib/Rewrite/Frontend/RewriteModernObjC.cpp
+++ b/lib/Rewrite/Frontend/RewriteModernObjC.cpp
@@ -2093,7 +2093,9 @@ Stmt *RewriteModernObjC::RewriteObjCThrowStmt(ObjCAtThrowStmt *S) {
assert((*wBuf == 'w') && "@throw: can't find 'w'");
ReplaceText(startLoc, wBuf-startBuf+1, buf);
- const char *semiBuf = strchr(startBuf, ';');
+ SourceLocation endLoc = S->getLocEnd();
+ const char *endBuf = SM->getCharacterData(endLoc);
+ const char *semiBuf = strchr(endBuf, ';');
assert((*semiBuf == ';') && "@throw: can't find ';'");
SourceLocation semiLoc = startLoc.getLocWithOffset(semiBuf-startBuf);
if (S->getThrowExpr())
diff --git a/test/Rewriter/rewrite-modern-throw.m b/test/Rewriter/rewrite-modern-throw.m
index 191238443d..1564611a3a 100644
--- a/test/Rewriter/rewrite-modern-throw.m
+++ b/test/Rewriter/rewrite-modern-throw.m
@@ -65,3 +65,29 @@ int main()
}
}
@end
+
+// rdar://13186010
+@class NSDictionary, NSException;
+@class NSMutableDictionary;
+
+@interface NSString
++ (id)stringWithFormat:(NSString *)format, ... ;
+@end
+
+@interface NSException
++ (NSException *)exceptionWithName:(NSString *)name reason:(NSString *)reason userInfo:(NSDictionary *)userInfo;
+@end
+id *_imp__NSInvalidArgumentException;
+
+@interface NSSetExpression @end
+
+@implementation NSSetExpression
+-(id)expressionValueWithObject:(id)object context:(NSMutableDictionary*)bindings {
+ id leftSet;
+ id rightSet;
+ @throw [NSException exceptionWithName: *_imp__NSInvalidArgumentException reason: [NSString stringWithFormat: @"Can't evaluate set expression; left subexpression not a set (lhs = %@ rhs = %@)", leftSet, rightSet] userInfo: 0];
+
+ return leftSet ;
+}
+@end
+