Skip to content

Commit 72787e0

Browse files
committed
[lldb] Fix latent compiler warnings
(cherry picked from commit 93587f5)
1 parent b910651 commit 72787e0

15 files changed

+49
-31
lines changed

lldb/source/Plugins/Language/Swift/SwiftFormatters.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1002,10 +1002,10 @@ void PrintMatrix(Stream &stream,
10021002
int num_columns, int num_rows) {
10031003
// Print each row.
10041004
stream.Printf("\n[ ");
1005-
for (unsigned J = 0; J < num_rows; ++J) {
1005+
for (int J = 0; J < num_rows; ++J) {
10061006
// Join the J-th row's elements with commas.
10071007
std::vector<std::string> row;
1008-
for (unsigned I = 0; I < num_columns; ++I)
1008+
for (int I = 0; I < num_columns; ++I)
10091009
row.emplace_back(std::move(matrix[I][J]));
10101010
std::string joined = llvm::join(row, ", ");
10111011

@@ -1072,14 +1072,14 @@ bool lldb_private::formatters::swift::SIMDVector_SummaryProvider(
10721072
ConstString full_type_name = simd_type.GetTypeName();
10731073
llvm::StringRef type_name = full_type_name.GetStringRef();
10741074
uint64_t num_elements = type_size / arg_size;
1075-
int generic_pos = type_name.find("<");
1075+
auto generic_pos = type_name.find("<");
10761076
if (generic_pos != llvm::StringRef::npos)
10771077
type_name = type_name.slice(0, generic_pos);
10781078
if (type_name == "Swift.SIMD3")
10791079
num_elements = 3;
10801080

10811081
std::vector<std::string> elem_vector;
1082-
for (int i = 0; i < num_elements; ++i) {
1082+
for (uint64_t i = 0; i < num_elements; ++i) {
10831083
DataExtractor elem_extractor(storage_buf, i * arg_size, arg_size);
10841084
auto simd_elem = ValueObject::CreateValueObjectFromData(
10851085
"simd_elem", elem_extractor, valobj.GetExecutionContextRef(), arg_type);

lldb/source/Plugins/Language/Swift/SwiftUnsafeTypes.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ class SwiftUnsafeType {
3030
UnsafePointerKind GetKind() const { return m_kind; }
3131
virtual bool Update() = 0;
3232

33+
virtual ~SwiftUnsafeType() = default;
34+
3335
protected:
3436
SwiftUnsafeType(ValueObject &valobj, UnsafePointerKind kind);
3537
addr_t GetAddress(llvm::StringRef child_name);
@@ -531,7 +533,7 @@ bool lldb_private::formatters::swift::UnsafeTypeSyntheticFrontEnd::Update() {
531533

532534
for (size_t i = 0; i < num_children; i++) {
533535
StreamString idx_name;
534-
idx_name.Printf("[%" PRIu64 "]", i);
536+
idx_name.Printf("[%zu]", i);
535537
DataExtractor data(buffer_data, i * m_element_stride, m_element_stride);
536538
m_children.push_back(CreateValueObjectFromData(
537539
idx_name.GetString(), data, m_exe_ctx_ref, element_type));

lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ class ObjectFileELF : public lldb_private::ObjectFile {
394394
std::shared_ptr<ObjectFileELF> GetGnuDebugDataObjectFile();
395395

396396
llvm::StringRef
397-
GetReflectionSectionIdentifier(swift::ReflectionSectionKind section);
397+
GetReflectionSectionIdentifier(swift::ReflectionSectionKind section) override;
398398
};
399399

400400
#endif // LLDB_SOURCE_PLUGINS_OBJECTFILE_ELF_OBJECTFILEELF_H

lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ class ObjectFileMachO : public lldb_private::ObjectFile {
208208
bool SectionIsLoadable(const lldb_private::Section *section);
209209

210210
llvm::StringRef
211-
GetReflectionSectionIdentifier(swift::ReflectionSectionKind section);
211+
GetReflectionSectionIdentifier(swift::ReflectionSectionKind section) override;
212212

213213
llvm::MachO::mach_header m_header;
214214
static lldb_private::ConstString GetSegmentNameTEXT();

lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ class ObjectFilePECOFF : public lldb_private::ObjectFile {
287287
const section_header_t &sect);
288288

289289
llvm::StringRef
290-
GetReflectionSectionIdentifier(swift::ReflectionSectionKind section);
290+
GetReflectionSectionIdentifier(swift::ReflectionSectionKind section) override;
291291

292292
typedef std::vector<section_header_t> SectionHeaderColl;
293293
typedef SectionHeaderColl::iterator SectionHeaderCollIter;

lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ void ManualDWARFIndex::Index() {
8383
// done indexing to make sure we don't pull in all DWARF dies, but we need
8484
// to wait until all compile units have been indexed in case a DIE in one
8585
// compile unit refers to another and the indexes accesses those DIEs.
86-
for (int i=0; i<units_to_index.size(); ++i)
87-
extract_fn(i);
86+
for (size_t i = 0; i < units_to_index.size(); ++i)
87+
extract_fn(i);
8888
// This call can deadlock because we are sometimes holding the module lock.
8989
// for (size_t i = 0; i < units_to_index.size(); ++i)
9090
// pool.async(extract_fn, i);

lldb/source/Plugins/TypeSystem/Swift/SwiftASTContext.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1266,8 +1266,6 @@ static const char *getImportFailureString(swift::serialization::Status status) {
12661266
case swift::serialization::Status::TargetTooNew:
12671267
return "The module file was built for a target newer than the current "
12681268
"target.";
1269-
default:
1270-
return "An unknown error occurred.";
12711269
}
12721270
}
12731271

@@ -2954,8 +2952,6 @@ class SwiftDWARFImporterDelegate : public swift::DWARFImporterDelegate {
29542952
// Not implemented since Objective-C protocols aren't yet
29552953
// described in DWARF.
29562954
return true;
2957-
default:
2958-
return true;
29592955
}
29602956
}
29612957

@@ -3170,7 +3166,7 @@ class SwiftDWARFImporterDelegate : public swift::DWARFImporterDelegate {
31703166
if (results.size())
31713167
break;
31723168
}
3173-
LOG_PRINTF(LIBLLDB_LOG_TYPES, "%d types collected.", results.size());
3169+
LOG_PRINTF(LIBLLDB_LOG_TYPES, "%zu types collected.", results.size());
31743170
return;
31753171
}
31763172

@@ -3201,7 +3197,7 @@ class SwiftDWARFImporterDelegate : public swift::DWARFImporterDelegate {
32013197
return true;
32023198
});
32033199

3204-
LOG_PRINTF(LIBLLDB_LOG_TYPES, "%d types from debug info.", results.size());
3200+
LOG_PRINTF(LIBLLDB_LOG_TYPES, "%zu types from debug info.", results.size());
32053201
}
32063202
};
32073203
} // namespace lldb_private
@@ -3529,8 +3525,7 @@ swift::ModuleDecl *SwiftASTContext::GetModule(const SourceModule &module,
35293525
}
35303526

35313527
if (!module_decl) {
3532-
LOG_PRINTF(LIBLLDB_LOG_TYPES, "failed with no error",
3533-
module.path.front().GetCString());
3528+
LOG_PRINTF(LIBLLDB_LOG_TYPES, "failed with no error");
35343529

35353530
error.SetErrorStringWithFormat(
35363531
"failed to get module \"%s\" from AST context",
@@ -6815,7 +6810,7 @@ static llvm::Optional<uint64_t> GetInstanceVariableOffset_Metadata(
68156810
llvm::Optional<uint64_t> offset = runtime->GetMemberVariableOffset(
68166811
type, valobj, ConstString(ivar_name), &error);
68176812
if (offset)
6818-
LOG_PRINTF(LIBLLDB_LOG_TYPES, "for %s: %lu", ivar_name.str().c_str(),
6813+
LOG_PRINTF(LIBLLDB_LOG_TYPES, "for %s: %llu", ivar_name.str().c_str(),
68196814
*offset);
68206815
else
68216816
LOG_PRINTF(LIBLLDB_LOG_TYPES, "resolver failure: %s", error.AsCString());
@@ -8110,10 +8105,16 @@ static void DescribeFileUnit(Stream &s, swift::FileUnit *file_unit) {
81108105
switch (source_file->Kind) {
81118106
case swift::SourceFileKind::Library:
81128107
s.PutCString("Library");
8108+
break;
81138109
case swift::SourceFileKind::Main:
81148110
s.PutCString("Main");
8111+
break;
81158112
case swift::SourceFileKind::SIL:
81168113
s.PutCString("SIL");
8114+
break;
8115+
case swift::SourceFileKind::Interface:
8116+
s.PutCString("Interface");
8117+
break;
81178118
}
81188119
}
81198120
} break;

lldb/source/Plugins/TypeSystem/Swift/SwiftASTContext.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -353,9 +353,10 @@ class SwiftASTContext : public TypeSystemSwift {
353353
swift::ClangImporter *GetClangImporter();
354354
swift::DWARFImporterDelegate *GetDWARFImporterDelegate();
355355

356-
CompilerType CreateTupleType(const std::vector<TupleElement> &elements);
356+
CompilerType
357+
CreateTupleType(const std::vector<TupleElement> &elements) override;
357358

358-
CompilerType GetErrorType();
359+
CompilerType GetErrorType() override;
359360

360361
bool HasErrors();
361362

lldb/source/Plugins/TypeSystem/Swift/TypeSystemSwift.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ class TypeSystemSwift : public TypeSystem {
109109
};
110110
virtual CompilerType
111111
CreateTupleType(const std::vector<TupleElement> &elements) = 0;
112+
using TypeSystem::DumpTypeDescription;
112113
virtual void DumpTypeDescription(
113114
lldb::opaque_compiler_type_t type, bool print_help_if_available,
114115
bool print_extensions_if_available,

lldb/source/Plugins/TypeSystem/Swift/TypeSystemSwiftTypeRef.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -558,15 +558,16 @@ GetNodeForPrinting(const std::string &m_description, lldb_private::Module &M,
558558
NodePointer args_ty = Dem.createNode(Node::Kind::Type);
559559
NodePointer args_tuple = Dem.createNode(Node::Kind::Tuple);
560560
for (NodePointer child : *node) {
561-
if (child->getKind() == Node::Kind::ImplParameter)
561+
if (child->getKind() == Node::Kind::ImplParameter) {
562562
for (NodePointer type : *node)
563563
if (type->getKind() == Node::Kind::Type &&
564564
type->getNumChildren() == 1)
565565
rett->addChild(type->getChild(0), Dem);
566-
else if (child->getKind() == Node::Kind::ImplResult)
566+
} else if (child->getKind() == Node::Kind::ImplResult) {
567567
for (NodePointer type : *node)
568568
if (type->getKind() == Node::Kind::Type)
569569
rett->addChild(type, Dem);
570+
}
570571
}
571572
args_ty->addChild(args_tuple, Dem);
572573
args->addChild(args_ty, Dem);
@@ -736,7 +737,6 @@ static uint32_t collectTypeInfo(Module *M, swift::Demangle::Demangler &Dem,
736737
// Bug-for-bug-compatibility. Not sure if this is correct.
737738
swift_flags |= eTypeIsPointer | eTypeHasValue;
738739
return swift_flags;
739-
LLVM_FALLTHROUGH;
740740
case Node::Kind::BoundGenericFunction:
741741
swift_flags |= eTypeIsGeneric | eTypeIsBound;
742742
LLVM_FALLTHROUGH;

lldb/source/Symbol/ObjectFile.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -755,6 +755,7 @@ void llvm::format_provider<ObjectFile::Strata>::format(
755755

756756
llvm::StringRef ObjectFile::GetReflectionSectionIdentifier(
757757
swift::ReflectionSectionKind section) {
758-
assert("Base class's GetReflectionSectionIdentifier should not be called");
758+
assert(false &&
759+
"Base class's GetReflectionSectionIdentifier should not be called");
759760
return "";
760761
}

lldb/source/Target/SwiftLanguageRuntime.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ void SwiftLanguageRuntimeImpl::SetupExclusivity() {
399399
Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
400400
if (log)
401401
log->Printf(
402-
"SwiftLanguageRuntime: _swift_disableExclusivityChecking = %lu",
402+
"SwiftLanguageRuntime: _swift_disableExclusivityChecking = %llu",
403403
m_dynamic_exclusivity_flag_addr ? *m_dynamic_exclusivity_flag_addr : 0);
404404
}
405405

@@ -574,6 +574,10 @@ static bool GetObjectDescription_ResultVariable(Process &process, Stream &str,
574574
log->Printf(
575575
"[GetObjectDescription_ResultVariable] eExpressionStoppedForDebug");
576576
break;
577+
case eExpressionThreadVanished:
578+
log->Printf(
579+
"[GetObjectDescription_ResultVariable] eExpressionThreadVanished");
580+
break;
577581
}
578582
}
579583

@@ -681,6 +685,10 @@ static bool GetObjectDescription_ObjectReference(Process &process, Stream &str,
681685
log->Printf(
682686
"[GetObjectDescription_ObjectReference] eExpressionStoppedForDebug");
683687
break;
688+
case eExpressionThreadVanished:
689+
log->Printf(
690+
"[GetObjectDescription_ObjectReference] eExpressionThreadVanished");
691+
break;
684692
}
685693
}
686694

@@ -839,6 +847,10 @@ static bool GetObjectDescription_ObjectCopy(SwiftLanguageRuntimeImpl *runtime,
839847
log->Printf(
840848
"[GetObjectDescription_ObjectCopy] eExpressionStoppedForDebug");
841849
break;
850+
case eExpressionThreadVanished:
851+
log->Printf(
852+
"[GetObjectDescription_ObjectCopy] eExpressionThreadVanished");
853+
break;
842854
}
843855
}
844856

lldb/source/Target/SwiftLanguageRuntimeDynamicTypeResolution.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -849,7 +849,7 @@ bool SwiftLanguageRuntimeImpl::GetDynamicTypeAndAddress_Class(
849849
auto metadata_address = remote_ast.getHeapMetadataForObject(instance_address);
850850
if (!metadata_address) {
851851
if (log) {
852-
log->Printf("could not read heap metadata for object at %lu: %s\n",
852+
log->Printf("could not read heap metadata for object at %llu: %s\n",
853853
class_metadata_ptr,
854854
metadata_address.getFailure().render().c_str());
855855
}

lldb/source/Target/Target.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2211,7 +2211,7 @@ Target::GetScratchTypeSystemForLanguage(lldb::LanguageType language,
22112211
auto type_system_or_err = m_scratch_type_system_map.GetTypeSystemForLanguage(
22122212
language, this, create_on_demand, compiler_options);
22132213
if (!type_system_or_err)
2214-
return std::move(type_system_or_err.takeError());
2214+
return type_system_or_err.takeError();
22152215

22162216
#ifdef LLDB_ENABLE_SWIFT
22172217
if (language == eLanguageTypeSwift) {
@@ -2249,7 +2249,7 @@ Target::GetScratchTypeSystemForLanguage(lldb::LanguageType language,
22492249
type_system_or_err = m_scratch_type_system_map.GetTypeSystemForLanguage(
22502250
language, this, create_on_demand, compiler_options);
22512251
if (!type_system_or_err)
2252-
return std::move(type_system_or_err.takeError());
2252+
return type_system_or_err.takeError();
22532253

22542254
if (auto *new_swift_ast_ctx =
22552255
llvm::dyn_cast_or_null<SwiftASTContextForExpressions>(

lldb/source/Target/ThreadPlanCallFunction.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -496,8 +496,8 @@ bool ThreadPlanCallFunction::BreakpointsExplainStop() {
496496
#ifdef LLDB_ENABLE_SWIFT
497497
ConstString persistent_variable_name(
498498
persistent_state->GetNextPersistentVariableName(/*is_error*/ true));
499-
if (m_return_valobj_sp = SwiftLanguageRuntime::CalculateErrorValue(
500-
frame_sp, persistent_variable_name)) {
499+
if ((m_return_valobj_sp = SwiftLanguageRuntime::CalculateErrorValue(
500+
frame_sp, persistent_variable_name))) {
501501

502502
DataExtractor data;
503503
Status data_error;

0 commit comments

Comments
 (0)