]> granicus.if.org Git - clang/commitdiff
Fix RewriteObjC::RewriteObjCThrowStmt() to respect whitespace between the @ and throw.
authorSteve Naroff <snaroff@apple.com>
Fri, 25 Jul 2008 15:41:30 +0000 (15:41 +0000)
committerSteve Naroff <snaroff@apple.com>
Fri, 25 Jul 2008 15:41:30 +0000 (15:41 +0000)
This fixes <rdar://problem/5988388> clang ObjC rewriter: mystery 'w' inserted in exception throw.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54017 91177308-0d34-0410-b5e6-96231b3b80d8

Driver/RewriteObjC.cpp

index 0ee0599b892cd628367a6ddb28dbadc80fe467b0..641da1877d3595aa5da92f94d6e8afee634e976b 100644 (file)
@@ -1493,7 +1493,12 @@ Stmt *RewriteObjC::RewriteObjCThrowStmt(ObjCAtThrowStmt *S) {
     buf = "objc_exception_throw(";
   else // add an implicit argument
     buf = "objc_exception_throw(_caught";
-  ReplaceText(startLoc, 6, buf.c_str(), buf.size());
+  
+  // handle "@  throw" correctly.
+  const char *wBuf = strchr(startBuf, 'w');
+  assert((*wBuf == 'w') && "@throw: can't find 'w'");
+  ReplaceText(startLoc, wBuf-startBuf+1, buf.c_str(), buf.size());
+  
   const char *semiBuf = strchr(startBuf, ';');
   assert((*semiBuf == ';') && "@throw: can't find ';'");
   SourceLocation semiLoc = startLoc.getFileLocWithOffset(semiBuf-startBuf);