diff options
Diffstat (limited to 'contrib/llvm/tools/clang/lib/Rewrite/Rewriter.cpp')
-rw-r--r-- | contrib/llvm/tools/clang/lib/Rewrite/Rewriter.cpp | 25 |
1 files changed, 10 insertions, 15 deletions
diff --git a/contrib/llvm/tools/clang/lib/Rewrite/Rewriter.cpp b/contrib/llvm/tools/clang/lib/Rewrite/Rewriter.cpp index 92f5160..464b299cc 100644 --- a/contrib/llvm/tools/clang/lib/Rewrite/Rewriter.cpp +++ b/contrib/llvm/tools/clang/lib/Rewrite/Rewriter.cpp @@ -17,10 +17,9 @@ #include "clang/AST/Decl.h" #include "clang/Lex/Lexer.h" #include "clang/Basic/SourceManager.h" -#include "llvm/Support/raw_ostream.h" using namespace clang; -llvm::raw_ostream &RewriteBuffer::write(llvm::raw_ostream &os) const { +raw_ostream &RewriteBuffer::write(raw_ostream &os) const { // FIXME: eliminate the copy by writing out each chunk at a time os << std::string(begin(), end()); return os; @@ -84,7 +83,7 @@ void RewriteBuffer::RemoveText(unsigned OrigOffset, unsigned Size, } } -void RewriteBuffer::InsertText(unsigned OrigOffset, llvm::StringRef Str, +void RewriteBuffer::InsertText(unsigned OrigOffset, StringRef Str, bool InsertAfter) { // Nothing to insert, exit early. @@ -101,7 +100,7 @@ void RewriteBuffer::InsertText(unsigned OrigOffset, llvm::StringRef Str, /// buffer with a new string. This is effectively a combined "remove+insert" /// operation. void RewriteBuffer::ReplaceText(unsigned OrigOffset, unsigned OrigLength, - llvm::StringRef NewStr) { + StringRef NewStr) { unsigned RealOffset = getMappedOffset(OrigOffset, true); Buffer.erase(RealOffset, OrigLength); Buffer.insert(RealOffset, NewStr.begin(), NewStr.end()); @@ -222,7 +221,7 @@ RewriteBuffer &Rewriter::getEditBuffer(FileID FID) { return I->second; I = RewriteBuffers.insert(I, std::make_pair(FID, RewriteBuffer())); - llvm::StringRef MB = SourceMgr->getBufferData(FID); + StringRef MB = SourceMgr->getBufferData(FID); I->second.Initialize(MB.begin(), MB.end()); return I->second; @@ -230,10 +229,8 @@ RewriteBuffer &Rewriter::getEditBuffer(FileID FID) { /// InsertText - Insert the specified string at the specified location in the /// original buffer. -bool Rewriter::InsertText(SourceLocation Loc, llvm::StringRef Str, +bool Rewriter::InsertText(SourceLocation Loc, StringRef Str, bool InsertAfter, bool indentNewLines) { - using llvm::StringRef; - if (!isRewritable(Loc)) return true; FileID FID; unsigned StartOffs = getLocationOffsetAndFileID(Loc, FID); @@ -256,7 +253,7 @@ bool Rewriter::InsertText(SourceLocation Loc, llvm::StringRef Str, indentSpace = MB.substr(lineOffs, i-lineOffs); } - llvm::SmallVector<StringRef, 4> lines; + SmallVector<StringRef, 4> lines; Str.split(lines, "\n"); for (unsigned i = 0, e = lines.size(); i != e; ++i) { @@ -273,7 +270,7 @@ bool Rewriter::InsertText(SourceLocation Loc, llvm::StringRef Str, return false; } -bool Rewriter::InsertTextAfterToken(SourceLocation Loc, llvm::StringRef Str) { +bool Rewriter::InsertTextAfterToken(SourceLocation Loc, StringRef Str) { if (!isRewritable(Loc)) return true; FileID FID; unsigned StartOffs = getLocationOffsetAndFileID(Loc, FID); @@ -298,7 +295,7 @@ bool Rewriter::RemoveText(SourceLocation Start, unsigned Length, /// buffer with a new string. This is effectively a combined "remove/insert" /// operation. bool Rewriter::ReplaceText(SourceLocation Start, unsigned OrigLength, - llvm::StringRef NewStr) { + StringRef NewStr) { if (!isRewritable(Start)) return true; FileID StartFileID; unsigned StartOffs = getLocationOffsetAndFileID(Start, StartFileID); @@ -317,7 +314,7 @@ bool Rewriter::ReplaceText(SourceRange range, SourceRange replacementRange) { FileID FID; unsigned newOffs = getLocationOffsetAndFileID(replacementRange.getBegin(), FID); - llvm::StringRef MB = SourceMgr->getBufferData(FID); + StringRef MB = SourceMgr->getBufferData(FID); return ReplaceText(start, origLength, MB.substr(newOffs, newLength)); } @@ -349,8 +346,6 @@ std::string Rewriter::ConvertToString(Stmt *From) { bool Rewriter::IncreaseIndentation(CharSourceRange range, SourceLocation parentIndent) { - using llvm::StringRef; - if (range.isInvalid()) return true; if (!isRewritable(range.getBegin())) return true; if (!isRewritable(range.getEnd())) return true; @@ -400,7 +395,7 @@ bool Rewriter::IncreaseIndentation(CharSourceRange range, if (!startSpace.startswith(parentSpace)) return true; - llvm::StringRef indent = startSpace.substr(parentSpace.size()); + StringRef indent = startSpace.substr(parentSpace.size()); // Indent the lines between start/end offsets. RewriteBuffer &RB = getEditBuffer(FID); |