[PATCH] D123958: [randstruct] Randomize all elements of a record

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 27 09:45:03 PDT 2022

aaron.ballman added a comment.

Can you also add a test specifically for an enumeration declaration, as that was something we found bugs with?

Comment at: clang/lib/AST/Randstruct.cpp:201
+            dyn_cast<ConstantArrayType>(RandomizedFields.back()->getType()))
+      if (CA->getSize().sle(2) || CA->isIncompleteArrayType())
+        FlexibleArray = RandomizedFields.pop_back_val();
CA->isIncompleteArrayType() looks to be at the wrong spot. An incomplete array type is one of type `IncompleteArrayType`, which a `ConstantArrayType` is not. Are we missing test coverage, or does the `hasFlexibleArrayMember()` make it so that we just need to remove this check entirely?

Comment at: clang/unittests/AST/RandstructTest.cpp:368
+        int h;
+        char name[0];
+    } __attribute__((randomize_layout));
Can you add a test where the last field is `char name[1];` and another one for `char name[];` so that we have full coverage there?

  rG LLVM Github Monorepo



More information about the cfe-commits mailing list