diff options
author | Daniel Dunbar <daniel@zuster.org> | 2009-08-19 19:10:30 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2009-08-19 19:10:30 +0000 |
commit | d7407dc92c7d19cafce429e7e1cf9819d3fc0b92 (patch) | |
tree | b1682301e20128532bd5143096f2eee9f99794f1 /lib/Frontend/RewriteObjC.cpp | |
parent | 7e37c818f9f77608c602ffb32c1135e3cd0132a8 (diff) |
Convert parts of Rewriter to StringRef based API.
- Please accept my sincere apologies for the gratuitous elimination of code
duplication, manual string length counting, unnecessary strlen calls, etc.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@79448 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Frontend/RewriteObjC.cpp')
-rw-r--r-- | lib/Frontend/RewriteObjC.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/Frontend/RewriteObjC.cpp b/lib/Frontend/RewriteObjC.cpp index 72982d2309..b3de53671b 100644 --- a/lib/Frontend/RewriteObjC.cpp +++ b/lib/Frontend/RewriteObjC.cpp @@ -175,7 +175,7 @@ namespace { const std::string &Str = S.str(); // If replacement succeeded or warning disabled return with no warning. - if (!Rewrite.ReplaceText(SrcRange.getBegin(), Size, &Str[0], Str.size())) { + if (!Rewrite.ReplaceText(SrcRange.getBegin(), Size, Str)) { ReplacedNodes[Old] = New; return; } @@ -188,7 +188,8 @@ namespace { void InsertText(SourceLocation Loc, const char *StrData, unsigned StrLen, bool InsertAfter = true) { // If insertion succeeded or warning disabled return with no warning. - if (!Rewrite.InsertText(Loc, StrData, StrLen, InsertAfter) || + if (!Rewrite.InsertText(Loc, llvm::StringRef(StrData, StrLen), + InsertAfter) || SilenceRewriteMacroWarning) return; @@ -206,7 +207,8 @@ namespace { void ReplaceText(SourceLocation Start, unsigned OrigLength, const char *NewStr, unsigned NewLength) { // If removal succeeded or warning disabled return with no warning. - if (!Rewrite.ReplaceText(Start, OrigLength, NewStr, NewLength) || + if (!Rewrite.ReplaceText(Start, OrigLength, + llvm::StringRef(NewStr, NewLength)) || SilenceRewriteMacroWarning) return; @@ -1605,8 +1607,7 @@ Stmt *RewriteObjC::RewriteObjCTryStmt(ObjCAtTryStmt *S) { assert((*bodyBuf == '{') && "bogus @catch body location"); buf += "1) { id _tmp = _caught;"; - Rewrite.ReplaceText(startLoc, bodyBuf-startBuf+1, - buf.c_str(), buf.size()); + Rewrite.ReplaceText(startLoc, bodyBuf-startBuf+1, buf); } else if (catchDecl) { QualType t = catchDecl->getType(); if (t == Context->getObjCIdType()) { |