[clang] [Clang][TableGen] Add explicit symbol visibility macros to code generated (PR #109362)

via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 19 19:05:38 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Thomas Fransham (fsfod)

<details>
<summary>Changes</summary>

Update ClangAttrEmitter TableGen to add explicit symbol visibility macros to class declarations it creates.
Both AnnotateFunctions and Attribute example plugins require clang::AnnotateAttr TableGen created functions to be exported from the Clang shared library.

---
Full diff: https://github.com/llvm/llvm-project/pull/109362.diff


1 Files Affected:

- (modified) clang/utils/TableGen/ClangAttrEmitter.cpp (+3-2) 


``````````diff
diff --git a/clang/utils/TableGen/ClangAttrEmitter.cpp b/clang/utils/TableGen/ClangAttrEmitter.cpp
index 87be48c215e230..43c423eb033890 100644
--- a/clang/utils/TableGen/ClangAttrEmitter.cpp
+++ b/clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -2762,7 +2762,7 @@ static void emitAttributes(const RecordKeeper &Records, raw_ostream &OS,
     }
 
     if (Header)
-      OS << "class " << R.getName() << "Attr : public " << SuperName << " {\n";
+      OS << "class CLANG_ABI " << R.getName() << "Attr : public " << SuperName << " {\n";
     else
       OS << "\n// " << R.getName() << "Attr implementation\n\n";
 
@@ -3220,7 +3220,8 @@ void clang::EmitClangAttrClass(const RecordKeeper &Records, raw_ostream &OS) {
   emitSourceFileHeader("Attribute classes' definitions", OS, Records);
 
   OS << "#ifndef LLVM_CLANG_ATTR_CLASSES_INC\n";
-  OS << "#define LLVM_CLANG_ATTR_CLASSES_INC\n\n";
+  OS << "#define LLVM_CLANG_ATTR_CLASSES_INC\n";
+  OS << "#include \"clang/Support/Compiler.h\"\n\n";
 
   emitAttributes(Records, OS, true);
 

``````````

</details>


https://github.com/llvm/llvm-project/pull/109362


More information about the cfe-commits mailing list