Skip to content

Commit 97166c8

Browse files
committed
Refactored code for better readability
1 parent b4446bd commit 97166c8

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

clang/include/clang/AST/RecordFieldReorganizer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class RecordFieldReorganizer {
3939
class Randstruct : public RecordFieldReorganizer {
4040
public:
4141
/// Determines if the Record can be safely and easily randomized based on certain criteria (see implementation).
42-
bool isTriviallyRandomizable(const RecordDecl *D) const;
42+
static bool isTriviallyRandomizable(const RecordDecl *D);
4343
protected:
4444
virtual void reorganize(const ASTContext &C, const RecordDecl *D,
4545
SmallVector<Decl *, 64> &NewOrder) const override;

clang/lib/AST/RecordFieldReorganizer.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,10 @@ void Randstruct::reorganize(const ASTContext &C, const RecordDecl *D,
247247
SmallVector<Decl *, 64> randomized = perfrandomize(C, NewOrder);
248248
NewOrder = randomized;
249249
}
250-
bool Randstruct::isTriviallyRandomizable(const RecordDecl *D) const {
251-
250+
bool Randstruct::isTriviallyRandomizable(const RecordDecl *D) {
251+
/*if(D->getAttr<NoRandomizeLayoutAttr>() != nullptr){
252+
return false;
253+
}*/
252254
for (auto f : D->fields()){
253255
//If an element of the structure does not have a
254256
//function type is not a function pointer

clang/lib/AST/RecordLayoutBuilder.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2986,9 +2986,9 @@ ASTContext::getASTRecordLayout(const RecordDecl *D) const {
29862986
if (Entry) return *Entry;
29872987

29882988
const ASTRecordLayout *NewEntry = nullptr;
2989-
Randstruct randstruct;
2990-
bool ShouldBeRandomized = randstruct.isTriviallyRandomizable(D) || D->getAttr<RandomizeLayoutAttr>() != nullptr;
2989+
bool ShouldBeRandomized = Randstruct::isTriviallyRandomizable(D) || D->getAttr<RandomizeLayoutAttr>() != nullptr;
29912990
if(ShouldBeRandomized){
2991+
Randstruct randstruct;
29922992
randstruct.reorganizeFields(*this, D);
29932993
}
29942994

0 commit comments

Comments
 (0)