diff options
author | Jan Svoboda <jan_svoboda@apple.com> | 2021-03-01 18:52:15 +0100 |
---|---|---|
committer | Jan Svoboda <jan_svoboda@apple.com> | 2021-03-05 11:11:05 +0100 |
commit | 4295ae96cdf275cdda8bded9271960a4cac11fb2 (patch) | |
tree | 63c4e3f4df83db07fff18cb4bfd649b1d29e47de /clang/lib/Serialization/ModuleFileExtension.cpp | |
parent | 36beaa3ba3b334fa0be0afd0a2b0da9c7c8afd34 (diff) | |
download | llvm-4295ae96cdf275cdda8bded9271960a4cac11fb2.zip llvm-4295ae96cdf275cdda8bded9271960a4cac11fb2.tar.gz llvm-4295ae96cdf275cdda8bded9271960a4cac11fb2.tar.bz2 |
[clang][modules] Use extensible RTTI for ModuleFileExtension
Clang exposes an interface for extending the PCM/PCH file format: `ModuleFileExtension`.
Clang itself has only a single implementation of the interface: `TestModuleFileExtension` that can be instantiated via the `-ftest-module-file_extension=` command line argument (and is stored in `FrontendOptions::ModuleFileExtensions`).
Clients of the Clang library can extend the PCM/PCH file format by pushing an instance of their extension class to the `FrontendOptions::ModuleFileExtensions` vector.
When generating the `-ftest-module-file_extension=` command line argument from `FrontendOptions`, a downcast is used to distinguish between the Clang's testing extension and other (client) extensions.
This functionality is enabled by LLVM-style RTTI. However, this style of RTTI is hard to extend, as it requires patching Clang (adding new case to the `ModuleFileExtensionKind` enum).
This patch switches to the LLVM RTTI for open class hierarchies, which allows libClang users (e.g. Swift) to create implementations of `ModuleFileExtension` without patching Clang. (Documentation of the feature: https://llvm.org/docs/HowToSetUpLLVMStyleRTTI.html#rtti-for-open-class-hierarchies)
Reviewed By: artemcm
Differential Revision: https://reviews.llvm.org/D97702
Diffstat (limited to 'clang/lib/Serialization/ModuleFileExtension.cpp')
-rw-r--r-- | clang/lib/Serialization/ModuleFileExtension.cpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/clang/lib/Serialization/ModuleFileExtension.cpp b/clang/lib/Serialization/ModuleFileExtension.cpp index e1ae8a4..6b7fd1d 100644 --- a/clang/lib/Serialization/ModuleFileExtension.cpp +++ b/clang/lib/Serialization/ModuleFileExtension.cpp @@ -9,6 +9,8 @@ #include "llvm/ADT/Hashing.h" using namespace clang; +char ModuleFileExtension::ID = 0; + ModuleFileExtension::~ModuleFileExtension() { } llvm::hash_code ModuleFileExtension::hashExtension(llvm::hash_code Code) const { |