Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Clang][TableGen] Add explicit symbol visibility macros to code generated #109362

Merged
merged 2 commits into from
Nov 5, 2024

Conversation

fsfod
Copy link
Contributor

@fsfod fsfod commented Sep 20, 2024

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

@llvmbot llvmbot added the clang Clang issues not falling into any other category label Sep 20, 2024
@llvmbot
Copy link
Member

llvmbot commented Sep 20, 2024

@llvm/pr-subscribers-clang

Author: Thomas Fransham (fsfod)

Changes

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

Copy link

github-actions bot commented Sep 20, 2024

✅ With the latest revision this PR passed the C/C++ code formatter.

@vgvassilev
Copy link
Contributor

@AaronBallman, ping.

@vgvassilev
Copy link
Contributor

@fsfod, can you rebase?

fsfod added 2 commits November 2, 2024 21:41
…ated

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.
@fsfod fsfod force-pushed the exported-api/clang-tablegen branch from 164b921 to e395af0 Compare November 2, 2024 21:42
Copy link
Collaborator

@AaronBallman AaronBallman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@vgvassilev vgvassilev merged commit d7979c1 into llvm:main Nov 5, 2024
8 checks passed
PhilippRados pushed a commit to PhilippRados/llvm-project that referenced this pull request Nov 6, 2024
…ated (llvm#109362)

Update ClangAttrEmitter TableGen to add explicit symbol visibility
macros to attribute class declarations it creates.
Both AnnotateFunctions and Attribute example plugins require
clang::AnnotateAttr TableGen created functions to be exported from the
Clang shared library.
This depends on macros to be added in
llvm#108276
@fsfod fsfod deleted the exported-api/clang-tablegen branch December 2, 2024 11:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants