summaryrefslogtreecommitdiff
path: root/unittests
diff options
context:
space:
mode:
authorYitzhak Mandelbaum <yitzhakm@google.com>2019-10-16 01:06:46 +0000
committerYitzhak Mandelbaum <yitzhakm@google.com>2019-10-16 01:06:46 +0000
commita5f406013645696985998bdaf1d4d85c95a280dd (patch)
tree8813073d88f7d063adf1fdbdcf0e073e7ed664c3 /unittests
parented4dbd72ed336ea1b7ae8a2165bc0f7b3eccb31c (diff)
downloadclang-a5f406013645696985998bdaf1d4d85c95a280dd.tar.gz
[libTooling] Put all Transformer declarations in a single namespace.
Summary: This revision introduces a new namespace, `clang::transformer`, to hold the declarations for the Transformer library. Reviewers: gribozavr Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D68876 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@374962 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests')
-rw-r--r--unittests/Tooling/RangeSelectorTest.cpp8
-rw-r--r--unittests/Tooling/StencilTest.cpp13
-rw-r--r--unittests/Tooling/TransformerTest.cpp11
3 files changed, 12 insertions, 20 deletions
diff --git a/unittests/Tooling/RangeSelectorTest.cpp b/unittests/Tooling/RangeSelectorTest.cpp
index 29a20a9f18..8a7d555e61 100644
--- a/unittests/Tooling/RangeSelectorTest.cpp
+++ b/unittests/Tooling/RangeSelectorTest.cpp
@@ -9,15 +9,15 @@
#include "clang/Tooling/Transformer/RangeSelector.h"
#include "clang/ASTMatchers/ASTMatchers.h"
#include "clang/Frontend/ASTUnit.h"
-#include "clang/Tooling/FixIt.h"
#include "clang/Tooling/Tooling.h"
+#include "clang/Tooling/Transformer/SourceCode.h"
#include "llvm/Support/Error.h"
#include "llvm/Testing/Support/Error.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
using namespace clang;
-using namespace tooling;
+using namespace transformer;
using namespace ast_matchers;
namespace {
@@ -40,7 +40,7 @@ struct TestMatch {
};
template <typename M> TestMatch matchCode(StringRef Code, M Matcher) {
- auto ASTUnit = buildASTFromCode(Code);
+ auto ASTUnit = tooling::buildASTFromCode(Code);
assert(ASTUnit != nullptr && "AST construction failed");
ASTContext &Context = ASTUnit->getASTContext();
@@ -59,7 +59,7 @@ Expected<StringRef> select(RangeSelector Selector, const TestMatch &Match) {
Expected<CharSourceRange> Range = Selector(Match.Result);
if (!Range)
return Range.takeError();
- return fixit::internal::getText(*Range, *Match.Result.Context);
+ return tooling::getText(*Range, *Match.Result.Context);
}
// Applies \p Selector to a trivial match with only a single bound node with id
diff --git a/unittests/Tooling/StencilTest.cpp b/unittests/Tooling/StencilTest.cpp
index c524441beb..c62eae79d2 100644
--- a/unittests/Tooling/StencilTest.cpp
+++ b/unittests/Tooling/StencilTest.cpp
@@ -16,7 +16,7 @@
#include "gtest/gtest.h"
using namespace clang;
-using namespace tooling;
+using namespace transformer;
using namespace ast_matchers;
namespace {
@@ -27,15 +27,6 @@ using ::testing::AllOf;
using ::testing::Eq;
using ::testing::HasSubstr;
using MatchResult = MatchFinder::MatchResult;
-using stencil::access;
-using stencil::addressOf;
-using stencil::cat;
-using stencil::deref;
-using stencil::dPrint;
-using stencil::expression;
-using stencil::ifBound;
-using stencil::run;
-using stencil::text;
// Create a valid translation-unit from a statement.
static std::string wrapSnippet(StringRef StatementCode) {
@@ -64,7 +55,7 @@ struct TestMatch {
// `StatementCode` may contain other statements not described by `Matcher`.
static llvm::Optional<TestMatch> matchStmt(StringRef StatementCode,
StatementMatcher Matcher) {
- auto AstUnit = buildASTFromCode(wrapSnippet(StatementCode));
+ auto AstUnit = tooling::buildASTFromCode(wrapSnippet(StatementCode));
if (AstUnit == nullptr) {
ADD_FAILURE() << "AST construction failed";
return llvm::None;
diff --git a/unittests/Tooling/TransformerTest.cpp b/unittests/Tooling/TransformerTest.cpp
index feae0c649a..c42976a71c 100644
--- a/unittests/Tooling/TransformerTest.cpp
+++ b/unittests/Tooling/TransformerTest.cpp
@@ -18,9 +18,10 @@
using namespace clang;
using namespace tooling;
using namespace ast_matchers;
-
namespace {
using ::testing::IsEmpty;
+using transformer::RewriteRule;
+using transformer::text;
constexpr char KHeaderContents[] = R"cc(
struct string {
@@ -208,7 +209,7 @@ TEST_F(TransformerTest, AddIncludeQuoted) {
TEST_F(TransformerTest, AddIncludeAngled) {
RewriteRule Rule = makeRule(callExpr(callee(functionDecl(hasName("f")))),
change(text("other()")));
- addInclude(Rule, "clang/OtherLib.h", IncludeFormat::Angled);
+ addInclude(Rule, "clang/OtherLib.h", transformer::IncludeFormat::Angled);
std::string Input = R"cc(
int f(int x);
@@ -559,7 +560,7 @@ TEST_F(TransformerTest, OrderedRuleMultipleKinds) {
change(name("fun"), text("DECL_RULE")));
RewriteRule Rule = applyFirst({ReplaceF1, DeclRule, ReplaceF1OrF2});
- EXPECT_EQ(tooling::detail::buildMatchers(Rule).size(), 2UL);
+ EXPECT_EQ(transformer::detail::buildMatchers(Rule).size(), 2UL);
testRule(Rule, Input, Expected);
}
@@ -795,11 +796,11 @@ TEST_F(TransformerTest, NoPartialRewriteOfMacroExpansionForMacroArgs) {
// rules.
TEST(TransformerDeathTest, OrderedRuleTypes) {
RewriteRule QualTypeRule = makeRule(qualType(), change(text("Q")));
- EXPECT_DEATH(tooling::detail::buildMatchers(QualTypeRule),
+ EXPECT_DEATH(transformer::detail::buildMatchers(QualTypeRule),
"Matcher must be.*node matcher");
RewriteRule TypeRule = makeRule(arrayType(), change(text("T")));
- EXPECT_DEATH(tooling::detail::buildMatchers(TypeRule),
+ EXPECT_DEATH(transformer::detail::buildMatchers(TypeRule),
"Matcher must be.*node matcher");
}
#endif