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/RewriteMacros.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/RewriteMacros.cpp')
-rw-r--r-- | lib/Frontend/RewriteMacros.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/Frontend/RewriteMacros.cpp b/lib/Frontend/RewriteMacros.cpp index 5ef4892e5b..1a477be4b5 100644 --- a/lib/Frontend/RewriteMacros.cpp +++ b/lib/Frontend/RewriteMacros.cpp @@ -129,13 +129,13 @@ void clang::RewriteMacrosInInput(Preprocessor &PP, llvm::raw_ostream *OS) { const IdentifierInfo *II = RawTokens[CurRawTok].getIdentifierInfo(); if (!strcmp(II->getName(), "warning")) { // Comment out #warning. - RB.InsertTextAfter(SM.getFileOffset(RawTok.getLocation()), "//", 2); + RB.InsertTextAfter(SM.getFileOffset(RawTok.getLocation()), "//"); } else if (!strcmp(II->getName(), "pragma") && RawTokens[CurRawTok+1].is(tok::identifier) && !strcmp(RawTokens[CurRawTok+1].getIdentifierInfo()->getName(), "mark")){ // Comment out #pragma mark. - RB.InsertTextAfter(SM.getFileOffset(RawTok.getLocation()), "//", 2); + RB.InsertTextAfter(SM.getFileOffset(RawTok.getLocation()), "//"); } } @@ -165,7 +165,7 @@ void clang::RewriteMacrosInInput(Preprocessor &PP, llvm::raw_ostream *OS) { // Comment out a whole run of tokens instead of bracketing each one with // comments. Add a leading space if RawTok didn't have one. bool HasSpace = RawTok.hasLeadingSpace(); - RB.InsertTextAfter(RawOffs, " /*"+HasSpace, 2+!HasSpace); + RB.InsertTextAfter(RawOffs, " /*"+HasSpace); unsigned EndPos; do { @@ -183,7 +183,7 @@ void clang::RewriteMacrosInInput(Preprocessor &PP, llvm::raw_ostream *OS) { } while (RawOffs <= PPOffs && !RawTok.isAtStartOfLine() && (PPOffs != RawOffs || !isSameToken(RawTok, PPTok))); - RB.InsertTextBefore(EndPos, "*/", 2); + RB.InsertTextBefore(EndPos, "*/"); continue; } @@ -199,7 +199,7 @@ void clang::RewriteMacrosInInput(Preprocessor &PP, llvm::raw_ostream *OS) { PPOffs = SM.getFileOffset(PPLoc); } Expansion += ' '; - RB.InsertTextBefore(InsertPos, &Expansion[0], Expansion.size()); + RB.InsertTextBefore(InsertPos, Expansion); } // Get the buffer corresponding to MainFileID. If we haven't changed it, then |