summaryrefslogtreecommitdiffstats
path: root/clang/lib/Frontend/RewriteObjC.cpp
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-08-19 19:10:30 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-08-19 19:10:30 +0000
commitdec484abfba2def91d49b8f7d0a832244a419aef (patch)
tree37d929b784968983568ee352149a6bcadd5b059e /clang/lib/Frontend/RewriteObjC.cpp
parent6c528bc7ae6b8cf7c3e0ff351fb56f357b6c9745 (diff)
downloadbcm5719-llvm-dec484abfba2def91d49b8f7d0a832244a419aef.tar.gz
bcm5719-llvm-dec484abfba2def91d49b8f7d0a832244a419aef.zip
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. llvm-svn: 79448
Diffstat (limited to 'clang/lib/Frontend/RewriteObjC.cpp')
-rw-r--r--clang/lib/Frontend/RewriteObjC.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/clang/lib/Frontend/RewriteObjC.cpp b/clang/lib/Frontend/RewriteObjC.cpp
index 72982d2309c..b3de53671b7 100644
--- a/clang/lib/Frontend/RewriteObjC.cpp
+++ b/clang/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()) {
OpenPOWER on IntegriCloud