[all-commits] [llvm/llvm-project] 463790: [randstruct] Randomize all elements of a record

Bill Wendling via All-commits all-commits at lists.llvm.org
Thu Apr 28 12:01:27 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 463790bfc70e15f9c23b76f1c53e228b644f8bb1
      https://github.com/llvm/llvm-project/commit/463790bfc70e15f9c23b76f1c53e228b644f8bb1
  Author: Bill Wendling <isanbard at gmail.com>
  Date:   2022-04-28 (Thu, 28 Apr 2022)

  Changed paths:
    M clang/include/clang/AST/Decl.h
    M clang/include/clang/AST/Randstruct.h
    M clang/lib/AST/Decl.cpp
    M clang/lib/AST/Randstruct.cpp
    M clang/lib/Sema/SemaDecl.cpp
    M clang/lib/Sema/SemaInit.cpp
    M clang/test/Sema/init-randomized-struct.c
    M clang/unittests/AST/RandstructTest.cpp

  Log Message:
  -----------
  [randstruct] Randomize all elements of a record

A record may have more than just FieldDecls in it. If so, then we're
likely to drop them if we only randomize the FieldDecls.

We need to be careful about anonymous structs/unions. Their fields are
made available in the RecordDecl as IndirectFieldDecls, which are listed
after the anonymous struct/union. The ordering doesn't appear to be
super important, however we place them unrandomized at the end of the
RecordDecl just in case. There's also the possiblity of
StaticAssertDecls. We also want those at the end.

All other non-FieldDecls we place at the top, just in case we get
something like:

    struct foo {
      enum e { BORK };
      enum e a;
    };

Link: https://github.com/KSPP/linux/issues/185

Reviewed By: aaron.ballman

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




More information about the All-commits mailing list