[PATCH] D76289: [NFC][Attr TableGen] Emit Spelling Enum for Attr types if there >1

Erich Keane via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 17 08:31:34 PDT 2020


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) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D76289.250787.patch
Type: text/x-patch
Size: 784 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200317/824bd92c/attachment.bin>


More information about the cfe-commits mailing list