[clang] [clang][dataflow] Make optional checker work for types derived from optional. (PR #84138)

Gábor Horváth via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 6 09:00:56 PST 2024


================
@@ -64,38 +64,53 @@ static bool hasOptionalClassName(const CXXRecordDecl &RD) {
   return false;
 }
 
+static const CXXRecordDecl *getOptionalBaseClass(const CXXRecordDecl *RD) {
+  if (RD == nullptr)
+    return nullptr;
+  if (hasOptionalClassName(*RD))
+    return RD;
+
+  if (!RD->hasDefinition())
+    return nullptr;
+
+  for (const CXXBaseSpecifier &Base : RD->bases())
+    if (Base.getAccessSpecifier() == AS_public)
----------------
Xazax-hun wrote:

I wonder if we can still get in trouble with private or protected inheritance. E.g., if I had `class Foo : std::optional`, I could still call the methods of `std::optional ` in `Foo`'s methods. Could we get in trouble while analyzing those methods?

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


More information about the cfe-commits mailing list