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