diff --git a/utils/TableGen/ClangAttrEmitter.cpp b/utils/TableGen/ClangAttrEmitter.cpp
index c7f235e..c8fa33d 100644
--- a/utils/TableGen/ClangAttrEmitter.cpp
+++ b/utils/TableGen/ClangAttrEmitter.cpp
@@ -1598 +1598,9 @@ static void EmitAttrList(raw_ostream &OS, StringRef Class,
-namespace clang {
+// Determines if an attribute has a Pragma spelling.
+bool AttrHasPragmaSpelling(Record *R) {
+  std::vector<FlattenedSpelling> Spellings = GetFlattenedSpellings(*R);
+  for (const auto &SI : Spellings) {
+    std::string Variety = SI.variety();
+    if (Variety == "Pragma") {
+      return true;
+    }
+  }
@@ -1599,0 +1608,4 @@ namespace clang {
+  return false;
+}
+
+namespace clang {
@@ -1624,0 +1637,8 @@ void EmitClangAttrList(RecordKeeper &Records, raw_ostream &OS) {
+  OS << "#ifndef PRAGMA_ATTR\n";
+  OS << "#define PRAGMA_ATTR(NAME) ATTR(NAME)\n";
+  OS << "#endif\n\n";
+
+  OS << "#ifndef LAST_PRAGMA_ATTR\n";
+  OS << "#define LAST_PRAGMA_ATTR(NAME) PRAGMA_ATTR(NAME)\n";
+  OS << "#endif\n\n";
+
@@ -1628 +1648 @@ void EmitClangAttrList(RecordKeeper &Records, raw_ostream &OS) {
-                       NonInhAttrs, InhAttrs, InhParamAttrs;
+                       NonInhAttrs, InhAttrs, InhParamAttrs, PragmaAttrs;
@@ -1632,2 +1652,4 @@ void EmitClangAttrList(RecordKeeper &Records, raw_ostream &OS) {
-    
-    if (Attr->isSubClassOf(InhParamClass))
+
+    if (AttrHasPragmaSpelling(Attr))
+      PragmaAttrs.push_back(Attr);
+    else if (Attr->isSubClassOf(InhParamClass))
@@ -1640,0 +1663 @@ void EmitClangAttrList(RecordKeeper &Records, raw_ostream &OS) {
+  EmitAttrList(OS, "PRAGMA_ATTR", PragmaAttrs);
@@ -1648,0 +1672,2 @@ void EmitClangAttrList(RecordKeeper &Records, raw_ostream &OS) {
+  OS << "#undef LAST_PRAGMA_ATTR\n";
+  OS << "#undef PRAGMA_ATTR\n";
