summaryrefslogtreecommitdiffstats
path: root/contrib/llvm/tools/clang/lib/Rewrite
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/llvm/tools/clang/lib/Rewrite')
-rw-r--r--contrib/llvm/tools/clang/lib/Rewrite/RewriteRope.cpp14
-rw-r--r--contrib/llvm/tools/clang/lib/Rewrite/Rewriter.cpp33
2 files changed, 6 insertions, 41 deletions
diff --git a/contrib/llvm/tools/clang/lib/Rewrite/RewriteRope.cpp b/contrib/llvm/tools/clang/lib/Rewrite/RewriteRope.cpp
index ef8abfc..1c82ee4 100644
--- a/contrib/llvm/tools/clang/lib/Rewrite/RewriteRope.cpp
+++ b/contrib/llvm/tools/clang/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/contrib/llvm/tools/clang/lib/Rewrite/Rewriter.cpp b/contrib/llvm/tools/clang/lib/Rewrite/Rewriter.cpp
index eab4ccf..60cdcf7 100644
--- a/contrib/llvm/tools/clang/lib/Rewrite/Rewriter.cpp
+++ b/contrib/llvm/tools/clang/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;
OpenPOWER on IntegriCloud