1435933ddSDimitry Andric //===-- ObjCPlusPlusLanguage.cpp --------------------------------------*- C++
2435933ddSDimitry Andric //-*-===//
39f2f44ceSEd Maste //
49f2f44ceSEd Maste //                     The LLVM Compiler Infrastructure
59f2f44ceSEd Maste //
69f2f44ceSEd Maste // This file is distributed under the University of Illinois Open Source
79f2f44ceSEd Maste // License. See LICENSE.TXT for details.
89f2f44ceSEd Maste //
99f2f44ceSEd Maste //===----------------------------------------------------------------------===//
109f2f44ceSEd Maste 
119f2f44ceSEd Maste #include "ObjCPlusPlusLanguage.h"
129f2f44ceSEd Maste 
139f2f44ceSEd Maste #include "lldb/Core/PluginManager.h"
14f678e45dSDimitry Andric #include "lldb/Utility/ConstString.h"
159f2f44ceSEd Maste 
169f2f44ceSEd Maste using namespace lldb;
179f2f44ceSEd Maste using namespace lldb_private;
189f2f44ceSEd Maste 
IsSourceFile(llvm::StringRef file_path) const19*b5893f02SDimitry Andric bool ObjCPlusPlusLanguage::IsSourceFile(llvm::StringRef file_path) const {
20*b5893f02SDimitry Andric   const auto suffixes = {".h", ".mm"};
21*b5893f02SDimitry Andric   for (auto suffix : suffixes) {
22*b5893f02SDimitry Andric     if (file_path.endswith_lower(suffix))
23*b5893f02SDimitry Andric       return true;
24*b5893f02SDimitry Andric   }
25*b5893f02SDimitry Andric   return false;
26*b5893f02SDimitry Andric }
27*b5893f02SDimitry Andric 
Initialize()28435933ddSDimitry Andric void ObjCPlusPlusLanguage::Initialize() {
29435933ddSDimitry Andric   PluginManager::RegisterPlugin(GetPluginNameStatic(), "Objective-C++ Language",
309f2f44ceSEd Maste                                 CreateInstance);
319f2f44ceSEd Maste }
329f2f44ceSEd Maste 
Terminate()33435933ddSDimitry Andric void ObjCPlusPlusLanguage::Terminate() {
349f2f44ceSEd Maste   PluginManager::UnregisterPlugin(CreateInstance);
359f2f44ceSEd Maste }
369f2f44ceSEd Maste 
GetPluginNameStatic()37435933ddSDimitry Andric lldb_private::ConstString ObjCPlusPlusLanguage::GetPluginNameStatic() {
389f2f44ceSEd Maste   static ConstString g_name("objcplusplus");
399f2f44ceSEd Maste   return g_name;
409f2f44ceSEd Maste }
419f2f44ceSEd Maste 
429f2f44ceSEd Maste //------------------------------------------------------------------
439f2f44ceSEd Maste // PluginInterface protocol
449f2f44ceSEd Maste //------------------------------------------------------------------
GetPluginName()45435933ddSDimitry Andric lldb_private::ConstString ObjCPlusPlusLanguage::GetPluginName() {
469f2f44ceSEd Maste   return GetPluginNameStatic();
479f2f44ceSEd Maste }
489f2f44ceSEd Maste 
GetPluginVersion()49435933ddSDimitry Andric uint32_t ObjCPlusPlusLanguage::GetPluginVersion() { return 1; }
509f2f44ceSEd Maste 
519f2f44ceSEd Maste //------------------------------------------------------------------
529f2f44ceSEd Maste // Static Functions
539f2f44ceSEd Maste //------------------------------------------------------------------
CreateInstance(lldb::LanguageType language)54435933ddSDimitry Andric Language *ObjCPlusPlusLanguage::CreateInstance(lldb::LanguageType language) {
55435933ddSDimitry Andric   switch (language) {
569f2f44ceSEd Maste   case lldb::eLanguageTypeObjC_plus_plus:
579f2f44ceSEd Maste     return new ObjCPlusPlusLanguage();
589f2f44ceSEd Maste   default:
599f2f44ceSEd Maste     return nullptr;
609f2f44ceSEd Maste   }
619f2f44ceSEd Maste }
62