mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 21:17:45 +00:00
Everywhere: Explicitly specify the size in StringView constructors
This commit moves the length calculations out to be directly on the StringView users. This is an important step towards the goal of removing StringView(char const*), as it moves the responsibility of calculating the size of the string to the user of the StringView (which will prevent naive uses causing OOB access).
This commit is contained in:
parent
e3da0adfe6
commit
c70f45ff44
75 changed files with 264 additions and 203 deletions
|
@ -15,8 +15,8 @@ namespace AK {
|
|||
|
||||
class SourceLocation {
|
||||
public:
|
||||
[[nodiscard]] constexpr StringView function_name() const { return StringView(m_function); }
|
||||
[[nodiscard]] constexpr StringView filename() const { return StringView(m_file); }
|
||||
[[nodiscard]] constexpr StringView function_name() const { return { m_function, __builtin_strlen(m_function) }; }
|
||||
[[nodiscard]] constexpr StringView filename() const { return { m_file, __builtin_strlen(m_file) }; }
|
||||
[[nodiscard]] constexpr u32 line_number() const { return m_line; }
|
||||
|
||||
[[nodiscard]] static constexpr SourceLocation current(char const* const file = __builtin_FILE(), u32 line = __builtin_LINE(), char const* const function = __builtin_FUNCTION())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue