@@ -3999,41 +3999,20 @@ class ExpandSynthesizedMemberMacroRequest
3999
3999
bool isCached () const { return true ; }
4000
4000
};
4001
4001
4002
- // / Load a plugin module with the given name.
4003
- // /
4004
- // /
4002
+ // / Represent a loaded plugin either an in-process library or an executable.
4005
4003
class LoadedCompilerPlugin {
4006
- enum class PluginKind : uint8_t {
4007
- None,
4008
- InProcess,
4009
- Executable,
4010
- };
4011
- PluginKind kind;
4012
- void *ptr;
4013
-
4014
- LoadedCompilerPlugin (PluginKind kind, void *ptr) : kind(kind), ptr(ptr) {
4015
- assert (ptr != nullptr || kind == PluginKind::None);
4016
- }
4004
+ llvm::PointerUnion<LoadedLibraryPlugin *, LoadedExecutablePlugin *> ptr;
4017
4005
4018
4006
public:
4019
- LoadedCompilerPlugin (std::nullptr_t ) : kind(PluginKind::None), ptr(nullptr ) {}
4020
-
4021
- static LoadedCompilerPlugin inProcess (LoadedLibraryPlugin *ptr) {
4022
- return {PluginKind::InProcess, ptr};
4023
- }
4024
- static LoadedCompilerPlugin executable (LoadedExecutablePlugin *ptr) {
4025
- return {PluginKind::Executable, ptr};
4026
- }
4007
+ LoadedCompilerPlugin (std::nullptr_t ) : ptr(nullptr ) {}
4008
+ LoadedCompilerPlugin (LoadedLibraryPlugin *ptr) : ptr(ptr){};
4009
+ LoadedCompilerPlugin (LoadedExecutablePlugin *ptr) : ptr(ptr){};
4027
4010
4028
- LoadedLibraryPlugin *getAsInProcessPlugin () const {
4029
- return kind == PluginKind::InProcess
4030
- ? static_cast <LoadedLibraryPlugin *>(ptr)
4031
- : nullptr ;
4011
+ LoadedLibraryPlugin *getAsLibraryPlugin () const {
4012
+ return ptr.dyn_cast <LoadedLibraryPlugin *>();
4032
4013
}
4033
4014
LoadedExecutablePlugin *getAsExecutablePlugin () const {
4034
- return kind == PluginKind::Executable
4035
- ? static_cast <LoadedExecutablePlugin *>(ptr)
4036
- : nullptr ;
4015
+ return ptr.dyn_cast <LoadedExecutablePlugin *>();
4037
4016
}
4038
4017
};
4039
4018
0 commit comments