[PATCH] D104381: [analyzer] Added a test case for PR46264

Denys Petrov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 16 06:47:59 PDT 2021


ASDenysPetrov created this revision.
ASDenysPetrov added reviewers: NoQ, steakhal.
ASDenysPetrov added a project: clang.
Herald added subscribers: manas, dkrupp, donat.nagy, Szelethus, mikhail.ramalho, a.sidorin, szepet, baloghadamsoftware, xazax.hun.
ASDenysPetrov requested review of this revision.
Herald added a subscriber: cfe-commits.

It's not able to reproduce the issue (https://bugs.llvm.org/show_bug.cgi?id=46264) for the latest sources. Add a reported test case to try to catch the problem if occures.

Prevent: https://bugs.llvm.org/show_bug.cgi?id=46264


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D104381

Files:
  clang/test/Analysis/diagnostics/PR46264.cpp


Index: clang/test/Analysis/diagnostics/PR46264.cpp
===================================================================
--- /dev/null
+++ clang/test/Analysis/diagnostics/PR46264.cpp
@@ -0,0 +1,34 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-output=text -verify %s
+
+// PR46264
+// This case shall not warn about dereference of void*
+namespace ns1 {
+namespace a {
+class b {
+public:
+  typedef int b::*c;
+  operator c() { return d ? &b::d : 0; }
+  // expected-note at -1{{'?' condition is true}}
+  // expected-note at -2{{Assuming field 'd' is not equal to 0}}
+  // expected-note at -3{{Returning value, which participates in a condition later}}
+  int d;
+};
+} // namespace a
+using a::b;
+class e {
+  void f();
+  void g();
+  b h;
+};
+void e::f() {
+  e *i;
+  // expected-note at -1{{'i' declared without an initial value}}
+  if (h)
+    // expected-note at -1{{Taking true branch}}
+    // expected-note at -2{{'b::operator int ns1::a::b::*'}}
+    // expected-note at -3{{Returning from 'b::operator int ns1::a::b::*'}}
+    i->g();
+  // expected-note at -1{{Called C++ object pointer is uninitialized}}
+  // expected-warning at -2{{Called C++ object pointer is uninitialized}}
+}
+} // namespace ns1


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D104381.352422.patch
Type: text/x-patch
Size: 1211 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210616/1c3d7532/attachment-0001.bin>


More information about the cfe-commits mailing list