Author: Kadir Cetinkaya
Date: 2022-08-31T10:09:24+02:00
New Revision: a5ab650714d05c2e49ec158dc99156118a893027

URL: 
https://github.com/llvm/llvm-project/commit/a5ab650714d05c2e49ec158dc99156118a893027
DIFF: 
https://github.com/llvm/llvm-project/commit/a5ab650714d05c2e49ec158dc99156118a893027.diff

LOG: [clang] Fix a crash in constant evaluation

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.

Differential Revision: https://reviews.llvm.org/D132918

Added: 
    

Modified: 
    clang/lib/AST/ExprConstant.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 3df0e4292b6ca..2b1a30f8354fb 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -4794,6 +4794,11 @@ static bool getDefaultInitValue(QualType T, APValue 
&Result) {
       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