Compare commits

...

8 Commits

Author SHA1 Message Date
Don Isaac
eaeb798fa9 HTTPHeaderNames.h needs config.h 2025-04-09 11:59:40 -07:00
Don Isaac
2cdb0c73ea fix verbose_abort (again) 2025-04-09 11:51:35 -07:00
Don Isaac
ac1989d3c8 Merge branch 'main' of github.com:oven-sh/bun into don/fix/clang-20-errors 2025-04-09 11:49:55 -07:00
Don Isaac
587f1d2642 Merge branch 'main' into don/fix/clang-20-errors 2025-04-08 18:33:22 -07:00
Don Isaac
8d264b30dd Merge branch 'main' of github.com:oven-sh/bun into don/fix/clang-20-errors 2025-04-08 15:41:34 -07:00
Don Isaac
4722d968cd fix noexcept 2025-04-08 15:40:16 -07:00
DonIsaac
433297193e bun run clang-format 2025-04-08 22:01:20 +00:00
Don Isaac
27ae77a134 fix: errors found by -Werror on Clang 20 2025-04-08 14:58:38 -07:00
15 changed files with 80 additions and 78 deletions

View File

@@ -50,7 +50,7 @@ public:
ScriptExecutionContext* m_context;
private:
MessagePortChannelProviderImpl* m_messagePortChannelProvider;
// private:
// MessagePortChannelProviderImpl* m_messagePortChannelProvider;
};
}

View File

@@ -4991,7 +4991,8 @@ void JSC__JSValue__getNameProperty(JSC__JSValue JSValue0, JSC__JSGlobalObject* a
}
if (JSC::InternalFunction* function = JSC::jsDynamicCast<JSC::InternalFunction*>(obj)) {
auto view = WTF::StringView(function->name());
String name = function->name();
auto view = WTF::StringView(name);
*arg2 = Zig::toZigString(view);
return;
}

View File

@@ -94,7 +94,7 @@ private:
unsigned m_columnNumber;
JSValueInWrappedObject m_error;
// RefPtr<SerializedScriptValue> m_serializedError;
bool m_triedToSerialize { false };
// bool m_triedToSerialize { false };
};
} // namespace WebCore

View File

@@ -29,21 +29,11 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#include "HTTPHeaderMap.h"
#include <utility>
#include <wtf/CrossThreadCopier.h>
#include <wtf/text/StringView.h>
static StringView extractCookieName(const StringView& cookie)
{
auto nameEnd = cookie.find('=');
if (nameEnd == notFound)
return String();
return cookie.substring(0, nameEnd);
}
namespace WebCore {
HTTPHeaderMap::HTTPHeaderMap()

View File

@@ -29,6 +29,7 @@
#pragma once
#include <wtf/Forward.h>
#include "config.h"
namespace WebCore {

View File

@@ -346,35 +346,6 @@ std::optional<WallTime> parseHTTPDate(const String& value)
return WallTime::fromRawSeconds(dateInMillisecondsSinceEpoch / 1000.0);
}
// FIXME: This function doesn't comply with RFC 6266.
// For example, this function doesn't handle the interaction between " and ;
// that arises from quoted-string, nor does this function properly unquote
// attribute values. Further this function appears to process parameter names
// in a case-sensitive manner. (There are likely other bugs as well.)
StringView filenameFromHTTPContentDisposition(StringView value)
{
for (auto keyValuePair : value.split(';')) {
size_t valueStartPos = keyValuePair.find('=');
if (valueStartPos == notFound)
continue;
auto key = keyValuePair.left(valueStartPos).trim(isUnicodeCompatibleASCIIWhitespace<UChar>);
if (key.isEmpty() || key != "filename"_s)
continue;
auto value = keyValuePair.substring(valueStartPos + 1).trim(isUnicodeCompatibleASCIIWhitespace<UChar>);
// Remove quotes if there are any
if (value.length() > 1 && value[0] == '\"')
value = value.substring(1, value.length() - 2);
return value;
}
return String();
}
String extractMIMETypeFromMediaType(const String& mediaType)
{
unsigned position = 0;

View File

@@ -82,7 +82,6 @@ WEBCORE_EXPORT bool isValidUserAgentHeaderValue(const StringView&);
#endif
bool isValidHTTPToken(const StringView&);
std::optional<WallTime> parseHTTPDate(const StringView&);
StringView filenameFromHTTPContentDisposition(StringView);
WEBCORE_EXPORT String extractMIMETypeFromMediaType(const String&);
StringView extractCharsetFromMediaType(const String&);
XSSProtectionDisposition parseXSSProtectionHeader(const String& header, String& failureReason, unsigned& failurePosition, String& reportURL);

View File

@@ -68,27 +68,27 @@ private:
unsigned long long monotonicTimeToIntegerMilliseconds(MonotonicTime) const;
mutable unsigned long long m_navigationStart { 0 };
mutable unsigned long long m_unloadEventStart { 0 };
mutable unsigned long long m_unloadEventEnd { 0 };
mutable unsigned long long m_redirectStart { 0 };
mutable unsigned long long m_redirectEnd { 0 };
mutable unsigned long long m_fetchStart { 0 };
mutable unsigned long long m_domainLookupStart { 0 };
mutable unsigned long long m_domainLookupEnd { 0 };
mutable unsigned long long m_connectStart { 0 };
mutable unsigned long long m_connectEnd { 0 };
mutable unsigned long long m_secureConnectionStart { 0 };
mutable unsigned long long m_requestStart { 0 };
mutable unsigned long long m_responseStart { 0 };
mutable unsigned long long m_responseEnd { 0 };
mutable unsigned long long m_domLoading { 0 };
mutable unsigned long long m_domInteractive { 0 };
mutable unsigned long long m_domContentLoadedEventStart { 0 };
mutable unsigned long long m_domContentLoadedEventEnd { 0 };
mutable unsigned long long m_domComplete { 0 };
mutable unsigned long long m_loadEventStart { 0 };
mutable unsigned long long m_loadEventEnd { 0 };
// mutable unsigned long long m_navigationStart { 0 };
// mutable unsigned long long m_unloadEventStart { 0 };
// mutable unsigned long long m_unloadEventEnd { 0 };
// mutable unsigned long long m_redirectStart { 0 };
// mutable unsigned long long m_redirectEnd { 0 };
// mutable unsigned long long m_fetchStart { 0 };
// mutable unsigned long long m_domainLookupStart { 0 };
// mutable unsigned long long m_domainLookupEnd { 0 };
// mutable unsigned long long m_connectStart { 0 };
// mutable unsigned long long m_connectEnd { 0 };
// mutable unsigned long long m_secureConnectionStart { 0 };
// mutable unsigned long long m_requestStart { 0 };
// mutable unsigned long long m_responseStart { 0 };
// mutable unsigned long long m_responseEnd { 0 };
// mutable unsigned long long m_domLoading { 0 };
// mutable unsigned long long m_domInteractive { 0 };
// mutable unsigned long long m_domContentLoadedEventStart { 0 };
// mutable unsigned long long m_domContentLoadedEventEnd { 0 };
// mutable unsigned long long m_domComplete { 0 };
// mutable unsigned long long m_loadEventStart { 0 };
// mutable unsigned long long m_loadEventEnd { 0 };
};
} // namespace WebCore

View File

@@ -238,7 +238,13 @@ extern "C" __attribute__((used)) char __libc_single_threaded = 0;
#include <cstdio>
#include "headers.h"
void std::__libcpp_verbose_abort(char const* format, ...)
#ifdef _LIBCPP_VERBOSE_ABORT_NOEXCEPT
#define VERBOSE_ABORT_NOEXCEPT _LIBCPP_VERBOSE_ABORT_NOEXCEPT
#else
#define VERBOSE_ABORT_NOEXCEPT
#endif
void std::__libcpp_verbose_abort(char const* format, ...) VERBOSE_ABORT_NOEXCEPT
{
va_list list;
va_start(list, format);
@@ -249,6 +255,8 @@ void std::__libcpp_verbose_abort(char const* format, ...)
Bun__panic(buffer, len);
}
#undef VERBOSE_ABORT_NOEXCEPT
#endif
#ifndef U_SHOW_CPLUSPLUS_API

View File

@@ -1024,7 +1024,12 @@ pub const Blob = struct {
// its usage from `Blob.writeFileInternal`), then upgrade this to
// Environment.allow_assert
if (Environment.isDebug) {
bun.assertf(destination_type != .bytes, "Cannot write to a Blob backed by a Buffer or TypedArray. This is a bug in the caller. Please report it to the Bun team.", .{});
bun.assertf(
destination_type != .bytes,
"Cannot write to a Blob backed by a Buffer or TypedArray. This is a bug in the caller. Please report it to the Bun team.",
.{},
@src(),
);
}
const source_store = source_blob.store orelse return writeFileWithEmptySourceToDestination(ctx, destination_blob, options);

View File

@@ -3354,16 +3354,24 @@ noinline fn assertionFailureAtLocation(src: std.builtin.SourceLocation) noreturn
@compileError(std.fmt.comptimePrint("assertion failure"));
} else {
@branchHint(.cold);
Output.panic(assertion_failure_msg ++ "at {s}:{d}:{d}", .{ src.file, src.line, src.column });
Output.panic(assertion_failure_msg ++ " at {s}:{d}:{d}", .{ src.file, src.line, src.column });
}
}
noinline fn assertionFailureWithMsg(comptime msg: []const u8, args: anytype) noreturn {
noinline fn assertionFailureWithMsg(
comptime msg: []const u8,
args: anytype,
comptime src: ?std.builtin.SourceLocation,
) noreturn {
if (@inComptime()) {
@compileError(std.fmt.comptimePrint("assertion failure: " ++ msg, args));
} else {
@branchHint(.cold);
Output.panic(assertion_failure_msg ++ ": " ++ msg, args);
const loc_part = if (src) |s|
std.fmt.comptimePrint(" at {s}:{d}:{d}", .{ s.file, s.line, s.column })
else
"";
Output.panic(assertion_failure_msg ++ loc_part ++ ": " ++ msg, args);
}
}
@@ -3426,20 +3434,26 @@ pub fn assert(ok: bool) callconv(callconv_inline) void {
/// ```zig
/// if (comptime bun.Environment.allow_assert) {
/// const expensive = doExpensiveCheck();
/// bun.assert(expensive, "Something happened: {}", .{ expensive });
/// bun.assert(expensive, "Something happened: {}", .{ expensive }, @src());
/// }
/// ```
///
/// Use `releaseAssert` for assertions that should not be stripped in release builds.
pub fn assertf(ok: bool, comptime format: []const u8, args: anytype) callconv(callconv_inline) void {
pub fn assertf(
ok: bool,
comptime format: []const u8,
args: anytype,
comptime src: ?std.builtin.SourceLocation,
) callconv(callconv_inline) void {
if (comptime !Environment.allow_assert) {
return;
}
if (!ok) {
@branchHint(.cold);
// crash handler has runtime-only code.
if (@inComptime()) @compileError(std.fmt.comptimePrint(format, args));
assertionFailureWithMsg(format, args);
assertionFailureWithMsg(format, args, src);
}
}

View File

@@ -274,7 +274,12 @@ pub const PackCommand = struct {
) OOM!PackQueue {
if (comptime Environment.isDebug) {
for (excludes) |exclude| {
bun.assertf(exclude.flags.negated, "Illegal exclusion pattern '{s}'. Exclusion patterns are always negated.", .{exclude.glob});
bun.assertf(
exclude.flags.negated,
"Illegal exclusion pattern '{s}'. Exclusion patterns are always negated.",
.{exclude.glob},
@src(),
);
}
}

View File

@@ -2406,10 +2406,15 @@ pub const PackageManifest = struct {
// When reading the versions, we iterate through the
// list backwards to choose the highest matching
// version
const first = semver_versions_[0];
const second = semver_versions_[1];
const first: Semver.Version = semver_versions_[0];
const second: Semver.Version = semver_versions_[1];
const order = second.order(first, string_buf, string_buf);
bun.assertWithLocation(order == .gt, @src());
bun.assertf(
order == .gt,
"expected {s} > {s}",
.{ second.fmt(source.contents), first.fmt(source.contents) },
@src(),
);
}
}
}

View File

@@ -240,6 +240,7 @@ pub fn CowSliceZ(T: type, comptime sentinel: ?T) type {
debug.allocator.vtable == allocator.vtable,
"CowSlice.deinit called with a different allocator than the one used to create it",
.{},
@src(),
);
if (str.isOwned()) {
// active borrows become invalid data
@@ -247,6 +248,7 @@ pub fn CowSliceZ(T: type, comptime sentinel: ?T) type {
debug.borrows == 0,
"Cannot deinit() a CowSlice with active borrows. Current borrow count: {d}",
.{debug.borrows},
@src(),
);
bun.destroy(debug);
} else {
@@ -287,6 +289,7 @@ comptime {
cow_size == @sizeOf([]const u8),
"CowSlice should be the same size as a native slice, but it was {d} bytes instead of {d}",
.{ cow_size, @sizeOf([]const u8) },
null,
);
}

View File

@@ -2690,7 +2690,7 @@ pub const Resolver = struct {
}
}
bun.assertf(std.fs.path.isAbsolute(input_path), "cannot resolve DirInfo for non-absolute path: {s}", .{input_path});
bun.assertf(std.fs.path.isAbsolute(input_path), "cannot resolve DirInfo for non-absolute path: {s}", .{input_path}, @src());
const path_without_trailing_slash = strings.withoutTrailingSlashWindowsPath(input_path);
assertValidCacheKey(path_without_trailing_slash);