[clang] [clang][dataflow] Model assignment to derived class from base. (PR #85064)

via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 18 02:06:14 PDT 2024


================
@@ -212,8 +212,23 @@ TEST(TransferTest, CopyRecordFromDerivedToBase) {
       // [[p]]
     }
   )";
+  auto SyntheticFieldCallback = [](QualType Ty) -> llvm::StringMap<QualType> {
+    CXXRecordDecl *ADecl = nullptr;
+    if (Ty.getAsString() == "A")
+      ADecl = Ty->getAsCXXRecordDecl();
+    else if (Ty.getAsString() == "B")
+      ADecl = Ty->getAsCXXRecordDecl()
+                  ->bases_begin()
+                  ->getType()
+                  ->getAsCXXRecordDecl();
+    else
+      return {};
+    QualType IntTy = getFieldNamed(ADecl, "i")->getType();
+    return {{"synth_int", IntTy}};
+  };
+  // Copy derived to base class.
----------------
martinboehme wrote:

This means that the following lines test the case of copying from the derived class to the base class, whereas another piece of the test further down tests the case of copying from the base class to the derived class. I'm not sure how I could word this better -- I've reworded slightly to "Test copying derived to base class", as maybe it wasn't clear that I was describing the behavior to be tested?

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


More information about the cfe-commits mailing list