Skip to content

Various warning and compilation fixes for stable/20211026 #3541

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Nov 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions clang/include/indexstore/indexstore.h
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ typedef enum {
INDEXSTORE_SYMBOL_SUBKIND_ACCESSORSETTER = 4,
INDEXSTORE_SYMBOL_SUBKIND_USINGTYPENAME = 5,
INDEXSTORE_SYMBOL_SUBKIND_USINGVALUE = 6,
INDEXSTORE_SYMBOL_SUBKIND_USINGENUM = 7,

INDEXSTORE_SYMBOL_SUBKIND_SWIFTACCESSORWILLSET = 1000,
INDEXSTORE_SYMBOL_SUBKIND_SWIFTACCESSORDIDSET = 1001,
Expand Down
4 changes: 4 additions & 0 deletions clang/lib/Index/IndexDataStoreUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ SymbolSubKind index::getSymbolSubKind(indexstore_symbol_subkind_t K) {
return SymbolSubKind::UsingTypename;
case INDEXSTORE_SYMBOL_SUBKIND_USINGVALUE:
return SymbolSubKind::UsingValue;
case INDEXSTORE_SYMBOL_SUBKIND_USINGENUM:
return SymbolSubKind::UsingEnum;
case INDEXSTORE_SYMBOL_SUBKIND_SWIFTACCESSORWILLSET:
return SymbolSubKind::SwiftAccessorWillSet;
case INDEXSTORE_SYMBOL_SUBKIND_SWIFTACCESSORDIDSET:
Expand Down Expand Up @@ -377,6 +379,8 @@ indexstore_symbol_subkind_t index::getIndexStoreSubKind(SymbolSubKind K) {
return INDEXSTORE_SYMBOL_SUBKIND_USINGTYPENAME;
case SymbolSubKind::UsingValue:
return INDEXSTORE_SYMBOL_SUBKIND_USINGVALUE;
case SymbolSubKind::UsingEnum:
return INDEXSTORE_SYMBOL_SUBKIND_USINGENUM;
case SymbolSubKind::SwiftAccessorWillSet:
return INDEXSTORE_SYMBOL_SUBKIND_SWIFTACCESSORWILLSET;
case SymbolSubKind::SwiftAccessorDidSet:
Expand Down
2,997 changes: 1,961 additions & 1,036 deletions lldb/bindings/python/static-binding/LLDBWrapPython.cpp

Large diffs are not rendered by default.

1,016 changes: 878 additions & 138 deletions lldb/bindings/python/static-binding/lldb.py

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lldb/source/Core/ModuleList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ void ModuleList::FindFunctions(const RegularExpression &name,
if (keep_looking) {
end = dylinker_modules.end();
for (pos = dylinker_modules.begin(); pos != end; pos++)
(*pos)->FindFunctions(name, include_symbols, include_inlines, sc_list);
(*pos)->FindFunctions(name, options, sc_list);
}
// END SWIFT
}
Expand Down
9 changes: 5 additions & 4 deletions lldb/source/Core/SourceManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -350,11 +350,12 @@ static lldb_private::LineEntry FindEntryPoint(Module *exe_module) {
const ConstString entry_point_name = entry_point.first;
const bool skip_prologue = entry_point.second;
SymbolContextList sc_list;
bool symbols_okay = false; // Force it to be a debug symbol.
bool inlines_okay = true;
ModuleFunctionSearchOptions function_options;
function_options.include_symbols = false; // Force it to be a debug symbol
function_options.include_inlines = true;
exe_module->FindFunctions(entry_point_name, CompilerDeclContext(),
lldb::eFunctionNameTypeBase, inlines_okay,
symbols_okay, sc_list);
lldb::eFunctionNameTypeBase, function_options,
sc_list);
size_t num_matches = sc_list.GetSize();
for (size_t idx = 0; idx < num_matches; idx++) {
SymbolContext sc;
Expand Down
44 changes: 0 additions & 44 deletions lldb/source/Core/ValueObjectVariable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,50 +215,6 @@ bool ValueObjectVariable::UpdateValue() {

Process *process = exe_ctx.GetProcessPtr();
const bool process_is_alive = process && process->IsAlive();
const uint32_t type_info = compiler_type.GetTypeInfo();
const bool is_pointer_or_ref =
(type_info & (lldb::eTypeIsPointer | lldb::eTypeIsReference)) != 0;

switch (value_type) {
case Value::ValueType::FileAddress:
// If this type is a pointer, then its children will be considered load
// addresses if the pointer or reference is dereferenced, but only if
// the process is alive.
//
// There could be global variables like in the following code:
// struct LinkedListNode { Foo* foo; LinkedListNode* next; };
// Foo g_foo1;
// Foo g_foo2;
// LinkedListNode g_second_node = { &g_foo2, NULL };
// LinkedListNode g_first_node = { &g_foo1, &g_second_node };
//
// When we aren't running, we should be able to look at these variables
// using the "target variable" command. Children of the "g_first_node"
// always will be of the same address type as the parent. But children
// of the "next" member of LinkedListNode will become load addresses if
// we have a live process, or remain what a file address if it what a
// file address.
if (process_is_alive && is_pointer_or_ref)
SetAddressTypeOfChildren(eAddressTypeLoad);
else
SetAddressTypeOfChildren(eAddressTypeFile);
break;
case Value::ValueType::HostAddress:
// Same as above for load addresses, except children of pointer or refs
// are always load addresses. Host addresses are used to store freeze
// dried variables. If this type is a struct, the entire struct
// contents will be copied into the heap of the
// LLDB process, but we do not currently follow any pointers.
if (is_pointer_or_ref)
SetAddressTypeOfChildren(eAddressTypeLoad);
else
SetAddressTypeOfChildren(eAddressTypeHost);
break;
case Value::ValueType::LoadAddress:
case Value::ValueType::Scalar:
SetAddressTypeOfChildren(eAddressTypeLoad);
break;
}

#ifdef LLDB_ENABLE_SWIFT
if (auto type = variable->GetType())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1392,8 +1392,9 @@ bool SwiftASTManipulator::SaveExpressionTextToTempFile(
std::error_code err =
llvm::sys::fs::createTemporaryFile(prefix, suffix, temp_fd, buffer);
if (!err) {
lldb_private::NativeFile file(temp_fd, /*options*/ File::eOpenOptionWrite,
/*transfer_ownership*/ true);
lldb_private::NativeFile file(temp_fd,
/*options*/ File::eOpenOptionWriteOnly,
/*transfer_ownership*/ true);
const size_t text_len = text.size();
size_t bytes_written = text_len;
if (file.Write(text.data(), bytes_written).Success()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,7 @@ bool SwiftExpressionSourceCode::GetText(
if (auto process_sp = exe_ctx.GetProcessSP()) {
os_vers << getAvailabilityName(triple) << " ";
auto platform = target->GetPlatform();
bool is_simulator =
platform->GetPluginName().GetStringRef().endswith("-simulator");
bool is_simulator = platform->GetPluginName().endswith("-simulator");
if (is_simulator) {
// The simulators look like the host OS to Process, but Platform
// can the version out of an environment variable.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ namespace lldb_private {
static lldb_private::ConstString GetPluginNameStatic();

static lldb::InstrumentationRuntimeType GetTypeStatic();
lldb_private::ConstString GetPluginName() override {
return GetPluginNameStatic();

llvm::StringRef GetPluginName() override {
return GetPluginNameStatic().GetStringRef();
}

virtual lldb::InstrumentationRuntimeType GetType() { return GetTypeStatic(); }

lldb::ThreadCollectionSP
Expand Down
5 changes: 2 additions & 3 deletions lldb/source/Plugins/Language/Swift/SwiftFormatters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -277,17 +277,16 @@ bool lldb_private::formatters::swift::StringGuts_SummaryProvider(
return false;

uint64_t buffer[2] = {raw0, raw1};
DataExtractor data(buffer, count, process->GetByteOrder(), ptrSize);

StringPrinter::ReadBufferAndDumpToStreamOptions options(read_options);
options.SetData(data);
options.SetData(
DataExtractor(buffer, count, process->GetByteOrder(), ptrSize));
options.SetStream(&stream);
options.SetSourceSize(count);
options.SetBinaryZeroIsTerminator(false);
options.SetEscapeStyle(StringPrinter::EscapeStyle::Swift);
return StringPrinter::ReadBufferAndDumpToStream<
StringPrinter::StringElementType::UTF8>(options);

}

uint64_t count = raw0 & 0x0000FFFFFFFFFFFF;
Expand Down
25 changes: 10 additions & 15 deletions lldb/source/Plugins/Language/Swift/SwiftLanguage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,8 @@ lldb::TypeCategoryImplSP SwiftLanguage::GetFormatters() {
static TypeCategoryImplSP g_category;

std::call_once(g_initialize, [this]() -> void {
DataVisualization::Categories::GetCategory(GetPluginName(), g_category);
DataVisualization::Categories::GetCategory(ConstString(GetPluginName()),
g_category);
if (g_category) {
LoadSwiftFormatters(g_category);
LoadFoundationValueTypesFormatters(g_category);
Expand Down Expand Up @@ -1484,29 +1485,23 @@ void SwiftLanguage::GetExceptionResolverDescription(bool catch_on,
}

ConstString SwiftLanguage::GetDemangledFunctionNameWithoutArguments(Mangled mangled) const {
const char *mangled_name_cstr = mangled.GetMangledName().GetCString();
ConstString mangled_name = mangled.GetMangledName();
ConstString demangled_name = mangled.GetDemangledName();
if (demangled_name && mangled_name_cstr && mangled_name_cstr[0]) {
if (SwiftLanguageRuntime::IsSwiftMangledName(demangled.GetStringRef())) {
if (demangled_name && mangled_name) {
if (SwiftLanguageRuntime::IsSwiftMangledName(
demangled_name.GetStringRef())) {
lldb_private::ConstString basename;
bool is_method = false;
if (SwiftLanguageRuntime::MethodName::ExtractFunctionBasenameFromMangled(
mangled, basename, is_method)) {
if (basename && basename != mangled)
return basename);
mangled_name, basename, is_method)) {
if (basename && basename != mangled_name)
return basename;
}
}
}
if (demangled_name)
return demangled_name;
return mangled.GetMangledName();
}

//------------------------------------------------------------------
// PluginInterface protocol
//------------------------------------------------------------------
lldb_private::ConstString SwiftLanguage::GetPluginName() {
return GetPluginNameStatic();
return mangled_name;
}

//------------------------------------------------------------------
Expand Down
4 changes: 3 additions & 1 deletion lldb/source/Plugins/Language/Swift/SwiftLanguage.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,9 @@ class SwiftLanguage : public Language {
//------------------------------------------------------------------
// PluginInterface protocol
//------------------------------------------------------------------
virtual ConstString GetPluginName() override;
llvm::StringRef GetPluginName() override {
return GetPluginNameStatic().GetStringRef();
}
};

} // namespace lldb_private
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ AppleObjCRuntimeV2 *
SwiftLanguageRuntime::GetObjCRuntime(lldb_private::Process &process) {
if (auto objc_runtime = ObjCLanguageRuntime::Get(process)) {
if (objc_runtime->GetPluginName() ==
AppleObjCRuntimeV2::GetPluginNameStatic())
AppleObjCRuntimeV2::GetPluginNameStatic().GetStringRef())
return (AppleObjCRuntimeV2 *)objc_runtime;
}
return nullptr;
Expand Down Expand Up @@ -146,7 +146,7 @@ FindSymbolForSwiftObject(Process &process, RuntimeKind runtime_kind,
if (runtime_kind == RuntimeKind::ObjC) {
auto *obj_file = target.GetExecutableModule()->GetObjectFile();
bool have_objc_interop =
obj_file && obj_file->GetPluginName().GetStringRef().equals("mach-o");
obj_file && obj_file->GetPluginName().equals("mach-o");
if (!have_objc_interop)
return {};
}
Expand Down Expand Up @@ -626,7 +626,7 @@ bool SwiftLanguageRuntimeImpl::AddModuleToReflectionContext(

// When dealing with ELF, we need to pass in the contents of the on-disk
// file, since the Section Header Table is not present in the child process
if (obj_file->GetPluginName().GetStringRef().equals("elf")) {
if (obj_file->GetPluginName().equals("elf")) {
DataExtractor extractor;
auto size = obj_file->GetData(0, obj_file->GetByteSize(), extractor);
const uint8_t *file_data = extractor.GetDataStart();
Expand Down Expand Up @@ -2009,10 +2009,6 @@ lldb_private::ConstString SwiftLanguageRuntime::GetPluginNameStatic() {
return g_name;
}

lldb_private::ConstString SwiftLanguageRuntime::GetPluginName() {
return GetPluginNameStatic();
}

#define FORWARD(METHOD, ...) \
assert(m_impl || m_stub); \
return m_impl ? m_impl->METHOD(__VA_ARGS__) : m_stub->METHOD(__VA_ARGS__);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,9 @@ class SwiftLanguageRuntime : public LanguageRuntime {
/// \}

/// PluginInterface protocol.
lldb_private::ConstString GetPluginName() override;
llvm::StringRef GetPluginName() override {
return GetPluginNameStatic().GetStringRef();
}

bool GetObjectDescription(Stream &str, Value &value,
ExecutionContextScope *exe_scope) override {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ class ThreadPlanStepInAsync : public ThreadPlan {

bool StopOthers() override { return false; }

void WillPop() override {
void DidPop() override {
if (m_async_breakpoint_sp)
m_async_breakpoint_sp->GetTarget().RemoveBreakpointByID(
m_async_breakpoint_sp->GetID());
Expand Down Expand Up @@ -1105,9 +1105,12 @@ bool SwiftLanguageRuntime::GetTargetOfPartialApply(SymbolContext &curr_sc,
std::string apply_target =
demangle_ctx.getThunkTarget(apply_name.GetStringRef());
if (!apply_target.empty()) {
curr_sc.module_sp->FindFunctions(ConstString(apply_target), CompilerDeclContext(),
eFunctionNameTypeFull, true, false,
sc_list);
ModuleFunctionSearchOptions function_options;
function_options.include_symbols = true;
function_options.include_inlines = false;
curr_sc.module_sp->FindFunctions(
ConstString(apply_target), CompilerDeclContext(), eFunctionNameTypeFull,
function_options, sc_list);
size_t num_symbols = sc_list.GetSize();
if (num_symbols == 0)
return false;
Expand Down
Loading