r174898 - objective-C modern translator: Fixes a mistranslation
Fariborz Jahanian
fjahanian at apple.com
Mon Feb 11 11:30:34 PST 2013
Author: fjahanian
Date: Mon Feb 11 13:30:33 2013
New Revision: 174898
URL: http://llvm.org/viewvc/llvm-project?rev=174898&view=rev
Log:
objective-C modern translator: Fixes a mistranslation
of @throw statement by finding location of the ';'
correctly. // rdar://13186010
Modified:
cfe/trunk/lib/Rewrite/Frontend/RewriteModernObjC.cpp
cfe/trunk/test/Rewriter/rewrite-modern-throw.m
Modified: cfe/trunk/lib/Rewrite/Frontend/RewriteModernObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Rewrite/Frontend/RewriteModernObjC.cpp?rev=174898&r1=174897&r2=174898&view=diff
==============================================================================
--- cfe/trunk/lib/Rewrite/Frontend/RewriteModernObjC.cpp (original)
+++ cfe/trunk/lib/Rewrite/Frontend/RewriteModernObjC.cpp Mon Feb 11 13:30:33 2013
@@ -2093,7 +2093,9 @@ Stmt *RewriteModernObjC::RewriteObjCThro
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())
Modified: cfe/trunk/test/Rewriter/rewrite-modern-throw.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Rewriter/rewrite-modern-throw.m?rev=174898&r1=174897&r2=174898&view=diff
==============================================================================
--- cfe/trunk/test/Rewriter/rewrite-modern-throw.m (original)
+++ cfe/trunk/test/Rewriter/rewrite-modern-throw.m Mon Feb 11 13:30:33 2013
@@ -65,3 +65,29 @@ int main()
}
}
@end
+
+// rdar://13186010
+ at class NSDictionary, NSException;
+ at class NSMutableDictionary;
+
+ at interface NSString
++ (id)stringWithFormat:(NSString *)format, ... ;
+ at end
+
+ at interface NSException
++ (NSException *)exceptionWithName:(NSString *)name reason:(NSString *)reason userInfo:(NSDictionary *)userInfo;
+ at end
+id *_imp__NSInvalidArgumentException;
+
+ at interface NSSetExpression @end
+
+ at 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 ;
+}
+ at end
+
More information about the cfe-commits
mailing list