[llvm] [TableGen] Fix __CLAUSE_NO_CLASS macro leak in directive emitter (PR #82912)

via llvm-commits llvm-commits at lists.llvm.org
Sun Feb 25 00:21:00 PST 2024


https://github.com/FruitClover created https://github.com/llvm/llvm-project/pull/82912

`__CLAUSE_NO_CLASS` was not undefined inside the `GEN_CLANG_CLAUSE_CLASS` block, resulting in macro redifinition warnings when several generated directives are used simultaneously.

>From a4fbde7620abe7bd102455acea68fbbd5c3eec7a Mon Sep 17 00:00:00 2001
From: Mike Kashkarov <m.kashkarov at samsung.com>
Date: Fri, 23 Feb 2024 00:55:39 +0300
Subject: [PATCH] [TableGen] Fix __CLAUSE_NO_CLASS macro leak in directive
 emitter

__CLAUSE_NO_CLASS was not undefined inside the GEN_CLANG_CLAUSE_CLASS block,
resulting in macro redifinition warnings when several generated directives are
used simultaneously.
---
 llvm/test/TableGen/directive1.td         | 1 +
 llvm/test/TableGen/directive2.td         | 1 +
 llvm/utils/TableGen/DirectiveEmitter.cpp | 1 +
 3 files changed, 3 insertions(+)

diff --git a/llvm/test/TableGen/directive1.td b/llvm/test/TableGen/directive1.td
index b249f2bf5fc689..bcd9fa34c99d3a 100644
--- a/llvm/test/TableGen/directive1.td
+++ b/llvm/test/TableGen/directive1.td
@@ -258,6 +258,7 @@ def TDL_DirA : Directive<"dira"> {
 // IMPL-EMPTY:
 // IMPL-NEXT:  #undef __IMPLICIT_CLAUSE_NO_CLASS
 // IMPL-NEXT:  #undef __IMPLICIT_CLAUSE_CLASS
+// IMPL-NEXT:  #undef __CLAUSE_NO_CLASS
 // IMPL-NEXT:  #undef __CLAUSE
 // IMPL-NEXT:  #undef CLAUSE_NO_CLASS
 // IMPL-NEXT:  #undef CLAUSE_CLASS
diff --git a/llvm/test/TableGen/directive2.td b/llvm/test/TableGen/directive2.td
index 154d1e86ffb1d6..01741152956d22 100644
--- a/llvm/test/TableGen/directive2.td
+++ b/llvm/test/TableGen/directive2.td
@@ -206,6 +206,7 @@ def TDL_DirA : Directive<"dira"> {
 // IMPL-EMPTY:
 // IMPL-NEXT:  #undef __IMPLICIT_CLAUSE_NO_CLASS
 // IMPL-NEXT:  #undef __IMPLICIT_CLAUSE_CLASS
+// IMPL-NEXT:  #undef __CLAUSE_NO_CLASS
 // IMPL-NEXT:  #undef __CLAUSE
 // IMPL-NEXT:  #undef CLAUSE_NO_CLASS
 // IMPL-NEXT:  #undef CLAUSE_CLASS
diff --git a/llvm/utils/TableGen/DirectiveEmitter.cpp b/llvm/utils/TableGen/DirectiveEmitter.cpp
index b6aee665f8ee0b..99eebacd6b3f32 100644
--- a/llvm/utils/TableGen/DirectiveEmitter.cpp
+++ b/llvm/utils/TableGen/DirectiveEmitter.cpp
@@ -842,6 +842,7 @@ static void GenerateClauseClassMacro(const DirectiveLanguage &DirLang,
   OS << "\n";
   OS << "#undef __IMPLICIT_CLAUSE_NO_CLASS\n";
   OS << "#undef __IMPLICIT_CLAUSE_CLASS\n";
+  OS << "#undef __CLAUSE_NO_CLASS\n";
   OS << "#undef __CLAUSE\n";
   OS << "#undef CLAUSE_NO_CLASS\n";
   OS << "#undef CLAUSE_CLASS\n";



More information about the llvm-commits mailing list