summaryrefslogtreecommitdiff
path: root/unittests/Tooling/RefactoringTest.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2015-06-09 19:08:19 +0000
committerDimitry Andric <dim@FreeBSD.org>2015-06-09 19:08:19 +0000
commit798321d8eb5630cd4a8f490a4f25e32ef195fb07 (patch)
treea59f5569ef36d00388c0428426abef26aa9105b6 /unittests/Tooling/RefactoringTest.cpp
parent5e20cdd81c44a443562a09007668ffdf76c455af (diff)
Diffstat (limited to 'unittests/Tooling/RefactoringTest.cpp')
-rw-r--r--unittests/Tooling/RefactoringTest.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/unittests/Tooling/RefactoringTest.cpp b/unittests/Tooling/RefactoringTest.cpp
index 7e643fa66d9b..6c2c16b484d7 100644
--- a/unittests/Tooling/RefactoringTest.cpp
+++ b/unittests/Tooling/RefactoringTest.cpp
@@ -281,6 +281,7 @@ public:
protected:
clang::SourceManager *SM;
+ clang::ASTContext *Context;
private:
class FindConsumer : public clang::ASTConsumer {
@@ -303,6 +304,7 @@ private:
CreateASTConsumer(clang::CompilerInstance &compiler,
llvm::StringRef dummy) override {
Visitor->SM = &compiler.getSourceManager();
+ Visitor->Context = &compiler.getASTContext();
/// TestConsumer will be deleted by the framework calling us.
return llvm::make_unique<FindConsumer>(Visitor);
}
@@ -368,6 +370,29 @@ TEST(Replacement, TemplatedFunctionCall) {
expectReplacementAt(CallToF.Replace, "input.cc", 43, 8);
}
+class NestedNameSpecifierAVisitor
+ : public TestVisitor<NestedNameSpecifierAVisitor> {
+public:
+ bool TraverseNestedNameSpecifierLoc(NestedNameSpecifierLoc NNSLoc) {
+ if (NNSLoc.getNestedNameSpecifier()) {
+ if (const NamespaceDecl* NS = NNSLoc.getNestedNameSpecifier()->getAsNamespace()) {
+ if (NS->getName() == "a") {
+ Replace = Replacement(*SM, &NNSLoc, "", Context->getLangOpts());
+ }
+ }
+ }
+ return TestVisitor<NestedNameSpecifierAVisitor>::TraverseNestedNameSpecifierLoc(
+ NNSLoc);
+ }
+ Replacement Replace;
+};
+
+TEST(Replacement, ColonColon) {
+ NestedNameSpecifierAVisitor VisitNNSA;
+ EXPECT_TRUE(VisitNNSA.runOver("namespace a { void f() { ::a::f(); } }"));
+ expectReplacementAt(VisitNNSA.Replace, "input.cc", 25, 5);
+}
+
TEST(Range, overlaps) {
EXPECT_TRUE(Range(10, 10).overlapsWith(Range(0, 11)));
EXPECT_TRUE(Range(0, 11).overlapsWith(Range(10, 10)));