1 //===-- ObjCPlusPlusLanguage.cpp ------------------------------------------===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 #include "ObjCPlusPlusLanguage.h" 10 11 #include "lldb/Core/PluginManager.h" 12 #include "lldb/Utility/ConstString.h" 13 14 using namespace lldb; 15 using namespace lldb_private; 16 LLDB_PLUGIN_DEFINE(ObjCPlusPlusLanguage)17LLDB_PLUGIN_DEFINE(ObjCPlusPlusLanguage) 18 19 bool ObjCPlusPlusLanguage::IsSourceFile(llvm::StringRef file_path) const { 20 const auto suffixes = {".h", ".mm"}; 21 for (auto suffix : suffixes) { 22 if (file_path.endswith_lower(suffix)) 23 return true; 24 } 25 return false; 26 } 27 Initialize()28void ObjCPlusPlusLanguage::Initialize() { 29 PluginManager::RegisterPlugin(GetPluginNameStatic(), "Objective-C++ Language", 30 CreateInstance); 31 } 32 Terminate()33void ObjCPlusPlusLanguage::Terminate() { 34 PluginManager::UnregisterPlugin(CreateInstance); 35 } 36 GetPluginNameStatic()37lldb_private::ConstString ObjCPlusPlusLanguage::GetPluginNameStatic() { 38 static ConstString g_name("objcplusplus"); 39 return g_name; 40 } 41 42 // PluginInterface protocol GetPluginName()43lldb_private::ConstString ObjCPlusPlusLanguage::GetPluginName() { 44 return GetPluginNameStatic(); 45 } 46 GetPluginVersion()47uint32_t ObjCPlusPlusLanguage::GetPluginVersion() { return 1; } 48 49 // Static Functions CreateInstance(lldb::LanguageType language)50Language *ObjCPlusPlusLanguage::CreateInstance(lldb::LanguageType language) { 51 switch (language) { 52 case lldb::eLanguageTypeObjC_plus_plus: 53 return new ObjCPlusPlusLanguage(); 54 default: 55 return nullptr; 56 } 57 } 58