[clang] [Clang] Add diagnostic for why std::is_abstract is false (PR #156199)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 23 06:31:46 PDT 2025


================
@@ -2774,6 +2775,66 @@ static void DiagnoseNonAggregateReason(Sema &SemaRef, SourceLocation Loc,
     DiagnoseNonAggregateReason(SemaRef, Loc, D);
 }
 
+static void DiagnoseNonAbstractReason(Sema &SemaRef, SourceLocation Loc,
+                                      const CXXRecordDecl *D) {
+  // If this type has any abstract base classes, their respective virtual
+  // functions must have been overridden.
+  for (const CXXBaseSpecifier &B : D->bases()) {
+    assert(B.getType()->getAsCXXRecordDecl() && "invalid base?");
+    if (B.getType()->getAsCXXRecordDecl()->isAbstract()) {
----------------
erichkeane wrote:

```suggestion
    if (B.getType()->castAsCXXRecordDecl()->isAbstract()) {
```

Plus remove the assert, since castAs does it for you.

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


More information about the cfe-commits mailing list