Index: lldb/trunk/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp =================================================================== --- lldb/trunk/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp +++ lldb/trunk/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp @@ -220,6 +220,8 @@ context_start = full.rfind(' ', template_start); if (context_start == llvm::StringRef::npos) context_start = 0; + else + ++context_start; context_end = full.rfind(':', template_start); if (context_end == llvm::StringRef::npos || context_end < context_start) @@ -240,7 +242,7 @@ else { if (context_start < context_end) - m_context = full.substr(context_start, context_end - 1); + m_context = full.substr(context_start, context_end - 1 - context_start); const size_t basename_begin = context_end + 1; m_basename = full.substr(basename_begin, basename_end - basename_begin); } Index: lldb/trunk/unittests/CMakeLists.txt =================================================================== --- lldb/trunk/unittests/CMakeLists.txt +++ lldb/trunk/unittests/CMakeLists.txt @@ -43,6 +43,7 @@ add_subdirectory(Expression) add_subdirectory(Host) add_subdirectory(Interpreter) +add_subdirectory(Language) add_subdirectory(Process) add_subdirectory(ScriptInterpreter) add_subdirectory(Symbol) Index: lldb/trunk/unittests/Language/CMakeLists.txt =================================================================== --- lldb/trunk/unittests/Language/CMakeLists.txt +++ lldb/trunk/unittests/Language/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(CPlusPlus) Index: lldb/trunk/unittests/Language/CPlusPlus/CMakeLists.txt =================================================================== --- lldb/trunk/unittests/Language/CPlusPlus/CMakeLists.txt +++ lldb/trunk/unittests/Language/CPlusPlus/CMakeLists.txt @@ -0,0 +1,3 @@ +add_lldb_unittest(LanguageCPlusPlusTests + CPlusPlusLanguageTest.cpp + ) Index: lldb/trunk/unittests/Language/CPlusPlus/CPlusPlusLanguageTest.cpp =================================================================== --- lldb/trunk/unittests/Language/CPlusPlus/CPlusPlusLanguageTest.cpp +++ lldb/trunk/unittests/Language/CPlusPlus/CPlusPlusLanguageTest.cpp @@ -0,0 +1,41 @@ +//===-- CPlusPlusLanguageTest.cpp -------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "gtest/gtest.h" + +#include "Plugins/Language/CPlusPlus/CPlusPlusLanguage.h" + +using namespace lldb_private; + +TEST(CPlusPlusLanguage, MethodName) +{ + struct TestCase { + std::string input; + std::string context, basename, arguments, qualifiers, scope_qualified_name; + }; + + TestCase test_cases[] = {{"foo::bar(baz)", "foo", "bar", "(baz)", "", "foo::bar"}, + {"std::basic_ostream >& " + "std::operator<< >" + "(std::basic_ostream >&, char const*)", + "std", "operator<< >", + "(std::basic_ostream >&, char const*)", "", + "std::operator<< >"}}; + + for (const auto &test: test_cases) + { + CPlusPlusLanguage::MethodName method(ConstString(test.input)); + EXPECT_TRUE(method.IsValid()); + EXPECT_EQ(test.context, method.GetContext()); + EXPECT_EQ(test.basename, method.GetBasename()); + EXPECT_EQ(test.arguments, method.GetArguments()); + EXPECT_EQ(test.qualifiers, method.GetQualifiers()); + EXPECT_EQ(test.scope_qualified_name, method.GetScopeQualifiedName()); + } +}