[clang-tools-extra] 26f230f - [clang-tidy][NFC] Fix llvm-else-after-return findings

Piotr Zegar via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 30 10:42:06 PDT 2023


Author: Piotr Zegar
Date: 2023-08-30T17:41:41Z
New Revision: 26f230fe5214614b912b6e1800e1526d625181ac

URL: https://github.com/llvm/llvm-project/commit/26f230fe5214614b912b6e1800e1526d625181ac
DIFF: https://github.com/llvm/llvm-project/commit/26f230fe5214614b912b6e1800e1526d625181ac.diff

LOG: [clang-tidy][NFC] Fix llvm-else-after-return findings

Fix issues found by clang-tidy in clang-tidy source directory.

Added: 
    

Modified: 
    clang-tools-extra/clang-tidy/google/AvoidCStyleCastsCheck.cpp
    clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp

Removed: 
    


################################################################################
diff  --git a/clang-tools-extra/clang-tidy/google/AvoidCStyleCastsCheck.cpp b/clang-tools-extra/clang-tidy/google/AvoidCStyleCastsCheck.cpp
index 8c62fef6f3f3f9..714ac0ee54dafb 100644
--- a/clang-tools-extra/clang-tidy/google/AvoidCStyleCastsCheck.cpp
+++ b/clang-tools-extra/clang-tidy/google/AvoidCStyleCastsCheck.cpp
@@ -58,16 +58,14 @@ static bool pointedUnqualifiedTypesAreEqual(QualType T1, QualType T2) {
 }
 
 static clang::CharSourceRange getReplaceRange(const ExplicitCastExpr *Expr) {
-  if (const auto *CastExpr = dyn_cast<CStyleCastExpr>(Expr)) {
+  if (const auto *CastExpr = dyn_cast<CStyleCastExpr>(Expr))
     return CharSourceRange::getCharRange(
         CastExpr->getLParenLoc(),
         CastExpr->getSubExprAsWritten()->getBeginLoc());
-  }
-  if (const auto *CastExpr = dyn_cast<CXXFunctionalCastExpr>(Expr)) {
+  if (const auto *CastExpr = dyn_cast<CXXFunctionalCastExpr>(Expr))
     return CharSourceRange::getCharRange(CastExpr->getBeginLoc(),
                                          CastExpr->getLParenLoc());
-  } else
-    llvm_unreachable("Unsupported CastExpr");
+  llvm_unreachable("Unsupported CastExpr");
 }
 
 static StringRef getDestTypeString(const SourceManager &SM,

diff  --git a/clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp b/clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
index a37551b42a0e0e..f90d99a8d66069 100644
--- a/clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
@@ -375,8 +375,8 @@ static std::optional<ContainerCall> getContainerExpr(const Expr *Call) {
     return ContainerCall{TheCall->getArg(0),
                          TheCall->getDirectCallee()->getName(), false,
                          CallKind};
-
-  } else if (const auto *TheCall = dyn_cast_or_null<CallExpr>(Dug)) {
+  }
+  if (const auto *TheCall = dyn_cast_or_null<CallExpr>(Dug)) {
     if (TheCall->getNumArgs() != 1)
       return std::nullopt;
 


        


More information about the cfe-commits mailing list