[clang-tools-extra] b1a5df1 - [clangd] Drop explicit specifier on define out-of-line
Kadir Cetinkaya via cfe-commits
cfe-commits at lists.llvm.org
Thu Mar 11 04:29:00 PST 2021
Author: Kadir Cetinkaya
Date: 2021-03-11T13:27:24+01:00
New Revision: b1a5df174e1d5a58f2498c30795cf18c9bf3e1b1
URL: https://github.com/llvm/llvm-project/commit/b1a5df174e1d5a58f2498c30795cf18c9bf3e1b1
DIFF: https://github.com/llvm/llvm-project/commit/b1a5df174e1d5a58f2498c30795cf18c9bf3e1b1.diff
LOG: [clangd] Drop explicit specifier on define out-of-line
Explicit specifier can only be mentioned on the in-line declaration of a
constructor, so don't carry it over to the definition.
Differential Revision: https://reviews.llvm.org/D98164
Added:
Modified:
clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
clang-tools-extra/clangd/unittests/tweaks/DefineOutlineTests.cpp
Removed:
################################################################################
diff --git a/clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp b/clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
index 4cdd36cbd4c9..18c521119972 100644
--- a/clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
+++ b/clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
@@ -272,6 +272,10 @@ getFunctionSourceCode(const FunctionDecl *FD, llvm::StringRef TargetNamespace,
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);
diff --git a/clang-tools-extra/clangd/unittests/tweaks/DefineOutlineTests.cpp b/clang-tools-extra/clangd/unittests/tweaks/DefineOutlineTests.cpp
index fa627282e193..a872341a871a 100644
--- a/clang-tools-extra/clangd/unittests/tweaks/DefineOutlineTests.cpp
+++ b/clang-tools-extra/clangd/unittests/tweaks/DefineOutlineTests.cpp
@@ -267,6 +267,28 @@ TEST_F(DefineOutlineTest, ApplyTest) {
};)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);
More information about the cfe-commits
mailing list