summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2012-07-17 08:37:03 +0000
committerDaniel Jasper <djasper@google.com>2012-07-17 08:37:03 +0000
commit6389dd145d63a8c45ef3e4a939ffdad2db621a63 (patch)
tree09586ec20ef9d02a139a4fe7f96bd917e9d3fad6
parent780f9b5f927f84d2191c9aa162194319e57fae86 (diff)
downloadbcm5719-llvm-6389dd145d63a8c45ef3e4a939ffdad2db621a63.tar.gz
bcm5719-llvm-6389dd145d63a8c45ef3e4a939ffdad2db621a63.zip
Finishing the move of RefactoringCallbacks and fixing the corresponding
buildbot failures. llvm-svn: 160355
-rw-r--r--clang/include/clang/Tooling/RefactoringCallbacks.h16
-rw-r--r--clang/lib/Tooling/RefactoringCallbacks.cpp25
-rw-r--r--clang/unittests/Tooling/RefactoringCallbacksTest.cpp4
3 files changed, 25 insertions, 20 deletions
diff --git a/clang/include/clang/Tooling/RefactoringCallbacks.h b/clang/include/clang/Tooling/RefactoringCallbacks.h
index 762e57e27b8..c500f356a4d 100644
--- a/clang/include/clang/Tooling/RefactoringCallbacks.h
+++ b/clang/include/clang/Tooling/RefactoringCallbacks.h
@@ -33,18 +33,18 @@
#include "clang/Tooling/Refactoring.h"
namespace clang {
-namespace ast_matchers {
+namespace tooling {
/// \brief Base class for RefactoringCallbacks.
///
/// Collects \c tooling::Replacements while running.
-class RefactoringCallback : public MatchFinder::MatchCallback {
+class RefactoringCallback : public ast_matchers::MatchFinder::MatchCallback {
public:
RefactoringCallback();
- tooling::Replacements &getReplacements();
+ Replacements &getReplacements();
protected:
- tooling::Replacements Replace;
+ Replacements Replace;
};
/// \brief Replace the text of the statement bound to \c FromId with the text in
@@ -52,7 +52,7 @@ protected:
class ReplaceStmtWithText : public RefactoringCallback {
public:
ReplaceStmtWithText(StringRef FromId, StringRef ToText);
- virtual void run(const MatchFinder::MatchResult &Result);
+ virtual void run(const ast_matchers::MatchFinder::MatchResult &Result);
private:
std::string FromId;
@@ -64,7 +64,7 @@ private:
class ReplaceStmtWithStmt : public RefactoringCallback {
public:
ReplaceStmtWithStmt(StringRef FromId, StringRef ToId);
- virtual void run(const MatchFinder::MatchResult &Result);
+ virtual void run(const ast_matchers::MatchFinder::MatchResult &Result);
private:
std::string FromId;
@@ -77,14 +77,14 @@ private:
class ReplaceIfStmtWithItsBody : public RefactoringCallback {
public:
ReplaceIfStmtWithItsBody(StringRef Id, bool PickTrueBranch);
- virtual void run(const MatchFinder::MatchResult &Result);
+ virtual void run(const ast_matchers::MatchFinder::MatchResult &Result);
private:
std::string Id;
const bool PickTrueBranch;
};
-} // end namespace ast_matchers
+} // end namespace tooling
} // end namespace clang
#endif // LLVM_CLANG_TOOLING_REFACTORING_CALLBACKS_H
diff --git a/clang/lib/Tooling/RefactoringCallbacks.cpp b/clang/lib/Tooling/RefactoringCallbacks.cpp
index 2584747d6df..4de125ec02a 100644
--- a/clang/lib/Tooling/RefactoringCallbacks.cpp
+++ b/clang/lib/Tooling/RefactoringCallbacks.cpp
@@ -13,22 +13,22 @@
#include "clang/Tooling/RefactoringCallbacks.h"
namespace clang {
-namespace ast_matchers {
+namespace tooling {
RefactoringCallback::RefactoringCallback() {}
tooling::Replacements &RefactoringCallback::getReplacements() {
return Replace;
}
-static tooling::Replacement replaceStmtWithText(SourceManager &Sources,
- const Stmt &From,
- StringRef Text) {
+static Replacement replaceStmtWithText(SourceManager &Sources,
+ const Stmt &From,
+ StringRef Text) {
return tooling::Replacement(Sources, CharSourceRange::getTokenRange(
From.getSourceRange()), Text);
}
-static tooling::Replacement replaceStmtWithStmt(SourceManager &Sources,
- const Stmt &From,
- const Stmt &To) {
+static Replacement replaceStmtWithStmt(SourceManager &Sources,
+ const Stmt &From,
+ const Stmt &To) {
return replaceStmtWithText(Sources, From, Lexer::getSourceText(
CharSourceRange::getTokenRange(To.getSourceRange()),
Sources, LangOptions()));
@@ -37,7 +37,8 @@ static tooling::Replacement replaceStmtWithStmt(SourceManager &Sources,
ReplaceStmtWithText::ReplaceStmtWithText(StringRef FromId, StringRef ToText)
: FromId(FromId), ToText(ToText) {}
-void ReplaceStmtWithText::run(const MatchFinder::MatchResult &Result) {
+void ReplaceStmtWithText::run(
+ const ast_matchers::MatchFinder::MatchResult &Result) {
if (const Stmt *FromMatch = Result.Nodes.getStmtAs<Stmt>(FromId)) {
Replace.insert(tooling::Replacement(
*Result.SourceManager,
@@ -49,7 +50,8 @@ void ReplaceStmtWithText::run(const MatchFinder::MatchResult &Result) {
ReplaceStmtWithStmt::ReplaceStmtWithStmt(StringRef FromId, StringRef ToId)
: FromId(FromId), ToId(ToId) {}
-void ReplaceStmtWithStmt::run(const MatchFinder::MatchResult &Result) {
+void ReplaceStmtWithStmt::run(
+ const ast_matchers::MatchFinder::MatchResult &Result) {
const Stmt *FromMatch = Result.Nodes.getStmtAs<Stmt>(FromId);
const Stmt *ToMatch = Result.Nodes.getStmtAs<Stmt>(ToId);
if (FromMatch && ToMatch)
@@ -61,7 +63,8 @@ ReplaceIfStmtWithItsBody::ReplaceIfStmtWithItsBody(StringRef Id,
bool PickTrueBranch)
: Id(Id), PickTrueBranch(PickTrueBranch) {}
-void ReplaceIfStmtWithItsBody::run(const MatchFinder::MatchResult &Result) {
+void ReplaceIfStmtWithItsBody::run(
+ const ast_matchers::MatchFinder::MatchResult &Result) {
if (const IfStmt *Node = Result.Nodes.getStmtAs<IfStmt>(Id)) {
const Stmt *Body = PickTrueBranch ? Node->getThen() : Node->getElse();
if (Body) {
@@ -74,5 +77,5 @@ void ReplaceIfStmtWithItsBody::run(const MatchFinder::MatchResult &Result) {
}
}
-} // end namespace ast_matchers
+} // end namespace tooling
} // end namespace clang
diff --git a/clang/unittests/Tooling/RefactoringCallbacksTest.cpp b/clang/unittests/Tooling/RefactoringCallbacksTest.cpp
index 90d9377ccd6..00eb193d74c 100644
--- a/clang/unittests/Tooling/RefactoringCallbacksTest.cpp
+++ b/clang/unittests/Tooling/RefactoringCallbacksTest.cpp
@@ -14,7 +14,9 @@
#include "RewriterTestContext.h"
namespace clang {
-namespace ast_matchers {
+namespace tooling {
+
+using namespace ast_matchers;
template <typename T>
void expectRewritten(const std::string &Code,
OpenPOWER on IntegriCloud