Skip to content

Commit c8eb1f2

Browse files
authored
Merge pull request swiftlang#62687 from eeckstein/fix-strict-clang-errors
Fix build problems with a newer clang
2 parents 1ef2a56 + 1881e17 commit c8eb1f2

File tree

2 files changed

+12
-16
lines changed

2 files changed

+12
-16
lines changed

include/swift/ABI/Metadata.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -648,9 +648,9 @@ struct TargetClassMetadataBounds : TargetMetadataBounds<Runtime> {
648648
/// Return the basic bounds of all Swift class metadata.
649649
/// The immediate members offset will not be meaningful.
650650
static constexpr TargetClassMetadataBounds<Runtime> forSwiftRootClass() {
651-
using Metadata = FullMetadata<TargetClassMetadataType<Runtime>>;
652-
return forAddressPointAndSize(sizeof(typename Metadata::HeaderType),
653-
sizeof(Metadata));
651+
using MetadataTy = FullMetadata<TargetClassMetadataType<Runtime>>;
652+
return forAddressPointAndSize(sizeof(typename MetadataTy::HeaderType),
653+
sizeof(MetadataTy));
654654
}
655655

656656
/// Return the bounds of a Swift class metadata with the given address

stdlib/public/LLVMSupport/ErrorHandling.cpp

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,14 @@
3131
#endif
3232

3333
namespace {
34-
void error(const char *fmt, ...) {
34+
void error(const char *prefix, const char *msg, const char *file = nullptr, unsigned line = 0) {
3535
char buffer[1024];
36-
va_list argp;
3736

38-
va_start(argp, fmt);
39-
vsnprintf(buffer, sizeof(buffer), fmt, argp);
40-
va_end(argp);
37+
if (file) {
38+
snprintf(buffer, sizeof(buffer), "%s%s at %s:%u\n", prefix, msg, file, line);
39+
} else {
40+
snprintf(buffer, sizeof(buffer), "%s%s\n", prefix, msg);
41+
}
4142

4243
#if SWIFT_STDLIB_HAS_ASL
4344
asl_log(nullptr, nullptr, ASL_LEVEL_ERR, "%s", buffer);
@@ -57,7 +58,7 @@ using namespace llvm;
5758

5859
void __swift::__runtime::llvm::report_fatal_error(const char *Reason,
5960
bool GenCrashDiag) {
60-
error("LLVM ERROR: %s\n", Reason);
61+
error("LLVM ERROR: ", Reason);
6162
abort();
6263
}
6364

@@ -75,7 +76,7 @@ void __swift::__runtime::llvm::report_bad_alloc_error(const char *Reason,
7576
bool GenCrashDiag) {
7677
// Don't call the normal error handler. It may allocate memory. Directly write
7778
// an OOM to stderr and abort.
78-
error("LLVM ERROR: out of memory\n");
79+
error("LLVM ERROR: ", "out of memory");
7980
abort();
8081
}
8182

@@ -84,12 +85,7 @@ void __swift::__runtime::llvm::llvm_unreachable_internal(
8485
// This code intentionally doesn't call the ErrorHandler callback, because
8586
// llvm_unreachable is intended to be used to indicate "impossible"
8687
// situations, and not legitimate runtime errors.
87-
if (msg)
88-
error("%s\n", msg);
89-
error("UNREACHABLE executed");
90-
if (file)
91-
error(" at %s:%u", file, line);
92-
error("!\n");
88+
error("", msg ? msg : "UNREACHABLE executed!", file, line);
9389
abort();
9490
#ifdef LLVM_BUILTIN_UNREACHABLE
9591
// Windows systems and possibly others don't declare abort() to be noreturn,

0 commit comments

Comments
 (0)