[clang] 661c950 - [NFC][Attr TableGen] Emit Spelling Enum for Attr types if there >1

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 17 12:22:30 PDT 2020


Author: Erich Keane
Date: 2020-03-17T12:20:23-07:00
New Revision: 661c950630fbc30c49c6a0d3f78eebeb87a2f019

URL: https://github.com/llvm/llvm-project/commit/661c950630fbc30c49c6a0d3f78eebeb87a2f019
DIFF: https://github.com/llvm/llvm-project/commit/661c950630fbc30c49c6a0d3f78eebeb87a2f019.diff

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

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.

Differential Revision: https://reviews.llvm.org/D76289

Added: 
    

Modified: 
    clang/utils/TableGen/ClangAttrEmitter.cpp

Removed: 
    


################################################################################
diff  --git a/clang/utils/TableGen/ClangAttrEmitter.cpp b/clang/utils/TableGen/ClangAttrEmitter.cpp
index 529145efa3d0..c7380cd49652 100644
--- a/clang/utils/TableGen/ClangAttrEmitter.cpp
+++ b/clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -2329,7 +2329,7 @@ static void emitAttributes(RecordKeeper &Records, raw_ostream &OS,
     SemanticSpellingMap SemanticToSyntacticMap;
 
     std::string SpellingEnum;
-    if (!ElideSpelling)
+    if (Spellings.size() > 1)
       SpellingEnum = CreateSemanticSpellings(Spellings, SemanticToSyntacticMap);
     if (Header)
       OS << SpellingEnum;


        


More information about the cfe-commits mailing list