From 363e96ba9ed442698c134f7f716a667e65ba3dbb Mon Sep 17 00:00:00 2001 From: Thomas Fransham Date: Mon, 8 Jul 2024 01:48:46 +0100 Subject: [PATCH] [Clang][TableGen] Add explicit symbol visibility macros to code generated Update ClangAttrEmitter tablegen to add explicit symbol visibility macros to function declarations it creates. Both AnnotateFunctions and Attribute example plugins require clang::AnnotateAttr TableGen created functions to be exported from the Clang shared library. --- clang/utils/TableGen/ClangAttrEmitter.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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);