[PATCH] D98164: [clangd] Drop explicit specifier on define out-of-line
Kadir Cetinkaya via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Mar 8 00:01:54 PST 2021
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);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D98164.328941.patch
Type: text/x-patch
Size: 1574 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210308/31715e41/attachment.bin>
More information about the cfe-commits
mailing list