File tree 1 file changed +15
-0
lines changed
1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -433,10 +433,25 @@ std::set<ConstraintVariable *>
433
433
// { e1, e2, e3, ... }
434
434
} else if (InitListExpr *ILE = dyn_cast<InitListExpr>(E)) {
435
435
if (ILE->getType ()->isArrayType ()) {
436
+ // Array initialization is similar AddrOf, so the same pattern is used
437
+ // where a new indirection is added to constraint variables.
436
438
std::vector<Expr *> SubExprs = ILE->inits ().vec ();
437
439
std::set<ConstraintVariable *> CVars =
438
440
getAllSubExprConstraintVars (SubExprs);
439
441
return addAtomAll (CVars, CS.getArr (), CS);
442
+ } else if (ILE->getType ()->isStructureType ()) {
443
+ // Struct initialization is treated as a series of assignments to the
444
+ // fields of the struct.
445
+ const RecordDecl *Definition =
446
+ ILE->getType ()->getAsStructureType ()->getDecl ()->getDefinition ();
447
+ int initIdx = 0 ;
448
+ for (const auto &D : Definition->fields ()) {
449
+ std::set<ConstraintVariable *> DefCVars = Info.getVariable (D, Context);
450
+ Expr *InitExpr = ILE->getInit (initIdx);
451
+ std::set<ConstraintVariable *> InitCVars = getExprConstraintVars (InitExpr);
452
+ constrainLocalAssign (nullptr , D, InitExpr);
453
+ initIdx++;
454
+ }
440
455
}
441
456
442
457
// "foo"
You can’t perform that action at this time.
0 commit comments