================
@@ -2371,6 +2371,24 @@ NonOdrUseReason 
Sema::getNonOdrUseReasonInCurrentContext(ValueDecl *D) {
   return NOUR_None;
 }
 
+bool Sema::isConditionVarReference(const DeclRefExpr *DRE) {
+  if (!DRE)
+    return false;
+
+  const VarDecl *VD = dyn_cast<VarDecl>(DRE->getDecl());
+
+  if (!VD)
+    return false;
+
+  for (Scope *S = getCurScope(); S; S = S->getParent()) {
+    if (VarDecl *CV = S->getConditionVar())
+      if (VD == CV)
----------------
arrowten wrote:

```
  if (bool x = get_something()) {}
  else {
    {   
      bool x = get_something_else();
      if (x) {} //throws warning here
    }   
  }
  ```
It is throwing here since it compares the local `x` to the `if` condition `x` 
and since both have the same type, it eventually throws a warning.

https://github.com/llvm/llvm-project/pull/156436
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to