Skip to content

[lldb] Fix latent compiler warnings #1779

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
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
8 changes: 4 additions & 4 deletions lldb/source/Plugins/Language/Swift/SwiftFormatters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1002,10 +1002,10 @@ void PrintMatrix(Stream &stream,
int num_columns, int num_rows) {
// Print each row.
stream.Printf("\n[ ");
for (unsigned J = 0; J < num_rows; ++J) {
for (int J = 0; J < num_rows; ++J) {
// Join the J-th row's elements with commas.
std::vector<std::string> row;
for (unsigned I = 0; I < num_columns; ++I)
for (int I = 0; I < num_columns; ++I)
row.emplace_back(std::move(matrix[I][J]));
std::string joined = llvm::join(row, ", ");

Expand Down Expand Up @@ -1072,14 +1072,14 @@ bool lldb_private::formatters::swift::SIMDVector_SummaryProvider(
ConstString full_type_name = simd_type.GetTypeName();
llvm::StringRef type_name = full_type_name.GetStringRef();
uint64_t num_elements = type_size / arg_size;
int generic_pos = type_name.find("<");
auto generic_pos = type_name.find("<");
if (generic_pos != llvm::StringRef::npos)
type_name = type_name.slice(0, generic_pos);
if (type_name == "Swift.SIMD3")
num_elements = 3;

std::vector<std::string> elem_vector;
for (int i = 0; i < num_elements; ++i) {
for (uint64_t i = 0; i < num_elements; ++i) {
DataExtractor elem_extractor(storage_buf, i * arg_size, arg_size);
auto simd_elem = ValueObject::CreateValueObjectFromData(
"simd_elem", elem_extractor, valobj.GetExecutionContextRef(), arg_type);
Expand Down
4 changes: 3 additions & 1 deletion lldb/source/Plugins/Language/Swift/SwiftUnsafeTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ class SwiftUnsafeType {
UnsafePointerKind GetKind() const { return m_kind; }
virtual bool Update() = 0;

virtual ~SwiftUnsafeType() = default;

protected:
SwiftUnsafeType(ValueObject &valobj, UnsafePointerKind kind);
addr_t GetAddress(llvm::StringRef child_name);
Expand Down Expand Up @@ -531,7 +533,7 @@ bool lldb_private::formatters::swift::UnsafeTypeSyntheticFrontEnd::Update() {

for (size_t i = 0; i < num_children; i++) {
StreamString idx_name;
idx_name.Printf("[%" PRIu64 "]", i);
idx_name.Printf("[%zu]", i);
DataExtractor data(buffer_data, i * m_element_stride, m_element_stride);
m_children.push_back(CreateValueObjectFromData(
idx_name.GetString(), data, m_exe_ctx_ref, element_type));
Expand Down
2 changes: 1 addition & 1 deletion lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ class ObjectFileELF : public lldb_private::ObjectFile {
std::shared_ptr<ObjectFileELF> GetGnuDebugDataObjectFile();

llvm::StringRef
GetReflectionSectionIdentifier(swift::ReflectionSectionKind section);
GetReflectionSectionIdentifier(swift::ReflectionSectionKind section) override;
};

#endif // LLDB_SOURCE_PLUGINS_OBJECTFILE_ELF_OBJECTFILEELF_H
2 changes: 1 addition & 1 deletion lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ class ObjectFileMachO : public lldb_private::ObjectFile {
bool SectionIsLoadable(const lldb_private::Section *section);

llvm::StringRef
GetReflectionSectionIdentifier(swift::ReflectionSectionKind section);
GetReflectionSectionIdentifier(swift::ReflectionSectionKind section) override;

llvm::MachO::mach_header m_header;
static lldb_private::ConstString GetSegmentNameTEXT();
Expand Down
2 changes: 1 addition & 1 deletion lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ class ObjectFilePECOFF : public lldb_private::ObjectFile {
const section_header_t &sect);

llvm::StringRef
GetReflectionSectionIdentifier(swift::ReflectionSectionKind section);
GetReflectionSectionIdentifier(swift::ReflectionSectionKind section) override;

typedef std::vector<section_header_t> SectionHeaderColl;
typedef SectionHeaderColl::iterator SectionHeaderCollIter;
Expand Down
4 changes: 2 additions & 2 deletions lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ void ManualDWARFIndex::Index() {
// done indexing to make sure we don't pull in all DWARF dies, but we need
// to wait until all compile units have been indexed in case a DIE in one
// compile unit refers to another and the indexes accesses those DIEs.
for (int i=0; i<units_to_index.size(); ++i)
extract_fn(i);
for (size_t i = 0; i < units_to_index.size(); ++i)
extract_fn(i);
// This call can deadlock because we are sometimes holding the module lock.
// for (size_t i = 0; i < units_to_index.size(); ++i)
// pool.async(extract_fn, i);
Expand Down
19 changes: 10 additions & 9 deletions lldb/source/Plugins/TypeSystem/Swift/SwiftASTContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1266,8 +1266,6 @@ static const char *getImportFailureString(swift::serialization::Status status) {
case swift::serialization::Status::TargetTooNew:
return "The module file was built for a target newer than the current "
"target.";
default:
return "An unknown error occurred.";
}
}

Expand Down Expand Up @@ -2954,8 +2952,6 @@ class SwiftDWARFImporterDelegate : public swift::DWARFImporterDelegate {
// Not implemented since Objective-C protocols aren't yet
// described in DWARF.
return true;
default:
return true;
}
}

Expand Down Expand Up @@ -3170,7 +3166,7 @@ class SwiftDWARFImporterDelegate : public swift::DWARFImporterDelegate {
if (results.size())
break;
}
LOG_PRINTF(LIBLLDB_LOG_TYPES, "%d types collected.", results.size());
LOG_PRINTF(LIBLLDB_LOG_TYPES, "%zu types collected.", results.size());
return;
}

Expand Down Expand Up @@ -3201,7 +3197,7 @@ class SwiftDWARFImporterDelegate : public swift::DWARFImporterDelegate {
return true;
});

LOG_PRINTF(LIBLLDB_LOG_TYPES, "%d types from debug info.", results.size());
LOG_PRINTF(LIBLLDB_LOG_TYPES, "%zu types from debug info.", results.size());
}
};
} // namespace lldb_private
Expand Down Expand Up @@ -3529,8 +3525,7 @@ swift::ModuleDecl *SwiftASTContext::GetModule(const SourceModule &module,
}

if (!module_decl) {
LOG_PRINTF(LIBLLDB_LOG_TYPES, "failed with no error",
module.path.front().GetCString());
LOG_PRINTF(LIBLLDB_LOG_TYPES, "failed with no error");

error.SetErrorStringWithFormat(
"failed to get module \"%s\" from AST context",
Expand Down Expand Up @@ -6815,7 +6810,7 @@ static llvm::Optional<uint64_t> GetInstanceVariableOffset_Metadata(
llvm::Optional<uint64_t> offset = runtime->GetMemberVariableOffset(
type, valobj, ConstString(ivar_name), &error);
if (offset)
LOG_PRINTF(LIBLLDB_LOG_TYPES, "for %s: %lu", ivar_name.str().c_str(),
LOG_PRINTF(LIBLLDB_LOG_TYPES, "for %s: %llu", ivar_name.str().c_str(),
*offset);
else
LOG_PRINTF(LIBLLDB_LOG_TYPES, "resolver failure: %s", error.AsCString());
Expand Down Expand Up @@ -8110,10 +8105,16 @@ static void DescribeFileUnit(Stream &s, swift::FileUnit *file_unit) {
switch (source_file->Kind) {
case swift::SourceFileKind::Library:
s.PutCString("Library");
break;
case swift::SourceFileKind::Main:
s.PutCString("Main");
break;
case swift::SourceFileKind::SIL:
s.PutCString("SIL");
break;
case swift::SourceFileKind::Interface:
s.PutCString("Interface");
break;
}
}
} break;
Expand Down
5 changes: 3 additions & 2 deletions lldb/source/Plugins/TypeSystem/Swift/SwiftASTContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -353,9 +353,10 @@ class SwiftASTContext : public TypeSystemSwift {
swift::ClangImporter *GetClangImporter();
swift::DWARFImporterDelegate *GetDWARFImporterDelegate();

CompilerType CreateTupleType(const std::vector<TupleElement> &elements);
CompilerType
CreateTupleType(const std::vector<TupleElement> &elements) override;

CompilerType GetErrorType();
CompilerType GetErrorType() override;

bool HasErrors();

Expand Down
1 change: 1 addition & 0 deletions lldb/source/Plugins/TypeSystem/Swift/TypeSystemSwift.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ class TypeSystemSwift : public TypeSystem {
};
virtual CompilerType
CreateTupleType(const std::vector<TupleElement> &elements) = 0;
using TypeSystem::DumpTypeDescription;
virtual void DumpTypeDescription(
lldb::opaque_compiler_type_t type, bool print_help_if_available,
bool print_extensions_if_available,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -558,15 +558,16 @@ GetNodeForPrinting(const std::string &m_description, lldb_private::Module &M,
NodePointer args_ty = Dem.createNode(Node::Kind::Type);
NodePointer args_tuple = Dem.createNode(Node::Kind::Tuple);
for (NodePointer child : *node) {
if (child->getKind() == Node::Kind::ImplParameter)
if (child->getKind() == Node::Kind::ImplParameter) {
for (NodePointer type : *node)
if (type->getKind() == Node::Kind::Type &&
type->getNumChildren() == 1)
rett->addChild(type->getChild(0), Dem);
else if (child->getKind() == Node::Kind::ImplResult)
} else if (child->getKind() == Node::Kind::ImplResult) {
for (NodePointer type : *node)
if (type->getKind() == Node::Kind::Type)
rett->addChild(type, Dem);
}
}
args_ty->addChild(args_tuple, Dem);
args->addChild(args_ty, Dem);
Expand Down Expand Up @@ -736,7 +737,6 @@ static uint32_t collectTypeInfo(Module *M, swift::Demangle::Demangler &Dem,
// Bug-for-bug-compatibility. Not sure if this is correct.
swift_flags |= eTypeIsPointer | eTypeHasValue;
return swift_flags;
LLVM_FALLTHROUGH;
case Node::Kind::BoundGenericFunction:
swift_flags |= eTypeIsGeneric | eTypeIsBound;
LLVM_FALLTHROUGH;
Expand Down
3 changes: 2 additions & 1 deletion lldb/source/Symbol/ObjectFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -755,6 +755,7 @@ void llvm::format_provider<ObjectFile::Strata>::format(

llvm::StringRef ObjectFile::GetReflectionSectionIdentifier(
swift::ReflectionSectionKind section) {
assert("Base class's GetReflectionSectionIdentifier should not be called");
assert(false &&
"Base class's GetReflectionSectionIdentifier should not be called");
return "";
}
14 changes: 13 additions & 1 deletion lldb/source/Target/SwiftLanguageRuntime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ void SwiftLanguageRuntimeImpl::SetupExclusivity() {
Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
if (log)
log->Printf(
"SwiftLanguageRuntime: _swift_disableExclusivityChecking = %lu",
"SwiftLanguageRuntime: _swift_disableExclusivityChecking = %llu",
m_dynamic_exclusivity_flag_addr ? *m_dynamic_exclusivity_flag_addr : 0);
}

Expand Down Expand Up @@ -574,6 +574,10 @@ static bool GetObjectDescription_ResultVariable(Process &process, Stream &str,
log->Printf(
"[GetObjectDescription_ResultVariable] eExpressionStoppedForDebug");
break;
case eExpressionThreadVanished:
log->Printf(
"[GetObjectDescription_ResultVariable] eExpressionThreadVanished");
break;
}
}

Expand Down Expand Up @@ -681,6 +685,10 @@ static bool GetObjectDescription_ObjectReference(Process &process, Stream &str,
log->Printf(
"[GetObjectDescription_ObjectReference] eExpressionStoppedForDebug");
break;
case eExpressionThreadVanished:
log->Printf(
"[GetObjectDescription_ObjectReference] eExpressionThreadVanished");
break;
}
}

Expand Down Expand Up @@ -839,6 +847,10 @@ static bool GetObjectDescription_ObjectCopy(SwiftLanguageRuntimeImpl *runtime,
log->Printf(
"[GetObjectDescription_ObjectCopy] eExpressionStoppedForDebug");
break;
case eExpressionThreadVanished:
log->Printf(
"[GetObjectDescription_ObjectCopy] eExpressionThreadVanished");
break;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -849,7 +849,7 @@ bool SwiftLanguageRuntimeImpl::GetDynamicTypeAndAddress_Class(
auto metadata_address = remote_ast.getHeapMetadataForObject(instance_address);
if (!metadata_address) {
if (log) {
log->Printf("could not read heap metadata for object at %lu: %s\n",
log->Printf("could not read heap metadata for object at %llu: %s\n",
class_metadata_ptr,
metadata_address.getFailure().render().c_str());
}
Expand Down
4 changes: 2 additions & 2 deletions lldb/source/Target/Target.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2211,7 +2211,7 @@ Target::GetScratchTypeSystemForLanguage(lldb::LanguageType language,
auto type_system_or_err = m_scratch_type_system_map.GetTypeSystemForLanguage(
language, this, create_on_demand, compiler_options);
if (!type_system_or_err)
return std::move(type_system_or_err.takeError());
return type_system_or_err.takeError();

#ifdef LLDB_ENABLE_SWIFT
if (language == eLanguageTypeSwift) {
Expand Down Expand Up @@ -2249,7 +2249,7 @@ Target::GetScratchTypeSystemForLanguage(lldb::LanguageType language,
type_system_or_err = m_scratch_type_system_map.GetTypeSystemForLanguage(
language, this, create_on_demand, compiler_options);
if (!type_system_or_err)
return std::move(type_system_or_err.takeError());
return type_system_or_err.takeError();

if (auto *new_swift_ast_ctx =
llvm::dyn_cast_or_null<SwiftASTContextForExpressions>(
Expand Down
4 changes: 2 additions & 2 deletions lldb/source/Target/ThreadPlanCallFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -496,8 +496,8 @@ bool ThreadPlanCallFunction::BreakpointsExplainStop() {
#ifdef LLDB_ENABLE_SWIFT
ConstString persistent_variable_name(
persistent_state->GetNextPersistentVariableName(/*is_error*/ true));
if (m_return_valobj_sp = SwiftLanguageRuntime::CalculateErrorValue(
frame_sp, persistent_variable_name)) {
if ((m_return_valobj_sp = SwiftLanguageRuntime::CalculateErrorValue(
frame_sp, persistent_variable_name))) {

DataExtractor data;
Status data_error;
Expand Down