ishaangandhi updated this revision to Diff 439501.
ishaangandhi marked an inline comment as done.
ishaangandhi added a comment.

Change doc path


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D128402/new/

https://reviews.llvm.org/D128402

Files:
  clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/test/clang-tidy/checkers/bugprone/branch-clone-unknown-expr.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone/branch-clone-unknown-expr.cpp
===================================================================
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone/branch-clone-unknown-expr.cpp
@@ -0,0 +1,9 @@
+// RUN: %check_clang_tidy -fix-errors %s bugprone-branch-clone %t
+
+int test_unknown_expression() {
+  if (unknown_expression_1) {        // CHECK-MESSAGES: :[[@LINE]]:7: error: use of undeclared identifier 'unknown_expression_1' [clang-diagnostic-error]
+    function1(unknown_expression_2); // CHECK-MESSAGES: :[[@LINE]]:15: error: use of undeclared identifier 'unknown_expression_2' [clang-diagnostic-error]
+  } else {
+    function2(unknown_expression_3); // CHECK-MESSAGES: :[[@LINE]]:15: error: use of undeclared identifier 'unknown_expression_3' [clang-diagnostic-error]
+  }
+}
Index: clang-tools-extra/docs/ReleaseNotes.rst
===================================================================
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -150,24 +150,29 @@
 Changes in existing checks
 ^^^^^^^^^^^^^^^^^^^^^^^^^^
 
-- Fixed nonsensical suggestion of :doc:`altera-struct-pack-align
-  <clang-tidy/checks/altera/struct-pack-align>` check for empty structs.
-
-- Fixed some false positives in :doc:`bugprone-infinite-loop
-  <clang-tidy/checks/bugprone/infinite-loop>` involving dependent expressions.
+- Expanded :doc:`readability-simplify-boolean-expr
+  <clang-tidy/checks/readability/simplify-boolean-expr>` to simplify expressions
+  using DeMorgan's Theorem.
 
 - Fixed a crash in :doc:`bugprone-sizeof-expression
   <clang-tidy/checks/bugprone/sizeof-expression>` when `sizeof(...)` is
   compared against a `__int128_t`.
 
-- Made :doc:`cert-oop57-cpp <clang-tidy/checks/cert/oop57-cpp>` more sensitive
-  by checking for an arbitrary expression in the second argument of ``memset``.
+- Fixed a crash in :doc:`llvmlibc-callee-namespace
+  <clang-tidy/checks/llvmlibc/callee-namespace>` when executing for C++ code
+  that contain calls to advanced constructs, e.g. overloaded operators.
 
-- Improved :doc:`cppcoreguidelines-prefer-member-initializer
-  <clang-tidy/checks/cppcoreguidelines/prefer-member-initializer>` check.
+- Fixed a crash in :doc:`performance-unnecessary-value-param
+  <clang-tidy/checks/readability/suspicious-call-argument>` when the specialization
+  template has an unnecessary value parameter. Removed the fix for a template.
 
-  Fixed an issue when there was already an initializer in the constructor and
-  the check would try to create another initializer for the same member.
+- Fixed a crash in :doc:`readability-const-return-type
+  <clang-tidy/checks/readability/const-return-type>` when a pure virtual function
+  overrided has a const return type. Removed the fix for a virtual function.
+
+- Fixed a false positive in :doc:`bugprone-branch-clone
+  <clang-tidy/checks/bugprone/branch-clone>` when the branches
+  involve unknown expressions.
 
 - Fixed a false positive in :doc:`cppcoreguidelines-virtual-class-destructor
   <clang-tidy/checks/cppcoreguidelines/virtual-class-destructor>` involving
@@ -175,18 +180,6 @@
   those cannot be used as base classes, consequently, they can not violate the
   rule.
 
-- Fixed a crash in :doc:`llvmlibc-callee-namespace
-  <clang-tidy/checks/llvmlibc/callee-namespace>` when executing for C++ code
-  that contain calls to advanced constructs, e.g. overloaded operators.
-
-- Fixed false positives in :doc:`misc-redundant-expression
-  <clang-tidy/checks/misc/redundant-expression>`:
-
-  - Fixed a false positive involving overloaded comparison operators.
-
-  - Fixed a false positive involving assignments in
-    conditions. This fixes `Issue 35853 <https://github.com/llvm/llvm-project/issues/35853>`_.
-
 - Fixed a false positive in :doc:`misc-unused-parameters
   <clang-tidy/checks/misc/unused-parameters>`
   where invalid parameters were implicitly being treated as being unused. 
@@ -201,28 +194,12 @@
   the ``CheckHeaderFile=true`` option if header files of the project only
   included by C++ source files.
 
-- Improved :doc:`performance-inefficient-vector-operation
-  <clang-tidy/checks/performance/inefficient-vector-operation>` to work when
-  the vector is a member of a structure.
-
-- Fixed a crash in :doc:`readability-const-return-type
-  <clang-tidy/checks/readability/const-return-type>` when a pure virtual function
-  overrided has a const return type. Removed the fix for a virtual function.
-
-- Fixed incorrect suggestions for :doc:`readability-container-size-empty
-  <clang-tidy/checks/readability/container-size-empty>` when smart pointers are involved.
-
 - Fixed a false positive in :doc:`readability-non-const-parameter
   <clang-tidy/checks/readability/non-const-parameter>` when the parameter is
   referenced by an lvalue.
 
-- Expanded :doc:`readability-simplify-boolean-expr
-  <clang-tidy/checks/readability/simplify-boolean-expr>` to simplify expressions
-  using DeMorgan's Theorem.
-
-- Fixed a crash in :doc:`performance-unnecessary-value-param
-  <clang-tidy/checks/readability/suspicious-call-argument>` when the specialization
-  template has an unnecessary value parameter. Removed the fix for a template.
+- Fixed an issue when there was already an initializer in the constructor and
+  the check would try to create another initializer for the same member.
 
 - Fixed bugs in :doc:`bugprone-use-after-move
   <clang-tidy/checks/bugprone/use-after-move>`:
@@ -233,6 +210,33 @@
 
   - Don't emit an erroneous warning on self-moves.
 
+- Fixed false positives in :doc:`misc-redundant-expression
+  <clang-tidy/checks/misc/redundant-expression>`:
+
+  - Fixed a false positive involving overloaded comparison operators.
+
+  - Fixed a false positive involving assignments in
+    conditions. This fixes `Issue 35853 <https://github.com/llvm/llvm-project/issues/35853>`_.
+
+- Fixed incorrect suggestions for :doc:`readability-container-size-empty
+  <clang-tidy/checks/readability/container-size-empty>` when smart pointers are involved.
+
+- Fixed nonsensical suggestion of :doc:`altera-struct-pack-align
+  <clang-tidy/checks/altera/struct-pack-align>` check for empty structs.
+
+- Fixed some false positives in :doc:`bugprone-infinite-loop
+  <clang-tidy/checks/bugprone/infinite-loop>` involving dependent expressions.
+
+- Improved :doc:`cppcoreguidelines-prefer-member-initializer
+  <clang-tidy/checks/cppcoreguidelines/prefer-member-initializer>` check.
+
+- Improved :doc:`performance-inefficient-vector-operation
+  <clang-tidy/checks/performance/inefficient-vector-operation>` to work when
+  the vector is a member of a structure.
+
+- Made :doc:`cert-oop57-cpp <clang-tidy/checks/cert/oop57-cpp>` more sensitive
+  by checking for an arbitrary expression in the second argument of ``memset``.
+
 Removed checks
 ^^^^^^^^^^^^^^
 
Index: clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp
===================================================================
--- clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp
@@ -19,6 +19,17 @@
 /// Returns true when the statements are Type I clones of each other.
 static bool areStatementsIdentical(const Stmt *LHS, const Stmt *RHS,
                                    const ASTContext &Context) {
+  if (isa<Expr>(LHS) && isa<Expr>(RHS)) {
+    // If we have errors in expressions, we will be unable
+    // to accurately profile and compute hashes for each
+    // of the left and right statements.
+    const auto *LHSExpr = llvm::cast<Expr>(LHS);
+    const auto *RHSExpr = llvm::cast<Expr>(RHS);
+    if (LHSExpr->containsErrors() && RHSExpr->containsErrors()) {
+      return false;
+    }
+  }
+
   llvm::FoldingSetNodeID DataLHS, DataRHS;
   LHS->Profile(DataLHS, Context, false);
   RHS->Profile(DataRHS, Context, false);
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to