[clang-tools-extra] c2bee1e - [clang-tidy][NFC] Unwind if-else-if-... in UnusedUsingDeclsCheck
Piotr Zegar via cfe-commits
cfe-commits at lists.llvm.org
Sun Sep 3 00:14:53 PDT 2023
Author: Piotr Zegar
Date: 2023-09-03T06:24:56Z
New Revision: c2bee1ed26a3355d164c92f1eb70ebf88804560d
URL: https://github.com/llvm/llvm-project/commit/c2bee1ed26a3355d164c92f1eb70ebf88804560d
DIFF: https://github.com/llvm/llvm-project/commit/c2bee1ed26a3355d164c92f1eb70ebf88804560d.diff
LOG: [clang-tidy][NFC] Unwind if-else-if-... in UnusedUsingDeclsCheck
Break a if-else-if-else... chain. Use early return instead.
Fixes: #46375
Added:
Modified:
clang-tools-extra/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
Removed:
################################################################################
diff --git a/clang-tools-extra/clang-tidy/misc/UnusedUsingDeclsCheck.cpp b/clang-tools-extra/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
index 8aadb8fcb13441..c0255ea11e5ca6 100644
--- a/clang-tools-extra/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
+++ b/clang-tools-extra/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
@@ -126,10 +126,14 @@ void UnusedUsingDeclsCheck::check(const MatchFinder::MatchResult &Result) {
// Also remove variants of Used.
if (const auto *FD = dyn_cast<FunctionDecl>(Used)) {
removeFromFoundDecls(FD->getPrimaryTemplate());
- } else if (const auto *Specialization =
- dyn_cast<ClassTemplateSpecializationDecl>(Used)) {
+ return;
+ }
+ if (const auto *Specialization =
+ dyn_cast<ClassTemplateSpecializationDecl>(Used)) {
removeFromFoundDecls(Specialization->getSpecializedTemplate());
- } else if (const auto *ECD = dyn_cast<EnumConstantDecl>(Used)) {
+ return;
+ }
+ if (const auto *ECD = dyn_cast<EnumConstantDecl>(Used)) {
if (const auto *ET = ECD->getType()->getAs<EnumType>())
removeFromFoundDecls(ET->getDecl());
}
@@ -151,10 +155,16 @@ void UnusedUsingDeclsCheck::check(const MatchFinder::MatchResult &Result) {
if (Used->getKind() == TemplateArgument::Template) {
if (const auto *TD = Used->getAsTemplate().getAsTemplateDecl())
removeFromFoundDecls(TD);
- } else if (Used->getKind() == TemplateArgument::Type) {
+ return;
+ }
+
+ if (Used->getKind() == TemplateArgument::Type) {
if (auto *RD = Used->getAsType()->getAsCXXRecordDecl())
removeFromFoundDecls(RD);
- } else if (Used->getKind() == TemplateArgument::Declaration) {
+ return;
+ }
+
+ if (Used->getKind() == TemplateArgument::Declaration) {
RemoveNamedDecl(Used->getAsDecl());
}
return;
More information about the cfe-commits
mailing list