diff options
Diffstat (limited to 'lib/Rewrite')
| -rw-r--r-- | lib/Rewrite/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | lib/Rewrite/RewriteRope.cpp | 14 | ||||
| -rw-r--r-- | lib/Rewrite/Rewriter.cpp | 33 |
3 files changed, 6 insertions, 42 deletions
diff --git a/lib/Rewrite/CMakeLists.txt b/lib/Rewrite/CMakeLists.txt index 0c77536012aa..16550b1b710e 100644 --- a/lib/Rewrite/CMakeLists.txt +++ b/lib/Rewrite/CMakeLists.txt @@ -10,7 +10,6 @@ add_clang_library(clangRewrite TokenRewriter.cpp LINK_LIBS - clangAST clangBasic clangLex ) diff --git a/lib/Rewrite/RewriteRope.cpp b/lib/Rewrite/RewriteRope.cpp index ef8abfcadc03..1c82ee4a67ec 100644 --- a/lib/Rewrite/RewriteRope.cpp +++ b/lib/Rewrite/RewriteRope.cpp @@ -788,18 +788,14 @@ RopePiece RewriteRope::MakeRopeString(const char *Start, const char *End) { // Otherwise, this was a small request but we just don't have space for it // Make a new chunk and share it with later allocations. - if (AllocBuffer) - AllocBuffer->dropRef(); - unsigned AllocSize = offsetof(RopeRefCountString, Data) + AllocChunkSize; - AllocBuffer = reinterpret_cast<RopeRefCountString *>(new char[AllocSize]); - AllocBuffer->RefCount = 0; - memcpy(AllocBuffer->Data, Start, Len); + RopeRefCountString *Res = + reinterpret_cast<RopeRefCountString *>(new char[AllocSize]); + Res->RefCount = 0; + memcpy(Res->Data, Start, Len); + AllocBuffer = Res; AllocOffs = Len; - // Start out the new allocation with a refcount of 1, since we have an - // internal reference to it. - AllocBuffer->addRef(); return RopePiece(AllocBuffer, 0, Len); } diff --git a/lib/Rewrite/Rewriter.cpp b/lib/Rewrite/Rewriter.cpp index eab4ccfeadc3..60cdcf703172 100644 --- a/lib/Rewrite/Rewriter.cpp +++ b/lib/Rewrite/Rewriter.cpp @@ -13,9 +13,7 @@ //===----------------------------------------------------------------------===// #include "clang/Rewrite/Core/Rewriter.h" -#include "clang/AST/Decl.h" -#include "clang/AST/PrettyPrinter.h" -#include "clang/AST/Stmt.h" +#include "clang/Basic/Diagnostic.h" #include "clang/Basic/DiagnosticIDs.h" #include "clang/Basic/FileManager.h" #include "clang/Basic/SourceManager.h" @@ -328,35 +326,6 @@ bool Rewriter::ReplaceText(SourceRange range, SourceRange replacementRange) { return ReplaceText(start, origLength, MB.substr(newOffs, newLength)); } -/// ReplaceStmt - This replaces a Stmt/Expr with another, using the pretty -/// printer to generate the replacement code. This returns true if the input -/// could not be rewritten, or false if successful. -bool Rewriter::ReplaceStmt(Stmt *From, Stmt *To) { - assert(From != nullptr && To != nullptr && "Expected non-null Stmt's"); - - // Measaure the old text. - int Size = getRangeSize(From->getSourceRange()); - if (Size == -1) - return true; - - // Get the new text. - std::string SStr; - llvm::raw_string_ostream S(SStr); - To->printPretty(S, nullptr, PrintingPolicy(*LangOpts)); - const std::string &Str = S.str(); - - ReplaceText(From->getLocStart(), Size, Str); - return false; -} - -std::string Rewriter::ConvertToString(Stmt *From) { - assert(From != nullptr && "Expected non-null Stmt"); - std::string SStr; - llvm::raw_string_ostream S(SStr); - From->printPretty(S, nullptr, PrintingPolicy(*LangOpts)); - return S.str(); -} - bool Rewriter::IncreaseIndentation(CharSourceRange range, SourceLocation parentIndent) { if (range.isInvalid()) return true; |
