@@ -1365,23 +1365,6 @@ void ItaniumRecordLayoutBuilder::LayoutFields(const RecordDecl *D) {
13651365 bool InsertExtraPadding = D->mayInsertExtraPadding (/* EmitRemark=*/ true );
13661366 bool HasFlexibleArrayMember = D->hasFlexibleArrayMember ();
13671367
1368- // A staging area to easily reorder the fields
1369- SmallVector<Decl *, 64 > fields;
1370- for (auto f : D->fields ()) {
1371- fields.push_back (f);
1372- }
1373-
1374- bool ShouldBeRandomized = D->getAttr <RandomizeLayoutAttr>() != nullptr ;
1375- if (ShouldBeRandomized) {
1376- // FIXME Should call our Randstruct code once we port it.
1377- auto rng = std::default_random_engine {};
1378- std::shuffle (std::begin (fields), std::end (fields), rng);
1379-
1380- // This will rebuild the Decl chain of fields
1381- D->reorderFields (fields);
1382- }
1383-
1384-
13851368 for (auto I = D->field_begin (), End = D->field_end (); I != End; ++I) {
13861369 auto Next (I);
13871370 ++Next;
@@ -3005,6 +2988,24 @@ ASTContext::getASTRecordLayout(const RecordDecl *D) const {
30052988
30062989 const ASTRecordLayout *NewEntry = nullptr ;
30072990
2991+ // FIXME Randstruct code should be called here!
2992+ // A staging area to easily reorder the fields
2993+ SmallVector<Decl *, 64 > fields;
2994+ for (auto f : D->fields ()) {
2995+ fields.push_back (f);
2996+ }
2997+
2998+ bool ShouldBeRandomized = D->getAttr <RandomizeLayoutAttr>() != nullptr ;
2999+ if (ShouldBeRandomized) {
3000+ // FIXME Should call our Randstruct code once we port it.
3001+ auto rng = std::default_random_engine {};
3002+ std::shuffle (std::begin (fields), std::end (fields), rng);
3003+
3004+ // This will rebuild the Decl chain of fields
3005+ D->reorderFields (fields);
3006+ }
3007+ // FIXME end Randstruct code
3008+
30083009 if (isMsLayout (*this )) {
30093010 MicrosoftRecordLayoutBuilder Builder (*this );
30103011 if (const auto *RD = dyn_cast<CXXRecordDecl>(D)) {
0 commit comments