Skip to content

Gardening: Fix various recently introduced warnings #79099

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 5 commits into from
Feb 2, 2025
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
3 changes: 0 additions & 3 deletions lib/Frontend/ModuleInterfaceLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2250,9 +2250,6 @@ InterfaceSubContextDelegateImpl::runInSubCompilerInstance(StringRef moduleName,

info.BuildArguments = BuildArgs;
info.Hash = CacheHash;
auto target = *(std::find(BuildArgs.rbegin(), BuildArgs.rend(), "-target") - 1);
auto langVersion = *(std::find(BuildArgs.rbegin(), BuildArgs.rend(),
"-swift-version") - 1);

// Run the action under the sub compiler instance.
return action(info);
Expand Down
6 changes: 3 additions & 3 deletions lib/Macros/Sources/ObservationMacros/ObservableMacro.swift
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ public struct ObservationTrackedMacro: AccessorMacro {
return []
}

guard let container = context.lexicalContext[0].as(ClassDeclSyntax.self) else {
guard context.lexicalContext[0].as(ClassDeclSyntax.self) != nil else {
return []
}

Expand Down Expand Up @@ -406,11 +406,11 @@ extension ObservationTrackedMacro: PeerMacro {
) throws -> [DeclSyntax] {
guard let property = declaration.as(VariableDeclSyntax.self),
property.isValidForObservation,
let identifier = property.identifier?.trimmed else {
property.identifier?.trimmed != nil else {
return []
}

guard let container = context.lexicalContext[0].as(ClassDeclSyntax.self) else {
guard context.lexicalContext[0].as(ClassDeclSyntax.self) != nil else {
return []
}

Expand Down
7 changes: 7 additions & 0 deletions stdlib/public/Concurrency/Actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,13 @@ void swift::swift_task_reportUnexpectedExecutor(
.errorType = "actor-isolation-violation",
.currentStackDescription = "Actor-isolated function called from another thread",
.framesToSkip = 1,
.memoryAddress = nullptr,
.numExtraThreads = 0,
.threads = nullptr,
.numFixIts = 0,
.fixIts = nullptr,
.numNotes = 0,
.notes = nullptr,
};
_swift_reportToDebugger(
isFatalError ? RuntimeErrorFlagFatal : RuntimeErrorFlagNone, message,
Expand Down
3 changes: 3 additions & 0 deletions stdlib/public/Concurrency/DispatchGlobalExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ struct MinimalDispatchObjectHeader {

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wgnu-offsetof-extensions"
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
static_assert(
offsetof(Job, metadata) == offsetof(MinimalDispatchObjectHeader, VTable),
"Job Metadata field must match location of Dispatch VTable field.");
Expand All @@ -77,6 +79,7 @@ static_assert(offsetof(Job, SchedulerPrivate[Job::DispatchLinkageIndex]) ==
"Dispatch Linkage field must match Job "
"SchedulerPrivate[DispatchLinkageIndex].");
#pragma clang diagnostic pop
#pragma clang diagnostic pop

/// The function passed to dispatch_async_f to execute a job.
static void __swift_run_job(void *_job) {
Expand Down
3 changes: 3 additions & 0 deletions stdlib/public/Concurrency/ExecutorChecks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ static_assert((SwiftJobPriority)swift::JobPriority::Background
static_assert((SwiftJobPriority)swift::JobPriority::Unspecified
== SwiftUnspecifiedJobPriority);

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
// Job (has additional fields not exposed via SwiftJob)
static_assert(sizeof(swift::Job) >= sizeof(SwiftJob));
static_assert(offsetof(swift::Job, metadata) == offsetof(SwiftJob, metadata));
Expand All @@ -63,6 +65,7 @@ static_assert(offsetof(swift::Job, SchedulerPrivate) == offsetof(SwiftJob, sched
static_assert(offsetof(swift::Job, SchedulerPrivate[0]) == offsetof(SwiftJob, schedulerPrivate[0]));
static_assert(offsetof(swift::Job, SchedulerPrivate[1]) == offsetof(SwiftJob, schedulerPrivate[1]));
static_assert(offsetof(swift::Job, Flags) == offsetof(SwiftJob, flags));
#pragma clang diagnostic pop

// SerialExecutorRef
static_assert(sizeof(swift::SerialExecutorRef) == sizeof(SwiftExecutorRef));
Expand Down
7 changes: 7 additions & 0 deletions stdlib/public/Concurrency/TaskGroup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,13 @@ struct TaskGroupStatus {
.errorType = "task-group-violation",
.currentStackDescription = "TaskGroup exceeded supported pending task count",
.framesToSkip = 1,
.memoryAddress = nullptr,
.numExtraThreads = 0,
.threads = nullptr,
.numFixIts = 0,
.fixIts = nullptr,
.numNotes = 0,
.notes = nullptr,
};
_swift_reportToDebugger(RuntimeErrorFlagFatal, message, &details);
}
Expand Down
7 changes: 7 additions & 0 deletions stdlib/public/Concurrency/TaskLocal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,13 @@ static void swift_task_reportIllegalTaskLocalBindingWithinWithTaskGroupImpl(
.errorType = "task-local-violation",
.currentStackDescription = "Task-local bound in illegal context",
.framesToSkip = 1,
.memoryAddress = nullptr,
.numExtraThreads = 0,
.threads = nullptr,
.numFixIts = 0,
.fixIts = nullptr,
.numNotes = 0,
.notes = nullptr,
};
_swift_reportToDebugger(RuntimeErrorFlagFatal, message, &details);
}
Expand Down
5 changes: 5 additions & 0 deletions stdlib/public/RuntimeModule/Backtrace.swift
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,11 @@ extension Backtrace {
return Backtrace(architecture: context.architecture,
frames: unwinder.dropFirst(offset),
images: images)

@unknown default:
// This will never execute but its needed to avoid warnings when
// the Backtrace library is built with library evolution.
fatalError()
}
}
}
1 change: 0 additions & 1 deletion stdlib/public/libexec/swift-backtrace/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,6 @@ Generate a backtrace for the parent process.
var mentionedImages = Set<Int>()
let formatter = backtraceFormatter()

let platform = target.images.platform
let architecture: String
switch crashingThread.backtrace {
case let .raw(backtrace):
Expand Down