#include "clang/AST/Randstruct.h"
#include "gtest/gtest.h"
#include "DeclMatcher.h"
#include "clang/AST/RecordLayout.h"
#include "clang/ASTMatchers/ASTMatchers.h"
#include "clang/Frontend/ASTUnit.h"
#include "clang/Testing/CommandLineArgs.h"
#include "clang/Tooling/Tooling.h"
#include "llvm/Support/ToolOutputFile.h"
#include <vector>
usingnamespaceclang;
usingnamespaceclang::ast_matchers;
usingnamespaceclang::randstruct;
field_names;
constexpr const char Seed[] = …;
static RecordDecl *getRecordDeclFromAST(const ASTContext &C,
const std::string &Name) { … }
static std::vector<std::string> getFieldNamesFromRecord(const RecordDecl *RD) { … }
static bool isSubsequence(const field_names &Seq, const field_names &Subseq) { … }
static bool recordsEqual(const std::unique_ptr<ASTUnit> &LHS,
const std::unique_ptr<ASTUnit> &RHS,
const std::string &RecordName) { … }
static std::unique_ptr<ASTUnit>
makeAST(const std::string &SourceCode, bool ExpectError = false,
std::vector<std::string> RecordNames = std::vector<std::string>()) { … }
namespace clang {
namespace ast_matchers {
long declCount(const RecordDecl *RD) { … }
#define RANDSTRUCT_TEST_SUITE_TEST …
TEST(RANDSTRUCT_TEST_SUITE_TEST, CanDetermineIfSubsequenceExists) { … }
#define RANDSTRUCT_TEST …
TEST(RANDSTRUCT_TEST, UnmarkedStruct) { … }
TEST(RANDSTRUCT_TEST, MarkedNoRandomize) { … }
TEST(RANDSTRUCT_TEST, MarkedRandomize) { … }
TEST(RANDSTRUCT_TEST, MismatchedAttrsDeclVsDef) { … }
TEST(RANDSTRUCT_TEST, MismatchedAttrsRandomizeVsNoRandomize) { … }
TEST(RANDSTRUCT_TEST, MismatchedAttrsNoRandomizeVsRandomize) { … }
TEST(RANDSTRUCT_TEST, CheckAdjacentBitfieldsRemainAdjacentAfterRandomization) { … }
TEST(RANDSTRUCT_TEST, CheckFlexibleArrayMemberRemainsAtEndOfStructure1) { … }
TEST(RANDSTRUCT_TEST, CheckFlexibleArrayMemberRemainsAtEndOfStructure2) { … }
TEST(RANDSTRUCT_TEST, CheckFlexibleArrayMemberRemainsAtEndOfStructure3) { … }
TEST(RANDSTRUCT_TEST, RandstructDoesNotOverrideThePackedAttr) { … }
TEST(RANDSTRUCT_TEST, ZeroWidthBitfieldsSeparateAllocationUnits) { … }
TEST(RANDSTRUCT_TEST, RandstructDoesNotRandomizeUnionFieldOrder) { … }
TEST(RANDSTRUCT_TEST, AnonymousStructsAndUnionsRetainFieldOrder) { … }
TEST(RANDSTRUCT_TEST, AnonymousStructsAndUnionsReferenced) { … }
TEST(RANDSTRUCT_TEST, AutoRandomizeStructOfFunctionPointers) { … }
TEST(RANDSTRUCT_TEST, DisableAutoRandomizeStructOfFunctionPointers) { … }
}
}