2015-08-25 07:46:31 +08:00
|
|
|
//===-- CompilerDeclContext.cpp ---------------------------------*- C++ -*-===//
|
|
|
|
//
|
2019-01-19 16:50:56 +08:00
|
|
|
// 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
|
2015-08-25 07:46:31 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "lldb/Symbol/CompilerDeclContext.h"
|
2015-09-16 07:44:17 +08:00
|
|
|
#include "lldb/Symbol/CompilerDecl.h"
|
2015-08-25 07:46:31 +08:00
|
|
|
#include "lldb/Symbol/TypeSystem.h"
|
2015-09-16 07:44:17 +08:00
|
|
|
#include <vector>
|
2015-08-25 07:46:31 +08:00
|
|
|
|
|
|
|
using namespace lldb_private;
|
|
|
|
|
2015-09-16 07:44:17 +08:00
|
|
|
std::vector<CompilerDecl>
|
2016-09-07 04:57:50 +08:00
|
|
|
CompilerDeclContext::FindDeclByName(ConstString name,
|
|
|
|
const bool ignore_using_decls) {
|
|
|
|
if (IsValid())
|
|
|
|
return m_type_system->DeclContextFindDeclByName(m_opaque_decl_ctx, name,
|
|
|
|
ignore_using_decls);
|
|
|
|
else
|
|
|
|
return std::vector<CompilerDecl>();
|
2015-09-16 07:44:17 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
bool CompilerDeclContext::IsClang() const {
|
|
|
|
return IsValid() && m_type_system->getKind() == TypeSystem::eKindClang;
|
2015-08-25 07:46:31 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
ConstString CompilerDeclContext::GetName() const {
|
|
|
|
if (IsValid())
|
|
|
|
return m_type_system->DeclContextGetName(m_opaque_decl_ctx);
|
|
|
|
else
|
|
|
|
return ConstString();
|
2015-08-25 07:46:31 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
ConstString CompilerDeclContext::GetScopeQualifiedName() const {
|
|
|
|
if (IsValid())
|
|
|
|
return m_type_system->DeclContextGetScopeQualifiedName(m_opaque_decl_ctx);
|
|
|
|
else
|
|
|
|
return ConstString();
|
Better scheme to lookup alternate mangled name when looking up function address.
Summary:
This change is relevant for inferiors compiled with GCC. GCC does not
emit complete debug info for std::basic_string<...>, and consequently, Clang
(the LLDB compiler) does not generate correct mangled names for certain
functions.
This change removes the hard-coded alternate names in
ItaniumABILanguageRuntime.cpp.
Before the hard-coded names were put in ItaniumABILanguageRuntime.cpp, one could
not evaluate std::string methods (ex. std::string::length). After putting in
the hard-coded names, one could evaluate them. However, it did not still
enable one to call methods on, say for example, std::vector<string>.
This change makes that possible.
There is some amount of incompleteness in this change. Consider the
following example:
std::string hello("hello"), world("world");
std::map<std::string, std::string> m;
m[hello] = world;
One can still not evaluate the expression "m[hello]" in LLDB. Will
address this issue in another pass.
Reviewers: jingham, vharron, evgeny777, spyffe, dawn
Subscribers: clayborg, dawn, lldb-commits
Differential Revision: http://reviews.llvm.org/D12809
llvm-svn: 257113
2016-01-08 07:32:34 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
bool CompilerDeclContext::IsStructUnionOrClass() const {
|
|
|
|
if (IsValid())
|
|
|
|
return m_type_system->DeclContextIsStructUnionOrClass(m_opaque_decl_ctx);
|
|
|
|
else
|
|
|
|
return false;
|
2015-08-25 07:46:31 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
bool CompilerDeclContext::IsClassMethod(lldb::LanguageType *language_ptr,
|
|
|
|
bool *is_instance_method_ptr,
|
|
|
|
ConstString *language_object_name_ptr) {
|
|
|
|
if (IsValid())
|
|
|
|
return m_type_system->DeclContextIsClassMethod(
|
|
|
|
m_opaque_decl_ctx, language_ptr, is_instance_method_ptr,
|
|
|
|
language_object_name_ptr);
|
|
|
|
else
|
|
|
|
return false;
|
2015-08-25 07:46:31 +08:00
|
|
|
}
|
|
|
|
|
2019-03-12 15:45:04 +08:00
|
|
|
bool CompilerDeclContext::IsContainedInLookup(CompilerDeclContext other) const {
|
|
|
|
if (!IsValid())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
// If the other context is just the current context, we don't need to go
|
|
|
|
// over the type system to know that the lookup is identical.
|
|
|
|
if (this == &other)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return m_type_system->DeclContextIsContainedInLookup(m_opaque_decl_ctx,
|
|
|
|
other.m_opaque_decl_ctx);
|
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
bool lldb_private::operator==(const lldb_private::CompilerDeclContext &lhs,
|
|
|
|
const lldb_private::CompilerDeclContext &rhs) {
|
|
|
|
return lhs.GetTypeSystem() == rhs.GetTypeSystem() &&
|
|
|
|
lhs.GetOpaqueDeclContext() == rhs.GetOpaqueDeclContext();
|
2015-08-25 07:46:31 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
bool lldb_private::operator!=(const lldb_private::CompilerDeclContext &lhs,
|
|
|
|
const lldb_private::CompilerDeclContext &rhs) {
|
|
|
|
return lhs.GetTypeSystem() != rhs.GetTypeSystem() ||
|
|
|
|
lhs.GetOpaqueDeclContext() != rhs.GetOpaqueDeclContext();
|
2015-08-25 07:46:31 +08:00
|
|
|
}
|