kadircet created this revision.
kadircet added reviewers: usaxena95, ilya-biryukov.
Herald added a project: All.
kadircet requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This was showing up in our internal crash collector. I have no idea how
to test it out though, open for suggestions if there are easy paths but
otherwise I'd move forward with the patch.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D132918

Files:
  clang/lib/AST/ExprConstant.cpp


Index: clang/lib/AST/ExprConstant.cpp
===================================================================
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -4794,6 +4794,11 @@
       Result = APValue((const FieldDecl *)nullptr);
       return true;
     }
+    // Can't access properties of an incomplete type.
+    if (!RD->hasDefinition()) {
+      Result = APValue();
+      return false;
+    }
     Result = APValue(APValue::UninitStruct(), RD->getNumBases(),
                      std::distance(RD->field_begin(), RD->field_end()));
 


Index: clang/lib/AST/ExprConstant.cpp
===================================================================
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -4794,6 +4794,11 @@
       Result = APValue((const FieldDecl *)nullptr);
       return true;
     }
+    // Can't access properties of an incomplete type.
+    if (!RD->hasDefinition()) {
+      Result = APValue();
+      return false;
+    }
     Result = APValue(APValue::UninitStruct(), RD->getNumBases(),
                      std::distance(RD->field_begin(), RD->field_end()));
 
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to