[clang] [clang][analyzer][NFCi] Pass if bind is to a Decl or not to checkBind (PR #152137)

Balazs Benics via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 7 12:42:33 PDT 2025


Endre =?utf-8?q?F=C3=BCl=C3=B6p?= <endre.fulop at sigmatechnology.com>,
Endre =?utf-8?q?F=C3=BCl=C3=B6p?= <endre.fulop at sigmatechnology.com>,
Endre =?utf-8?q?F=C3=BCl=C3=B6p?= <endre.fulop at sigmatechnology.com>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/152137 at github.com>


================
@@ -150,4 +152,23 @@ TEST(ExprEngineVisitTest, checkLocationAndBind) {
   EXPECT_TRUE(LocPos > BindPos);
 }
 
+TEST(ExprEngineVisitTest, checkLocationAndBindInitialization) {
+  std::string Diags;
+  EXPECT_TRUE(runCheckerOnCode<addMemAccessChecker>(R"(
+    class MyClass{
+    public:
+      int Value;
+    };
+    extern MyClass MyClassRead;
+    void top() {
+      MyClass MyClassWrite = MyClassRead;
+    }
+  )",
+                                                    Diags));
+
+  // Look for any occurrence of AtDeclInit = true
+  std::size_t BindPos = Diags.find("AtDeclInit = true");
+  EXPECT_NE(BindPos, std::string::npos);
----------------
steakhal wrote:

```suggestion
  EXPECT_TRUE(StringRef(Diags).contains("AtDeclInit = true"));
```

https://github.com/llvm/llvm-project/pull/152137


More information about the cfe-commits mailing list