Skip to content

[Clang-tidy][NFC] Remove dead code detected by code sanitizer. #134385

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 4, 2025

Conversation

zahiraam
Copy link
Contributor

@zahiraam zahiraam commented Apr 4, 2025

The code sanitizer is failing with this error: Execution cannot reach this statement.
The execution code path would early exit at line 928 if (Lil && Ril) = true.

@zahiraam zahiraam changed the title [NFC] Remove dead code detected by code santizer. [NFC] Remove dead code detected by code sanitizer. Apr 4, 2025
@firewave
Copy link

firewave commented Apr 4, 2025

LStrl and RStrl are unused now and can also be dropped.

@zahiraam zahiraam marked this pull request as ready for review April 4, 2025 18:05
@zahiraam zahiraam requested a review from PiotrZSL April 4, 2025 18:05
@llvmbot
Copy link
Member

llvmbot commented Apr 4, 2025

@llvm/pr-subscribers-clang-tidy

@llvm/pr-subscribers-clang-tools-extra

Author: Zahira Ammarguellat (zahiraam)

Changes

The code sanitizer is failing with this error: Execution cannot reach this statement.
The execution code path would early exit at line 928 if (Lil && Ril) = true.


Full diff: https://github.com/llvm/llvm-project/pull/134385.diff

1 Files Affected:

  • (modified) clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp (-12)
diff --git a/clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp b/clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp
index c249244b1a1b2..8e5a528bc5d3e 100644
--- a/clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp
+++ b/clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp
@@ -927,18 +927,6 @@ static bool areExprsSameMacroOrLiteral(const BinaryOperator *BinOp,
   if (Lil && Ril)
     return Lil->getValue() == Ril->getValue();
 
-  const auto *LStrl = dyn_cast<StringLiteral>(Lhs);
-  const auto *RStrl = dyn_cast<StringLiteral>(Rhs);
-  if (Lil && Ril) {
-    const llvm::StringRef L = Lexer::getSourceText(
-        CharSourceRange::getTokenRange(LStrl->getBeginLoc()), SM,
-        Context->getLangOpts(), 0);
-    const llvm::StringRef R = Lexer::getSourceText(
-        CharSourceRange::getTokenRange(RStrl->getBeginLoc()), SM,
-        Context->getLangOpts(), 0);
-    return L.compare(R) == 0;
-  }
-
   const auto *Lbl = dyn_cast<CXXBoolLiteralExpr>(Lhs);
   const auto *Rbl = dyn_cast<CXXBoolLiteralExpr>(Rhs);
   if (Lbl && Rbl)

Copy link
Contributor

@carlosgalvezp carlosgalvezp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice finding!

Nit: next time, please add [clang-tidy] to the beginning of the commit message, so it's easier to see which part of the repo is affected.

@zahiraam zahiraam changed the title [NFC] Remove dead code detected by code sanitizer. [Clang-tidy][NFC] Remove dead code detected by code sanitizer. Apr 4, 2025
@zahiraam zahiraam merged commit ebb0e6c into llvm:main Apr 4, 2025
15 checks passed
@firewave
Copy link

firewave commented Apr 4, 2025

Based on the message it seems the "sanitizer" was Coverity. Is my assumption correct?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants