[clang] [clang][Sema] Add checks for validity of default ctor's class (PR #78898)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 22 07:42:47 PST 2024


================
@@ -5990,6 +5990,10 @@ void Sema::ActOnDefaultCtorInitializers(Decl *CDtorDecl) {
 
   if (CXXConstructorDecl *Constructor
       = dyn_cast<CXXConstructorDecl>(CDtorDecl)) {
+    if (CXXRecordDecl *ClassDecl = Constructor->getParent();
+        !ClassDecl || ClassDecl->isInvalidDecl()) {
+      return;
+    }
----------------
AaronBallman wrote:

```suggestion
    if (CXXRecordDecl *ClassDecl = Constructor->getParent();
        !ClassDecl || ClassDecl->isInvalidDecl())
      return;
```

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


More information about the cfe-commits mailing list