================
@@ -492,4 +492,42 @@ namespace virtual_function {
     auto* baz = &*obj;
     // expected-warning@-1{{Local variable 'baz' is uncounted and unsafe 
[alpha.webkit.UncountedLocalVarsChecker]}}
   }
-}
\ No newline at end of file
+}
+
+namespace vardecl_in_if_condition {
+  RefCountable* provide();
+
+  RefCountable* get() {
+    if (auto* obj = provide())
+      return obj; // no warning
+    return nullptr;
+  }
+
+  RefCountable* get_non_trivial_then() {
+    if (auto* obj = provide()) // expected-warning{{Local variable 'obj' is 
uncounted and unsafe [alpha.webkit.UncountedLocalVarsChecker]}}
+      return obj->next();
+    return nullptr;
+  }
+
+  RefCountable* get_non_trivial_else() {
+    if (auto* obj = provide())
+      return obj;
+    else
+      return provide()->next();
+    return nullptr;
+  }
----------------
rniwa wrote:

I think in that scenario, `getConditionVariable()` returns `nullptr`. 
Basically, `getConditionVariable()` will only return the variable declaration 
in the form of: `if (auto var = ~)`. Whenever there is a condition defined with 
`;`, it returns `nullptr` as far as I could tell.

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

Reply via email to