From: Steve Naroff Date: Fri, 25 Jul 2008 15:41:30 +0000 (+0000) Subject: Fix RewriteObjC::RewriteObjCThrowStmt() to respect whitespace between the @ and throw. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4ba0acbe835b12b3755d138f364cd67044d7322f;p=clang Fix RewriteObjC::RewriteObjCThrowStmt() to respect whitespace between the @ and throw. This fixes 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 --- diff --git a/Driver/RewriteObjC.cpp b/Driver/RewriteObjC.cpp index 0ee0599b89..641da1877d 100644 --- a/Driver/RewriteObjC.cpp +++ b/Driver/RewriteObjC.cpp @@ -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);