Changeset View
Changeset View
Standalone View
Standalone View
lldb/source/Core/Mangled.cpp
//===-- Mangled.cpp -------------------------------------------------------===// | //===-- Mangled.cpp -------------------------------------------------------===// | ||||
// | // | ||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||||
// See https://llvm.org/LICENSE.txt for license information. | // See https://llvm.org/LICENSE.txt for license information. | ||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||||
// | // | ||||
//===----------------------------------------------------------------------===// | //===----------------------------------------------------------------------===// | ||||
#include "lldb/Core/Mangled.h" | #include "lldb/Core/Mangled.h" | ||||
#include "lldb/Core/RichManglingContext.h" | #include "lldb/Core/RichManglingContext.h" | ||||
#include "lldb/Target/Language.h" | |||||
xiaobai: Not happy about introducing this dependency. Maybe I can remove the `GuessLanguage` method from… | |||||
#include "lldb/Utility/ConstString.h" | #include "lldb/Utility/ConstString.h" | ||||
#include "lldb/Utility/Log.h" | #include "lldb/Utility/Log.h" | ||||
#include "lldb/Utility/Logging.h" | #include "lldb/Utility/Logging.h" | ||||
#include "lldb/Utility/RegularExpression.h" | #include "lldb/Utility/RegularExpression.h" | ||||
#include "lldb/Utility/Stream.h" | #include "lldb/Utility/Stream.h" | ||||
#include "lldb/Utility/Timer.h" | #include "lldb/Utility/Timer.h" | ||||
#include "lldb/lldb-enumerations.h" | #include "lldb/lldb-enumerations.h" | ||||
▲ Show 20 Lines • Show All 385 Lines • ▼ Show 20 Lines | |||||
// Itanium scheme, and defined in a compilation unit within the same module as | // Itanium scheme, and defined in a compilation unit within the same module as | ||||
// other C++ units. In addition, different targets could have different ways | // other C++ units. In addition, different targets could have different ways | ||||
// of mangling names from a given language, likewise the compilation units | // of mangling names from a given language, likewise the compilation units | ||||
// within those targets. | // within those targets. | ||||
lldb::LanguageType Mangled::GuessLanguage() const { | lldb::LanguageType Mangled::GuessLanguage() const { | ||||
ConstString mangled = GetMangledName(); | ConstString mangled = GetMangledName(); | ||||
if (mangled) { | if (mangled) { | ||||
const char *mangled_name = mangled.GetCString(); | lldb::LanguageType lang_type = lldb::eLanguageTypeUnknown; | ||||
if (CPlusPlusLanguage::IsCPPMangledName(mangled_name)) | Language::ForEach([&lang_type, &mangled](Language *lang) { | ||||
return lldb::eLanguageTypeC_plus_plus; | if (lang->IsMangledName(mangled.GetCString())) { | ||||
else if (ObjCLanguage::IsPossibleObjCMethodName(mangled_name)) | lang_type = lang->GetLanguageType(); | ||||
kwkUnsubmitted Not Done ReplyInline ActionsIn the ObjCLanguage's implementation of IsMangledName() I hope to see a call to sPossibleObjCMethodName. I think that is what @friss is aiming for with D74187#1865342. kwk: In the `ObjCLanguage`'s implementation of `IsMangledName()` I hope to see a call to… | |||||
return lldb::eLanguageTypeObjC; | return false; // Break out of ForEach early | ||||
} | |||||
return true; | |||||
}); | |||||
return lang_type; | |||||
} else { | } else { | ||||
// ObjC names aren't really mangled, so they won't necessarily be in the | // ObjC names aren't really mangled, so they won't necessarily be in the | ||||
// mangled name slot. | // mangled name slot. | ||||
ConstString demangled_name = GetDemangledName(); | ConstString demangled_name = GetDemangledName(); | ||||
if (demangled_name | if (demangled_name | ||||
&& ObjCLanguage::IsPossibleObjCMethodName(demangled_name.GetCString())) | && ObjCLanguage::IsPossibleObjCMethodName(demangled_name.GetCString())) | ||||
return lldb::eLanguageTypeObjC; | return lldb::eLanguageTypeObjC; | ||||
Show All 16 Lines |
Not happy about introducing this dependency. Maybe I can remove the GuessLanguage method from Mangled and add one to Language... something like Language::GuessMangledSymbolLanguage(Mangled mangled)?