summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorManuel Klimek <klimek@google.com>2012-05-30 16:04:29 +0000
committerManuel Klimek <klimek@google.com>2012-05-30 16:04:29 +0000
commit8b1c60220dee907fbfe2a73f791b8b047960793f (patch)
tree1caf32ce91f85aedd107097bbc654f441e766053 /clang
parentbb50e7f08cdfc2a5cbbbff17f5290a746d21c65a (diff)
downloadbcm5719-llvm-8b1c60220dee907fbfe2a73f791b8b047960793f.tar.gz
bcm5719-llvm-8b1c60220dee907fbfe2a73f791b8b047960793f.zip
Adds a toString method to Replacement, which helps debugging.
Adds missing header guards to Refactoring.h. llvm-svn: 157694
Diffstat (limited to 'clang')
-rw-r--r--clang/include/clang/Tooling/Refactoring.h9
-rw-r--r--clang/lib/Tooling/Refactoring.cpp8
2 files changed, 17 insertions, 0 deletions
diff --git a/clang/include/clang/Tooling/Refactoring.h b/clang/include/clang/Tooling/Refactoring.h
index 56509a61d59..0e42a0ec64f 100644
--- a/clang/include/clang/Tooling/Refactoring.h
+++ b/clang/include/clang/Tooling/Refactoring.h
@@ -16,6 +16,9 @@
//
//===----------------------------------------------------------------------===//
+#ifndef LLVM_CLANG_TOOLING_REFACTORING_H
+#define LLVM_CLANG_TOOLING_REFACTORING_H
+
#include "llvm/ADT/StringRef.h"
#include "clang/Basic/SourceLocation.h"
#include "clang/Tooling/Tooling.h"
@@ -76,6 +79,9 @@ public:
/// \brief Applies the replacement on the Rewriter.
bool apply(Rewriter &Rewrite) const;
+ /// \brief Returns a human readable string representation.
+ std::string toString() const;
+
/// \brief Comparator to be able to use Replacement in std::set for uniquing.
class Less {
public:
@@ -140,3 +146,6 @@ Replacement::Replacement(SourceManager &Sources, const Node &NodeToReplace,
} // end namespace tooling
} // end namespace clang
+
+#endif // end namespace LLVM_CLANG_TOOLING_REFACTORING_H
+
diff --git a/clang/lib/Tooling/Refactoring.cpp b/clang/lib/Tooling/Refactoring.cpp
index 6e90ba010cb..628435307c0 100644
--- a/clang/lib/Tooling/Refactoring.cpp
+++ b/clang/lib/Tooling/Refactoring.cpp
@@ -71,6 +71,14 @@ bool Replacement::apply(Rewriter &Rewrite) const {
return RewriteSucceeded;
}
+std::string Replacement::toString() const {
+ std::string result;
+ llvm::raw_string_ostream stream(result);
+ stream << FilePath << ": " << Offset << ":+" << Length
+ << ":\"" << ReplacementText << "\"";
+ return result;
+}
+
bool Replacement::Less::operator()(const Replacement &R1,
const Replacement &R2) const {
if (R1.FilePath != R2.FilePath) return R1.FilePath < R2.FilePath;
OpenPOWER on IntegriCloud