mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-11-28 16:11:29 +00:00
[change-namespace] do not change type locs in defaulted functions.
Reviewers: hokein Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D38893 llvm-svn: 315892
This commit is contained in:
parent
776bf1de01
commit
b583a7ead4
@ -427,7 +427,8 @@ void ChangeNamespaceTool::registerMatchers(ast_matchers::MatchFinder *Finder) {
|
||||
unless(templateSpecializationType())))))),
|
||||
hasParent(nestedNameSpecifierLoc()),
|
||||
hasAncestor(isImplicit()),
|
||||
hasAncestor(UsingShadowDeclInClass))),
|
||||
hasAncestor(UsingShadowDeclInClass),
|
||||
hasAncestor(functionDecl(isDefaulted())))),
|
||||
hasAncestor(decl().bind("dc")))
|
||||
.bind("type"),
|
||||
this);
|
||||
@ -451,6 +452,7 @@ void ChangeNamespaceTool::registerMatchers(ast_matchers::MatchFinder *Finder) {
|
||||
specifiesType(hasDeclaration(DeclMatcher.bind("from_decl"))))),
|
||||
unless(anyOf(hasAncestor(isImplicit()),
|
||||
hasAncestor(UsingShadowDeclInClass),
|
||||
hasAncestor(functionDecl(isDefaulted())),
|
||||
hasAncestor(typeLoc(loc(qualType(hasDeclaration(
|
||||
decl(equalsBoundNode("from_decl"))))))))))
|
||||
.bind("nested_specifier_loc"),
|
||||
|
@ -2093,6 +2093,68 @@ TEST_F(ChangeNamespaceTest, TypeAsTemplateParameter) {
|
||||
EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
|
||||
}
|
||||
|
||||
TEST_F(ChangeNamespaceTest, DefaultMoveConstructors) {
|
||||
std::string Code = "namespace na {\n"
|
||||
"class B {\n"
|
||||
" public:\n"
|
||||
" B() = default;\n"
|
||||
" // Allow move only.\n"
|
||||
" B(B&&) = default;\n"
|
||||
" B& operator=(B&&) = default;\n"
|
||||
" B(const B&) = delete;\n"
|
||||
" B& operator=(const B&) = delete;\n"
|
||||
" private:\n"
|
||||
" int ref_;\n"
|
||||
"};\n"
|
||||
"} // namespace na\n"
|
||||
"namespace na {\n"
|
||||
"namespace nb {\n"
|
||||
"class A {\n"
|
||||
"public:\n"
|
||||
" A() = default;\n"
|
||||
" A(A&&) = default;\n"
|
||||
" A& operator=(A&&) = default;\n"
|
||||
"private:\n"
|
||||
" B b;\n"
|
||||
" A(const A&) = delete;\n"
|
||||
" A& operator=(const A&) = delete;\n"
|
||||
"};\n"
|
||||
"void f() { A a; a = A(); A aa = A(); }\n"
|
||||
"} // namespace nb\n"
|
||||
"} // namespace na\n";
|
||||
std::string Expected = "namespace na {\n"
|
||||
"class B {\n"
|
||||
" public:\n"
|
||||
" B() = default;\n"
|
||||
" // Allow move only.\n"
|
||||
" B(B&&) = default;\n"
|
||||
" B& operator=(B&&) = default;\n"
|
||||
" B(const B&) = delete;\n"
|
||||
" B& operator=(const B&) = delete;\n"
|
||||
" private:\n"
|
||||
" int ref_;\n"
|
||||
"};\n"
|
||||
"} // namespace na\n"
|
||||
"\n"
|
||||
"namespace x {\n"
|
||||
"namespace y {\n"
|
||||
"class A {\n"
|
||||
"public:\n"
|
||||
" A() = default;\n"
|
||||
" A(A&&) = default;\n"
|
||||
" A& operator=(A&&) = default;\n"
|
||||
"private:\n"
|
||||
" na::B b;\n"
|
||||
" A(const A&) = delete;\n"
|
||||
" A& operator=(const A&) = delete;\n"
|
||||
"};\n"
|
||||
"void f() { A a; a = A(); A aa = A(); }\n"
|
||||
"} // namespace y\n"
|
||||
"} // namespace x\n";
|
||||
EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
|
||||
}
|
||||
|
||||
|
||||
} // anonymous namespace
|
||||
} // namespace change_namespace
|
||||
} // namespace clang
|
||||
|
Loading…
Reference in New Issue
Block a user