diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2013-02-11 19:30:33 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2013-02-11 19:30:33 +0000 |
commit | b0fdab26d17293c6442bcf81573864212119dd5e (patch) | |
tree | 378aa13e78107bc562b913dea8ef9a8e92f16e8d | |
parent | 6ad180cf355f98798c3d06457516f8474b3d5e2d (diff) | |
download | bcm5719-llvm-b0fdab26d17293c6442bcf81573864212119dd5e.tar.gz bcm5719-llvm-b0fdab26d17293c6442bcf81573864212119dd5e.zip |
objective-C modern translator: Fixes a mistranslation
of @throw statement by finding location of the ';'
correctly. // rdar://13186010
llvm-svn: 174898
-rw-r--r-- | clang/lib/Rewrite/Frontend/RewriteModernObjC.cpp | 4 | ||||
-rw-r--r-- | clang/test/Rewriter/rewrite-modern-throw.m | 26 |
2 files changed, 29 insertions, 1 deletions
diff --git a/clang/lib/Rewrite/Frontend/RewriteModernObjC.cpp b/clang/lib/Rewrite/Frontend/RewriteModernObjC.cpp index 34ffd227237..f6886034114 100644 --- a/clang/lib/Rewrite/Frontend/RewriteModernObjC.cpp +++ b/clang/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/clang/test/Rewriter/rewrite-modern-throw.m b/clang/test/Rewriter/rewrite-modern-throw.m index 191238443d3..1564611a3a7 100644 --- a/clang/test/Rewriter/rewrite-modern-throw.m +++ b/clang/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 + |