kadircet created this revision. kadircet added a reviewer: kbobyrev. Herald added subscribers: usaxena95, arphaman. kadircet requested review of this revision. Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov. Herald added a project: clang.
Explicit specifier can only be mentioned on the in-line declaration of a constructor, so don't carry it over to the definition. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D98164 Files: clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp clang-tools-extra/clangd/unittests/tweaks/DefineOutlineTests.cpp Index: clang-tools-extra/clangd/unittests/tweaks/DefineOutlineTests.cpp =================================================================== --- clang-tools-extra/clangd/unittests/tweaks/DefineOutlineTests.cpp +++ clang-tools-extra/clangd/unittests/tweaks/DefineOutlineTests.cpp @@ -267,6 +267,28 @@ };)cpp", " void A::foo() {}\n", }, + { + R"cpp( + struct Foo { + explicit Fo^o(int) {} + };)cpp", + R"cpp( + struct Foo { + explicit Foo(int) ; + };)cpp", + " Foo::Foo(int) {}\n", + }, + { + R"cpp( + struct Foo { + explicit explicit Fo^o(int) {} + };)cpp", + R"cpp( + struct Foo { + explicit explicit Foo(int) ; + };)cpp", + " Foo::Foo(int) {}\n", + }, }; for (const auto &Case : Cases) { SCOPED_TRACE(Case.Test); Index: clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp =================================================================== --- clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp +++ clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp @@ -272,6 +272,10 @@ if (MD->isStatic()) DelKeyword(tok::kw_static, {FD->getBeginLoc(), FD->getLocation()}); } + if (const auto *CD = dyn_cast<CXXConstructorDecl>(FD)) { + if (CD->isExplicit()) + DelKeyword(tok::kw_explicit, {FD->getBeginLoc(), FD->getLocation()}); + } if (Errors) return std::move(Errors);
Index: clang-tools-extra/clangd/unittests/tweaks/DefineOutlineTests.cpp =================================================================== --- clang-tools-extra/clangd/unittests/tweaks/DefineOutlineTests.cpp +++ clang-tools-extra/clangd/unittests/tweaks/DefineOutlineTests.cpp @@ -267,6 +267,28 @@ };)cpp", " void A::foo() {}\n", }, + { + R"cpp( + struct Foo { + explicit Fo^o(int) {} + };)cpp", + R"cpp( + struct Foo { + explicit Foo(int) ; + };)cpp", + " Foo::Foo(int) {}\n", + }, + { + R"cpp( + struct Foo { + explicit explicit Fo^o(int) {} + };)cpp", + R"cpp( + struct Foo { + explicit explicit Foo(int) ; + };)cpp", + " Foo::Foo(int) {}\n", + }, }; for (const auto &Case : Cases) { SCOPED_TRACE(Case.Test); Index: clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp =================================================================== --- clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp +++ clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp @@ -272,6 +272,10 @@ if (MD->isStatic()) DelKeyword(tok::kw_static, {FD->getBeginLoc(), FD->getLocation()}); } + if (const auto *CD = dyn_cast<CXXConstructorDecl>(FD)) { + if (CD->isExplicit()) + DelKeyword(tok::kw_explicit, {FD->getBeginLoc(), FD->getLocation()}); + } if (Errors) return std::move(Errors);
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits