erichkeane created this revision.
erichkeane added reviewers: aaron.ballman, rnk.

Discovered in a downstream, it is often useful to have slightly
different semantics for an attribute based on its namespace, however our
spelling infrastructure doesn't consider namespace when deciding to
elide the enum list.  The result is that the solution for a case where
an attribute has slightly different semantics based on a namespace
requires checking against the integer value, which is fragile.

      

This patch makes us always emit the spelling enum if there is more than
1 and we're generating the header.


https://reviews.llvm.org/D76289

Files:
  clang/utils/TableGen/ClangAttrEmitter.cpp


Index: clang/utils/TableGen/ClangAttrEmitter.cpp
===================================================================
--- clang/utils/TableGen/ClangAttrEmitter.cpp
+++ clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -2328,11 +2328,8 @@
     // This maps spelling index values to semantic Spelling enumerants.
     SemanticSpellingMap SemanticToSyntacticMap;
 
-    std::string SpellingEnum;
-    if (!ElideSpelling)
-      SpellingEnum = CreateSemanticSpellings(Spellings, 
SemanticToSyntacticMap);
-    if (Header)
-      OS << SpellingEnum;
+    if (Header && Spellings.size() > 1)
+      OS <<  CreateSemanticSpellings(Spellings, SemanticToSyntacticMap);
 
     const auto &ParsedAttrSpellingItr = llvm::find_if(
         AttrMap, [R](const std::pair<std::string, const Record *> &P) {


Index: clang/utils/TableGen/ClangAttrEmitter.cpp
===================================================================
--- clang/utils/TableGen/ClangAttrEmitter.cpp
+++ clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -2328,11 +2328,8 @@
     // This maps spelling index values to semantic Spelling enumerants.
     SemanticSpellingMap SemanticToSyntacticMap;
 
-    std::string SpellingEnum;
-    if (!ElideSpelling)
-      SpellingEnum = CreateSemanticSpellings(Spellings, SemanticToSyntacticMap);
-    if (Header)
-      OS << SpellingEnum;
+    if (Header && Spellings.size() > 1)
+      OS <<  CreateSemanticSpellings(Spellings, SemanticToSyntacticMap);
 
     const auto &ParsedAttrSpellingItr = llvm::find_if(
         AttrMap, [R](const std::pair<std::string, const Record *> &P) {
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to