https://github.com/HerrCai0907 updated 
https://github.com/llvm/llvm-project/pull/78022

>From 0988bb25a35e5d50b44bf53d459098777280c3e5 Mon Sep 17 00:00:00 2001
From: Congcong Cai <congcongcai0...@163.com>
Date: Sat, 13 Jan 2024 16:00:16 +0800
Subject: [PATCH 1/3] [clang-tidy]Add new check
 readability-avoid-nested-conditional-operator Finds nested conditional
 operator. Nested conditional operators lead code hard to understand, so they
 should be splited as several statement and stored in temporary varibale.

---
 .../AvoidNestedConditionalOperatorCheck.cpp   | 56 +++++++++++++++++++
 .../AvoidNestedConditionalOperatorCheck.h     | 33 +++++++++++
 .../clang-tidy/readability/CMakeLists.txt     |  1 +
 .../readability/ReadabilityTidyModule.cpp     |  3 +
 clang-tools-extra/docs/ReleaseNotes.rst       |  5 ++
 .../docs/clang-tidy/checks/list.rst           |  1 +
 .../avoid-nested-conditional-operator.rst     | 20 +++++++
 .../avoid-nested-conditional-operator.cpp     | 23 ++++++++
 8 files changed, 142 insertions(+)
 create mode 100644 
clang-tools-extra/clang-tidy/readability/AvoidNestedConditionalOperatorCheck.cpp
 create mode 100644 
clang-tools-extra/clang-tidy/readability/AvoidNestedConditionalOperatorCheck.h
 create mode 100644 
clang-tools-extra/docs/clang-tidy/checks/readability/avoid-nested-conditional-operator.rst
 create mode 100644 
clang-tools-extra/test/clang-tidy/checkers/readability/avoid-nested-conditional-operator.cpp

diff --git 
a/clang-tools-extra/clang-tidy/readability/AvoidNestedConditionalOperatorCheck.cpp
 
b/clang-tools-extra/clang-tidy/readability/AvoidNestedConditionalOperatorCheck.cpp
new file mode 100644
index 00000000000000..a0278c3ae32fa7
--- /dev/null
+++ 
b/clang-tools-extra/clang-tidy/readability/AvoidNestedConditionalOperatorCheck.cpp
@@ -0,0 +1,56 @@
+//===--- AvoidNestedConditionalOperatorCheck.cpp - clang-tidy ----------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "AvoidNestedConditionalOperatorCheck.h"
+#include "clang/AST/Expr.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Basic/DiagnosticIDs.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang::tidy::readability {
+
+namespace {
+constexpr const char *Description = "don't use nested conditional operator";
+constexpr const char *OutSideConditionalOperatorNote =
+    "outside conditional operator here";
+} // namespace
+
+void AvoidNestedConditionalOperatorCheck::registerMatchers(
+    MatchFinder *Finder) {
+  Finder->addMatcher(
+      conditionalOperator(
+          anyOf(
+              hasCondition(ignoringParenCasts(
+                  conditionalOperator().bind("nested-conditional-operator"))),
+              hasTrueExpression(ignoringParenCasts(
+                  conditionalOperator().bind("nested-conditional-operator"))),
+              hasFalseExpression(ignoringParenCasts(
+                  conditionalOperator().bind("nested-conditional-operator")))))
+          .bind("conditional-operator"),
+      this);
+}
+
+void AvoidNestedConditionalOperatorCheck::check(
+    const MatchFinder::MatchResult &Result) {
+  const auto *CO =
+      Result.Nodes.getNodeAs<ConditionalOperator>("conditional-operator");
+  const auto *NCO = Result.Nodes.getNodeAs<ConditionalOperator>(
+      "nested-conditional-operator");
+  assert(CO);
+  assert(NCO);
+
+  if (CO->getBeginLoc().isMacroID() || NCO->getBeginLoc().isMacroID())
+    return;
+
+  diag(NCO->getBeginLoc(), Description);
+  diag(CO->getBeginLoc(), OutSideConditionalOperatorNote, DiagnosticIDs::Note);
+}
+
+} // namespace clang::tidy::readability
diff --git 
a/clang-tools-extra/clang-tidy/readability/AvoidNestedConditionalOperatorCheck.h
 
b/clang-tools-extra/clang-tidy/readability/AvoidNestedConditionalOperatorCheck.h
new file mode 100644
index 00000000000000..2f82ea86cd849d
--- /dev/null
+++ 
b/clang-tools-extra/clang-tidy/readability/AvoidNestedConditionalOperatorCheck.h
@@ -0,0 +1,33 @@
+//===--- AvoidNestedConditionalOperatorCheck.h - clang-tidy --*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef 
LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_AVOIDNestedConditionalOperatorCHECK_H
+#define 
LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_AVOIDNestedConditionalOperatorCHECK_H
+
+#include "../ClangTidyCheck.h"
+
+namespace clang::tidy::readability {
+
+/// Finds nested conditional operator.
+///
+/// For the user-facing documentation see:
+/// 
http://clang.llvm.org/extra/clang-tidy/checks/readability/avoid-nested-conditional-operator.html
+class AvoidNestedConditionalOperatorCheck : public ClangTidyCheck {
+public:
+  AvoidNestedConditionalOperatorCheck(StringRef Name, ClangTidyContext 
*Context)
+      : ClangTidyCheck(Name, Context) {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+  std::optional<TraversalKind> getCheckTraversalKind() const override {
+    return TK_IgnoreUnlessSpelledInSource;
+  }
+};
+
+} // namespace clang::tidy::readability
+
+#endif // 
LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_AVOIDNestedConditionalOperatorCHECK_H
diff --git a/clang-tools-extra/clang-tidy/readability/CMakeLists.txt 
b/clang-tools-extra/clang-tidy/readability/CMakeLists.txt
index 408c822b861c5f..fa571d5dd7650d 100644
--- a/clang-tools-extra/clang-tidy/readability/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/readability/CMakeLists.txt
@@ -5,6 +5,7 @@ set(LLVM_LINK_COMPONENTS
 
 add_clang_library(clangTidyReadabilityModule
   AvoidConstParamsInDecls.cpp
+  AvoidNestedConditionalOperatorCheck.cpp
   AvoidReturnWithVoidValueCheck.cpp
   AvoidUnconditionalPreprocessorIfCheck.cpp
   BracesAroundStatementsCheck.cpp
diff --git a/clang-tools-extra/clang-tidy/readability/ReadabilityTidyModule.cpp 
b/clang-tools-extra/clang-tidy/readability/ReadabilityTidyModule.cpp
index 0b0aad7c0dcb36..f769752c5de5fa 100644
--- a/clang-tools-extra/clang-tidy/readability/ReadabilityTidyModule.cpp
+++ b/clang-tools-extra/clang-tidy/readability/ReadabilityTidyModule.cpp
@@ -10,6 +10,7 @@
 #include "../ClangTidyModule.h"
 #include "../ClangTidyModuleRegistry.h"
 #include "AvoidConstParamsInDecls.h"
+#include "AvoidNestedConditionalOperatorCheck.h"
 #include "AvoidReturnWithVoidValueCheck.h"
 #include "AvoidUnconditionalPreprocessorIfCheck.h"
 #include "BracesAroundStatementsCheck.h"
@@ -64,6 +65,8 @@ class ReadabilityModule : public ClangTidyModule {
   void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
     CheckFactories.registerCheck<AvoidConstParamsInDecls>(
         "readability-avoid-const-params-in-decls");
+    CheckFactories.registerCheck<AvoidNestedConditionalOperatorCheck>(
+        "readability-avoid-nested-conditional-operator");
     CheckFactories.registerCheck<AvoidReturnWithVoidValueCheck>(
         "readability-avoid-return-with-void-value");
     CheckFactories.registerCheck<AvoidUnconditionalPreprocessorIfCheck>(
diff --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index 3437b6cf9b59e9..7ed4bcf1ff92ac 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -224,6 +224,11 @@ New checks
   Recommends the smallest possible underlying type for an ``enum`` or ``enum``
   class based on the range of its enumerators.
 
+- New :doc:`readability-avoid-nested-conditional-operator
+  <clang-tidy/checks/readability/avoid-nested-conditional-operator>` check.
+
+  Finds nested conditional operator.
+
 - New :doc:`readability-reference-to-constructed-temporary
   <clang-tidy/checks/readability/reference-to-constructed-temporary>` check.
 
diff --git a/clang-tools-extra/docs/clang-tidy/checks/list.rst 
b/clang-tools-extra/docs/clang-tidy/checks/list.rst
index 2f86121ad87299..fd65bdc1e43f8d 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -337,6 +337,7 @@ Clang-Tidy Checks
    :doc:`portability-simd-intrinsics <portability/simd-intrinsics>`,
    :doc:`portability-std-allocator-const <portability/std-allocator-const>`,
    :doc:`readability-avoid-const-params-in-decls 
<readability/avoid-const-params-in-decls>`, "Yes"
+   :doc:`readability-avoid-nested-conditional-operator 
<readability/avoid-nested-conditional-operator>`, "Yes"
    :doc:`readability-avoid-return-with-void-value 
<readability/avoid-return-with-void-value>`,
    :doc:`readability-avoid-unconditional-preprocessor-if 
<readability/avoid-unconditional-preprocessor-if>`,
    :doc:`readability-braces-around-statements 
<readability/braces-around-statements>`, "Yes"
diff --git 
a/clang-tools-extra/docs/clang-tidy/checks/readability/avoid-nested-conditional-operator.rst
 
b/clang-tools-extra/docs/clang-tidy/checks/readability/avoid-nested-conditional-operator.rst
new file mode 100644
index 00000000000000..db4ce7de87a9e7
--- /dev/null
+++ 
b/clang-tools-extra/docs/clang-tidy/checks/readability/avoid-nested-conditional-operator.rst
@@ -0,0 +1,20 @@
+.. title:: clang-tidy - readability-avoid-nested-conditional-operator
+
+readability-avoid-nested-conditional-operator
+=================================================
+
+Finds nested conditional operator.
+
+Nested conditional operators lead code hard to understand, so they should be
+splited as several statement and stored in temporary varibale.
+
+Examples:
+
+.. code-block:: c++
+
+  int NestInConditional = (condition1 ? true1 : false1) ? true2 : false2;
+  int NestInTrue = condition1 ? (condition2 ? true1 : false1) : false2;
+  int NestInFalse = condition1 ? true1 : condition2 ? true2 : false1;
+
+This check implements part of `AUTOSAR C++14 Rule A5-16-1
+<https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Rc-constref>`_.
diff --git 
a/clang-tools-extra/test/clang-tidy/checkers/readability/avoid-nested-conditional-operator.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/readability/avoid-nested-conditional-operator.cpp
new file mode 100644
index 00000000000000..fd2d592544ddd0
--- /dev/null
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/readability/avoid-nested-conditional-operator.cpp
@@ -0,0 +1,23 @@
+// RUN: %check_clang_tidy %s readability-avoid-nested-conditional-operator %t
+
+int NestInConditional = (true ? true : false) ? 1 : 2;
+// CHECK-MESSAGES: :[[@LINE-1]]:26: warning: don't use nested conditional 
operator
+// CHECK-MESSAGES: :[[@LINE-2]]:25: note: outside conditional operator here
+
+int NestInTrue = true ? (true ? 1 : 2) : 2;
+// CHECK-MESSAGES: :[[@LINE-1]]:26: warning: don't use nested conditional 
operator
+// CHECK-MESSAGES: :[[@LINE-2]]:18: note: outside conditional operator here
+
+int NestInFalse = true ? 1 : true ? 1 : 2;
+// CHECK-MESSAGES: :[[@LINE-1]]:30: warning: don't use nested conditional 
operator
+// CHECK-MESSAGES: :[[@LINE-2]]:19: note: outside conditional operator here
+int NestInFalse2 = true ? 1 : (true ? 1 : 2);
+// CHECK-MESSAGES: :[[@LINE-1]]:32: warning: don't use nested conditional 
operator
+// CHECK-MESSAGES: :[[@LINE-2]]:20: note: outside conditional operator here
+
+int NestWithParensis = true ? 1 : ((((true ? 1 : 2))));
+// CHECK-MESSAGES: :[[@LINE-1]]:39: warning: don't use nested conditional 
operator
+// CHECK-MESSAGES: :[[@LINE-2]]:24: note: outside conditional operator here
+
+#define CONDITIONAL_EXPR (true ? 1 : 2)
+int NestWithMacro = true ? CONDITIONAL_EXPR : 2;

>From f9736f2aa55860fe33c2155264289e6ba405e89a Mon Sep 17 00:00:00 2001
From: Congcong Cai <congcongcai0...@163.com>
Date: Mon, 15 Jan 2024 09:38:21 +0800
Subject: [PATCH 2/3] fix comments

---
 .../AvoidNestedConditionalOperatorCheck.cpp   | 14 +++++--------
 .../AvoidNestedConditionalOperatorCheck.h     | 10 ++++-----
 .../docs/clang-tidy/checks/list.rst           |  2 +-
 .../avoid-nested-conditional-operator.rst     | 11 +++++-----
 .../avoid-nested-conditional-operator.cpp     | 21 ++++++++++---------
 5 files changed, 28 insertions(+), 30 deletions(-)

diff --git 
a/clang-tools-extra/clang-tidy/readability/AvoidNestedConditionalOperatorCheck.cpp
 
b/clang-tools-extra/clang-tidy/readability/AvoidNestedConditionalOperatorCheck.cpp
index a0278c3ae32fa7..2ea03c9070526f 100644
--- 
a/clang-tools-extra/clang-tidy/readability/AvoidNestedConditionalOperatorCheck.cpp
+++ 
b/clang-tools-extra/clang-tidy/readability/AvoidNestedConditionalOperatorCheck.cpp
@@ -7,7 +7,6 @@
 
//===----------------------------------------------------------------------===//
 
 #include "AvoidNestedConditionalOperatorCheck.h"
-#include "clang/AST/Expr.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/ASTMatchers/ASTMatchers.h"
 #include "clang/Basic/DiagnosticIDs.h"
@@ -16,12 +15,6 @@ using namespace clang::ast_matchers;
 
 namespace clang::tidy::readability {
 
-namespace {
-constexpr const char *Description = "don't use nested conditional operator";
-constexpr const char *OutSideConditionalOperatorNote =
-    "outside conditional operator here";
-} // namespace
-
 void AvoidNestedConditionalOperatorCheck::registerMatchers(
     MatchFinder *Finder) {
   Finder->addMatcher(
@@ -49,8 +42,11 @@ void AvoidNestedConditionalOperatorCheck::check(
   if (CO->getBeginLoc().isMacroID() || NCO->getBeginLoc().isMacroID())
     return;
 
-  diag(NCO->getBeginLoc(), Description);
-  diag(CO->getBeginLoc(), OutSideConditionalOperatorNote, DiagnosticIDs::Note);
+  diag(NCO->getBeginLoc(),
+       "conditional operator is used as sub-expression of parent conditional "
+       "operator, refrain from using nested conditional operators");
+  diag(CO->getBeginLoc(), "parent conditional operator here",
+       DiagnosticIDs::Note);
 }
 
 } // namespace clang::tidy::readability
diff --git 
a/clang-tools-extra/clang-tidy/readability/AvoidNestedConditionalOperatorCheck.h
 
b/clang-tools-extra/clang-tidy/readability/AvoidNestedConditionalOperatorCheck.h
index 2f82ea86cd849d..9010156de6ce2d 100644
--- 
a/clang-tools-extra/clang-tidy/readability/AvoidNestedConditionalOperatorCheck.h
+++ 
b/clang-tools-extra/clang-tidy/readability/AvoidNestedConditionalOperatorCheck.h
@@ -1,4 +1,4 @@
-//===--- AvoidNestedConditionalOperatorCheck.h - clang-tidy --*- C++ -*-===//
+//===--- AvoidNestedConditionalOperatorCheck.h - clang-tidy -----*- C++ 
-*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -6,14 +6,14 @@
 //
 
//===----------------------------------------------------------------------===//
 
-#ifndef 
LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_AVOIDNestedConditionalOperatorCHECK_H
-#define 
LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_AVOIDNestedConditionalOperatorCHECK_H
+#ifndef 
LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_AVOID_NESTED_CONDITIONAL_OPERATOR_CHECK_H
+#define 
LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_AVOID_NESTED_CONDITIONAL_OPERATOR_CHECK_H
 
 #include "../ClangTidyCheck.h"
 
 namespace clang::tidy::readability {
 
-/// Finds nested conditional operator.
+/// Identifies instances of nested conditional operators in the code.
 ///
 /// For the user-facing documentation see:
 /// 
http://clang.llvm.org/extra/clang-tidy/checks/readability/avoid-nested-conditional-operator.html
@@ -30,4 +30,4 @@ class AvoidNestedConditionalOperatorCheck : public 
ClangTidyCheck {
 
 } // namespace clang::tidy::readability
 
-#endif // 
LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_AVOIDNestedConditionalOperatorCHECK_H
+#endif // 
LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_AVOID_NESTED_CONDITIONAL_OPERATOR_CHECK_H
diff --git a/clang-tools-extra/docs/clang-tidy/checks/list.rst 
b/clang-tools-extra/docs/clang-tidy/checks/list.rst
index fd65bdc1e43f8d..5f21449cfc3df4 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -337,7 +337,7 @@ Clang-Tidy Checks
    :doc:`portability-simd-intrinsics <portability/simd-intrinsics>`,
    :doc:`portability-std-allocator-const <portability/std-allocator-const>`,
    :doc:`readability-avoid-const-params-in-decls 
<readability/avoid-const-params-in-decls>`, "Yes"
-   :doc:`readability-avoid-nested-conditional-operator 
<readability/avoid-nested-conditional-operator>`, "Yes"
+   :doc:`readability-avoid-nested-conditional-operator 
<readability/avoid-nested-conditional-operator>`,
    :doc:`readability-avoid-return-with-void-value 
<readability/avoid-return-with-void-value>`,
    :doc:`readability-avoid-unconditional-preprocessor-if 
<readability/avoid-unconditional-preprocessor-if>`,
    :doc:`readability-braces-around-statements 
<readability/braces-around-statements>`, "Yes"
diff --git 
a/clang-tools-extra/docs/clang-tidy/checks/readability/avoid-nested-conditional-operator.rst
 
b/clang-tools-extra/docs/clang-tidy/checks/readability/avoid-nested-conditional-operator.rst
index db4ce7de87a9e7..44b74283292ce0 100644
--- 
a/clang-tools-extra/docs/clang-tidy/checks/readability/avoid-nested-conditional-operator.rst
+++ 
b/clang-tools-extra/docs/clang-tidy/checks/readability/avoid-nested-conditional-operator.rst
@@ -1,12 +1,13 @@
 .. title:: clang-tidy - readability-avoid-nested-conditional-operator
 
 readability-avoid-nested-conditional-operator
-=================================================
+=============================================
 
-Finds nested conditional operator.
+Identifies instances of nested conditional operators in the code.
 
-Nested conditional operators lead code hard to understand, so they should be
-splited as several statement and stored in temporary varibale.
+Nested conditional operators, also known as ternary operators, can contribute
+to reduced code readability and comprehension. So they should be split as
+several statements and stored the intermediate results in temporary variable.
 
 Examples:
 
@@ -17,4 +18,4 @@ Examples:
   int NestInFalse = condition1 ? true1 : condition2 ? true2 : false1;
 
 This check implements part of `AUTOSAR C++14 Rule A5-16-1
-<https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Rc-constref>`_.
+<https://www.autosar.org/fileadmin/standards/R22-11/AP/AUTOSAR_RS_CPP14Guidelines.pdf>`_.
diff --git 
a/clang-tools-extra/test/clang-tidy/checkers/readability/avoid-nested-conditional-operator.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/readability/avoid-nested-conditional-operator.cpp
index fd2d592544ddd0..847df08199e349 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/readability/avoid-nested-conditional-operator.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/readability/avoid-nested-conditional-operator.cpp
@@ -1,23 +1,24 @@
 // RUN: %check_clang_tidy %s readability-avoid-nested-conditional-operator %t
 
 int NestInConditional = (true ? true : false) ? 1 : 2;
-// CHECK-MESSAGES: :[[@LINE-1]]:26: warning: don't use nested conditional 
operator
-// CHECK-MESSAGES: :[[@LINE-2]]:25: note: outside conditional operator here
+// CHECK-MESSAGES: :[[@LINE-1]]:26: warning: conditional operator is used as 
sub-expression of parent conditional operator, refrain from using nested 
conditional operators
+// CHECK-MESSAGES: :[[@LINE-2]]:25: note: parent conditional operator here
 
 int NestInTrue = true ? (true ? 1 : 2) : 2;
-// CHECK-MESSAGES: :[[@LINE-1]]:26: warning: don't use nested conditional 
operator
-// CHECK-MESSAGES: :[[@LINE-2]]:18: note: outside conditional operator here
+// CHECK-MESSAGES: :[[@LINE-1]]:26: warning: conditional operator is used as 
sub-expression of parent conditional operator, refrain from using nested 
conditional operators
+// CHECK-MESSAGES: :[[@LINE-2]]:18: note: parent conditional operator here
 
 int NestInFalse = true ? 1 : true ? 1 : 2;
-// CHECK-MESSAGES: :[[@LINE-1]]:30: warning: don't use nested conditional 
operator
-// CHECK-MESSAGES: :[[@LINE-2]]:19: note: outside conditional operator here
+// CHECK-MESSAGES: :[[@LINE-1]]:30: warning: conditional operator is used as 
sub-expression of parent conditional operator, refrain from using nested 
conditional operators
+// CHECK-MESSAGES: :[[@LINE-2]]:19: note: parent conditional operator here
 int NestInFalse2 = true ? 1 : (true ? 1 : 2);
-// CHECK-MESSAGES: :[[@LINE-1]]:32: warning: don't use nested conditional 
operator
-// CHECK-MESSAGES: :[[@LINE-2]]:20: note: outside conditional operator here
+// CHECK-MESSAGES: :[[@LINE-1]]:32: warning: conditional operator is used as 
sub-expression of parent conditional operator, refrain from using nested 
conditional operators
+// CHECK-MESSAGES: :[[@LINE-2]]:20: note: parent conditional operator here
 
 int NestWithParensis = true ? 1 : ((((true ? 1 : 2))));
-// CHECK-MESSAGES: :[[@LINE-1]]:39: warning: don't use nested conditional 
operator
-// CHECK-MESSAGES: :[[@LINE-2]]:24: note: outside conditional operator here
+// CHECK-MESSAGES: :[[@LINE-1]]:39: warning: conditional operator is used as 
sub-expression of parent conditional operator, refrain from using nested 
conditional operators
+// CHECK-MESSAGES: :[[@LINE-2]]:24: note: parent conditional operator here
 
 #define CONDITIONAL_EXPR (true ? 1 : 2)
+// not diag for macro since it will not reduce readability
 int NestWithMacro = true ? CONDITIONAL_EXPR : 2;

>From 9a831c9e1b3d4c64b26a568af88c4d06aa058ae3 Mon Sep 17 00:00:00 2001
From: Congcong Cai <congcongcai0...@163.com>
Date: Mon, 15 Jan 2024 18:11:32 +0800
Subject: [PATCH 3/3] update release note

---
 clang-tools-extra/docs/ReleaseNotes.rst | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index 925a36118aac76..a235a7d02592e8 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -227,7 +227,7 @@ New checks
 - New :doc:`readability-avoid-nested-conditional-operator
   <clang-tidy/checks/readability/avoid-nested-conditional-operator>` check.
 
-  Finds nested conditional operator.
+  Identifies instances of nested conditional operators in the code.
 
 - New :doc:`readability-avoid-return-with-void-value
   <clang-tidy/checks/readability/avoid-return-with-void-value>` check.

_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to