Co-authored-by: Cole Nixon <nixontc...@gmail.com>
Co-authored-by: Connor Kuehl <cipku...@gmail.com>
Co-authored-by: James Foster <jafoste...@gmail.com>
Co-authored-by: Jeff Takahashi <jeffrey.takaha...@gmail.com>
Co-authored-by: Jordan Cantrell <jordan.cantr...@mail.com>
Co-authored-by: Nikk Forbus <nicholas.for...@gmail.com>
Co-authored-by: Tim Pugh <nwtp...@gmail.com>
---
 clang/include/clang/Basic/Attr.td                          | 7 +++++++
 clang/lib/Sema/SemaDeclAttr.cpp                            | 3 +++
 .../Misc/pragma-attribute-supported-attributes-list.test   | 1 +
 3 files changed, 11 insertions(+)

diff --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index 523b89d0fcc..2d44d14ad6d 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -3214,3 +3214,10 @@ def ObjCExternallyRetained : InheritableAttr {
   let Subjects = SubjectList<[NonParmVar, Function, Block, ObjCMethod]>;
   let Documentation = [ObjCExternallyRetainedDocs];
 }
+
+def RandomizeLayout : InheritableAttr {
+  let Spellings = [GCC<"randomize_layout">, Declspec<"randomize_layout">,
+    Keyword<"randomize_layout">];
+  let Subjects = SubjectList<[Record]>;
+  let Documentation = [ClangRandstructDocs];
+}
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index c97d0bc819f..5de9125b44f 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -6966,6 +6966,9 @@ static void ProcessDeclAttribute(Sema &S, Scope *scope, 
Decl *D,
     handleSimpleAttributeWithExclusions<NoSpeculativeLoadHardeningAttr,
                                         SpeculativeLoadHardeningAttr>(S, D, 
AL);
     break;
+  case ParsedAttr::AT_RandomizeLayout:
+    handleSimpleAttribute<RandomizeLayoutAttr>(S, D, AL);
+    break;
   case ParsedAttr::AT_CodeSeg:
     handleCodeSegAttr(S, D, AL);
     break;
diff --git a/clang/test/Misc/pragma-attribute-supported-attributes-list.test 
b/clang/test/Misc/pragma-attribute-supported-attributes-list.test
index 9a7e65d2b24..b4bc1b3112f 100644
--- a/clang/test/Misc/pragma-attribute-supported-attributes-list.test
+++ b/clang/test/Misc/pragma-attribute-supported-attributes-list.test
@@ -118,6 +118,7 @@
 // CHECK-NEXT: Overloadable (SubjectMatchRule_function)
 // CHECK-NEXT: ParamTypestate (SubjectMatchRule_variable_is_parameter)
 // CHECK-NEXT: PassObjectSize (SubjectMatchRule_variable_is_parameter)
+// CHECK-NEXT: RandomizeLayout (SubjectMatchRule_record)
 // CHECK-NEXT: RenderScriptKernel (SubjectMatchRule_function)
 // CHECK-NEXT: ReqdWorkGroupSize (SubjectMatchRule_function)
 // CHECK-NEXT: RequireConstantInit (SubjectMatchRule_variable_is_global)
-- 
2.17.1

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to