[Lldb-commits] [PATCH] D82109: [lldb] Reactivate Objective-C++ plugin

Raphael Isemann via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Fri Jun 19 10:20:11 PDT 2020


This revision was automatically updated to reflect the committed changes.
Closed by commit rG8340fbb9c7bc: [lldb] Reactivate Objective-C++ plugin (authored by teemperor).
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82109/new/

https://reviews.llvm.org/D82109

Files:
  lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
  lldb/unittests/Language/CLanguages/CLanguagesTest.cpp
  lldb/unittests/Language/CLanguages/CMakeLists.txt
  lldb/unittests/Language/CMakeLists.txt
  lldb/unittests/Language/Highlighting/HighlighterTest.cpp


Index: lldb/unittests/Language/Highlighting/HighlighterTest.cpp
===================================================================
--- lldb/unittests/Language/Highlighting/HighlighterTest.cpp
+++ lldb/unittests/Language/Highlighting/HighlighterTest.cpp
@@ -58,6 +58,8 @@
   EXPECT_EQ(getName("a/dir.CC"), "clang");
   EXPECT_EQ(getName("/a/dir.hpp"), "clang");
   EXPECT_EQ(getName("header.h"), "clang");
+  EXPECT_EQ(getName("foo.m"), "clang");
+  EXPECT_EQ(getName("foo.mm"), "clang");
 
   EXPECT_EQ(getName(""), "none");
   EXPECT_EQ(getName("/dev/null"), "none");
Index: lldb/unittests/Language/CMakeLists.txt
===================================================================
--- lldb/unittests/Language/CMakeLists.txt
+++ lldb/unittests/Language/CMakeLists.txt
@@ -1,2 +1,3 @@
 add_subdirectory(CPlusPlus)
+add_subdirectory(CLanguages)
 add_subdirectory(Highlighting)
Index: lldb/unittests/Language/CLanguages/CMakeLists.txt
===================================================================
--- /dev/null
+++ lldb/unittests/Language/CLanguages/CMakeLists.txt
@@ -0,0 +1,8 @@
+add_lldb_unittest(LanguageCLanguagesTests
+  CLanguagesTest.cpp
+
+  LINK_LIBS
+    lldbPluginCPlusPlusLanguage
+    lldbPluginObjCLanguage
+    lldbPluginObjCPlusPlusLanguage
+)
Index: lldb/unittests/Language/CLanguages/CLanguagesTest.cpp
===================================================================
--- /dev/null
+++ lldb/unittests/Language/CLanguages/CLanguagesTest.cpp
@@ -0,0 +1,46 @@
+//===-- CLanguagesTest.cpp ------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "Plugins/Language/CPlusPlus/CPlusPlusLanguage.h"
+#include "Plugins/Language/ObjC/ObjCLanguage.h"
+#include "Plugins/Language/ObjCPlusPlus/ObjCPlusPlusLanguage.h"
+#include "TestingSupport/SubsystemRAII.h"
+#include "lldb/lldb-enumerations.h"
+
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+using namespace lldb_private;
+
+/// Returns the name of the LLDB plugin for the given language or a null
+/// ConstString if there is no fitting plugin.
+static ConstString GetPluginName(lldb::LanguageType language) {
+  Language *language_plugin = Language::FindPlugin(language);
+  if (language_plugin)
+    return language_plugin->GetPluginName();
+  return ConstString();
+}
+
+TEST(CLanguages, LookupCLanguagesByLanguageType) {
+  SubsystemRAII<CPlusPlusLanguage, ObjCPlusPlusLanguage, ObjCLanguage> langs;
+
+  // There is no plugin to find for C.
+  EXPECT_EQ(Language::FindPlugin(lldb::eLanguageTypeC), nullptr);
+  EXPECT_EQ(Language::FindPlugin(lldb::eLanguageTypeC89), nullptr);
+  EXPECT_EQ(Language::FindPlugin(lldb::eLanguageTypeC99), nullptr);
+  EXPECT_EQ(Language::FindPlugin(lldb::eLanguageTypeC11), nullptr);
+
+  EXPECT_EQ(GetPluginName(lldb::eLanguageTypeC_plus_plus), "cplusplus");
+  EXPECT_EQ(GetPluginName(lldb::eLanguageTypeC_plus_plus_03), "cplusplus");
+  EXPECT_EQ(GetPluginName(lldb::eLanguageTypeC_plus_plus_11), "cplusplus");
+  EXPECT_EQ(GetPluginName(lldb::eLanguageTypeC_plus_plus_14), "cplusplus");
+
+  EXPECT_EQ(GetPluginName(lldb::eLanguageTypeObjC), "objc");
+
+  EXPECT_EQ(GetPluginName(lldb::eLanguageTypeObjC_plus_plus), "objcplusplus");
+}
Index: lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
===================================================================
--- lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
+++ lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
@@ -70,7 +70,9 @@
 // Static Functions
 
 Language *CPlusPlusLanguage::CreateInstance(lldb::LanguageType language) {
-  if (Language::LanguageIsCPlusPlus(language))
+  // Use plugin for C++ but not for Objective-C++ (which has its own plugin).
+  if (Language::LanguageIsCPlusPlus(language) &&
+      language != eLanguageTypeObjC_plus_plus)
     return new CPlusPlusLanguage();
   return nullptr;
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D82109.272128.patch
Type: text/x-patch
Size: 4124 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20200619/9e241978/attachment.bin>


More information about the lldb-commits mailing list