Skip to content

Commit c4498ef

Browse files
authored
Merge pull request #1779 from apple/dl/lldb-Fix-latent-compiler-warnings-master-next
[lldb] Fix latent compiler warnings
2 parents 5120cc0 + 72787e0 commit c4498ef

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
@@ -1001,10 +1001,10 @@ void PrintMatrix(Stream &stream,
10011001
int num_columns, int num_rows) {
10021002
// Print each row.
10031003
stream.Printf("\n[ ");
1004-
for (unsigned J = 0; J < num_rows; ++J) {
1004+
for (int J = 0; J < num_rows; ++J) {
10051005
// Join the J-th row's elements with commas.
10061006
std::vector<std::string> row;
1007-
for (unsigned I = 0; I < num_columns; ++I)
1007+
for (int I = 0; I < num_columns; ++I)
10081008
row.emplace_back(std::move(matrix[I][J]));
10091009
std::string joined = llvm::join(row, ", ");
10101010

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

10781078
std::vector<std::string> elem_vector;
1079-
for (int i = 0; i < num_elements; ++i) {
1079+
for (uint64_t i = 0; i < num_elements; ++i) {
10801080
DataExtractor elem_extractor(storage_buf, i * arg_size, arg_size);
10811081
auto simd_elem = ValueObject::CreateValueObjectFromData(
10821082
"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
@@ -1263,8 +1263,6 @@ static const char *getImportFailureString(swift::serialization::Status status) {
12631263
case swift::serialization::Status::TargetTooNew:
12641264
return "The module file was built for a target newer than the current "
12651265
"target.";
1266-
default:
1267-
return "An unknown error occurred.";
12681266
}
12691267
}
12701268

@@ -2977,8 +2975,6 @@ class SwiftDWARFImporterDelegate : public swift::DWARFImporterDelegate {
29772975
// Not implemented since Objective-C protocols aren't yet
29782976
// described in DWARF.
29792977
return true;
2980-
default:
2981-
return true;
29822978
}
29832979
}
29842980

@@ -3193,7 +3189,7 @@ class SwiftDWARFImporterDelegate : public swift::DWARFImporterDelegate {
31933189
if (results.size())
31943190
break;
31953191
}
3196-
LOG_PRINTF(LIBLLDB_LOG_TYPES, "%d types collected.", results.size());
3192+
LOG_PRINTF(LIBLLDB_LOG_TYPES, "%zu types collected.", results.size());
31973193
return;
31983194
}
31993195

@@ -3224,7 +3220,7 @@ class SwiftDWARFImporterDelegate : public swift::DWARFImporterDelegate {
32243220
return true;
32253221
});
32263222

3227-
LOG_PRINTF(LIBLLDB_LOG_TYPES, "%d types from debug info.", results.size());
3223+
LOG_PRINTF(LIBLLDB_LOG_TYPES, "%zu types from debug info.", results.size());
32283224
}
32293225
};
32303226
} // namespace lldb_private
@@ -3553,8 +3549,7 @@ swift::ModuleDecl *SwiftASTContext::GetModule(const SourceModule &module,
35533549
}
35543550

35553551
if (!module_decl) {
3556-
LOG_PRINTF(LIBLLDB_LOG_TYPES, "failed with no error",
3557-
module.path.front().GetCString());
3552+
LOG_PRINTF(LIBLLDB_LOG_TYPES, "failed with no error");
35583553

35593554
error.SetErrorStringWithFormat(
35603555
"failed to get module \"%s\" from AST context",
@@ -6839,7 +6834,7 @@ static llvm::Optional<uint64_t> GetInstanceVariableOffset_Metadata(
68396834
llvm::Optional<uint64_t> offset = runtime->GetMemberVariableOffset(
68406835
type, valobj, ConstString(ivar_name), &error);
68416836
if (offset)
6842-
LOG_PRINTF(LIBLLDB_LOG_TYPES, "for %s: %lu", ivar_name.str().c_str(),
6837+
LOG_PRINTF(LIBLLDB_LOG_TYPES, "for %s: %llu", ivar_name.str().c_str(),
68436838
*offset);
68446839
else
68456840
LOG_PRINTF(LIBLLDB_LOG_TYPES, "resolver failure: %s", error.AsCString());
@@ -8139,10 +8134,16 @@ static void DescribeFileUnit(Stream &s, swift::FileUnit *file_unit) {
81398134
switch (source_file->Kind) {
81408135
case swift::SourceFileKind::Library:
81418136
s.PutCString("Library");
8137+
break;
81428138
case swift::SourceFileKind::Main:
81438139
s.PutCString("Main");
8140+
break;
81448141
case swift::SourceFileKind::SIL:
81458142
s.PutCString("SIL");
8143+
break;
8144+
case swift::SourceFileKind::Interface:
8145+
s.PutCString("Interface");
8146+
break;
81468147
}
81478148
}
81488149
} break;

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

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

364-
CompilerType CreateTupleType(const std::vector<TupleElement> &elements);
364+
CompilerType
365+
CreateTupleType(const std::vector<TupleElement> &elements) override;
365366

366-
CompilerType GetErrorType();
367+
CompilerType GetErrorType() override;
367368

368369
bool HasErrors();
369370

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ class TypeSystemSwift : public TypeSystem {
116116
};
117117
virtual CompilerType
118118
CreateTupleType(const std::vector<TupleElement> &elements) = 0;
119+
using TypeSystem::DumpTypeDescription;
119120
virtual void DumpTypeDescription(
120121
lldb::opaque_compiler_type_t type, bool print_help_if_available,
121122
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
@@ -586,15 +586,16 @@ swift::Demangle::NodePointer TypeSystemSwiftTypeRef::GetNodeForPrintingImpl(
586586
NodePointer args_ty = Dem.createNode(Node::Kind::Type);
587587
NodePointer args_tuple = Dem.createNode(Node::Kind::Tuple);
588588
for (NodePointer child : *node) {
589-
if (child->getKind() == Node::Kind::ImplParameter)
589+
if (child->getKind() == Node::Kind::ImplParameter) {
590590
for (NodePointer type : *node)
591591
if (type->getKind() == Node::Kind::Type &&
592592
type->getNumChildren() == 1)
593593
rett->addChild(type->getChild(0), Dem);
594-
else if (child->getKind() == Node::Kind::ImplResult)
594+
} else if (child->getKind() == Node::Kind::ImplResult) {
595595
for (NodePointer type : *node)
596596
if (type->getKind() == Node::Kind::Type)
597597
rett->addChild(type, Dem);
598+
}
598599
}
599600
args_ty->addChild(args_tuple, Dem);
600601
args->addChild(args_ty, Dem);
@@ -759,7 +760,6 @@ static uint32_t collectTypeInfo(Module *M, swift::Demangle::Demangler &Dem,
759760
// Bug-for-bug-compatibility. Not sure if this is correct.
760761
swift_flags |= eTypeIsPointer | eTypeHasValue;
761762
return swift_flags;
762-
LLVM_FALLTHROUGH;
763763
case Node::Kind::BoundGenericFunction:
764764
swift_flags |= eTypeIsGeneric | eTypeIsBound;
765765
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
@@ -400,7 +400,7 @@ void SwiftLanguageRuntimeImpl::SetupExclusivity() {
400400
Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
401401
if (log)
402402
log->Printf(
403-
"SwiftLanguageRuntime: _swift_disableExclusivityChecking = %lu",
403+
"SwiftLanguageRuntime: _swift_disableExclusivityChecking = %llu",
404404
m_dynamic_exclusivity_flag_addr ? *m_dynamic_exclusivity_flag_addr : 0);
405405
}
406406

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

@@ -682,6 +686,10 @@ static bool GetObjectDescription_ObjectReference(Process &process, Stream &str,
682686
log->Printf(
683687
"[GetObjectDescription_ObjectReference] eExpressionStoppedForDebug");
684688
break;
689+
case eExpressionThreadVanished:
690+
log->Printf(
691+
"[GetObjectDescription_ObjectReference] eExpressionThreadVanished");
692+
break;
685693
}
686694
}
687695

@@ -840,6 +848,10 @@ static bool GetObjectDescription_ObjectCopy(SwiftLanguageRuntimeImpl *runtime,
840848
log->Printf(
841849
"[GetObjectDescription_ObjectCopy] eExpressionStoppedForDebug");
842850
break;
851+
case eExpressionThreadVanished:
852+
log->Printf(
853+
"[GetObjectDescription_ObjectCopy] eExpressionThreadVanished");
854+
break;
843855
}
844856
}
845857

lldb/source/Target/SwiftLanguageRuntimeDynamicTypeResolution.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -949,7 +949,7 @@ bool SwiftLanguageRuntimeImpl::GetDynamicTypeAndAddress_Class(
949949
auto metadata_address = remote_ast.getHeapMetadataForObject(instance_address);
950950
if (!metadata_address) {
951951
if (log) {
952-
log->Printf("could not read heap metadata for object at %lu: %s\n",
952+
log->Printf("could not read heap metadata for object at %llu: %s\n",
953953
class_metadata_ptr,
954954
metadata_address.getFailure().render().c_str());
955955
}

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)