[PATCH] D128402: [clang-tidy] Don't treat invalid branches as identical
    Nathan James via Phabricator via cfe-commits 
    cfe-commits at lists.llvm.org
       
    Wed Jun 22 22:36:24 PDT 2022
    
    
  
njames93 added inline comments.
================
Comment at: clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp:26
+    // of the left and right statements.
+    const Expr *LHSExpr = llvm::dyn_cast<Expr>(LHS);
+    const Expr *RHSExpr = llvm::dyn_cast<Expr>(RHS);
----------------
Eugene.Zelenko wrote:
> `auto` could be used because type is spelled in same statement.
No need for `dyn_cast` here, we already know it's an `Expr` so `cast` would be sufficient.
================
Comment at: clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp:28
+    const Expr *RHSExpr = llvm::dyn_cast<Expr>(RHS);
+    if (LHSExpr->containsErrors() && RHSExpr->containsErrors()) {
+      return false;
----------------
Surely we can bail if only one of the sides contains an errors.
Repository:
  rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D128402/new/
https://reviews.llvm.org/D128402
    
    
More information about the cfe-commits
mailing list