srctree

Robin Linden parent 58d545b5 9131254e
meta/clang-tidy: Enable performance-enum-size

.clang-tidy added: 86, removed: 75, total 11
@@ -27,9 +27,6 @@
#
# -modernize-use-trailing-return-type: Stylistic change, and something we
# haven't been doing so far.
#
# TODO(robinlinden): Look into and enable:
# * performance-enum-size
Checks: >
bugprone-*,
cert-*,
@@ -71,8 +68,7 @@ Checks: >
-modernize-make-unique,
-modernize-use-emplace,
-modernize-use-nodiscard,
-modernize-use-trailing-return-type,
-performance-enum-size
-modernize-use-trailing-return-type
 
WarningsAsErrors: "*"
 
 
archive/zlib.h added: 86, removed: 75, total 11
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2023 Robin Lindén <dev@robinlinden.eu>
// SPDX-FileCopyrightText: 2023-2024 Robin Lindén <dev@robinlinden.eu>
//
// SPDX-License-Identifier: BSD-2-Clause
 
@@ -7,6 +7,7 @@
 
#include <tl/expected.hpp>
 
#include <cstdint>
#include <string>
#include <string_view>
 
@@ -17,7 +18,7 @@ struct ZlibError {
int code{};
};
 
enum class ZlibMode {
enum class ZlibMode : std::uint8_t {
Zlib,
Gzip,
};
 
azm/amd64/assembler.h added: 86, removed: 75, total 11
@@ -15,7 +15,7 @@
 
namespace azm::amd64 {
 
enum class Reg32 {
enum class Reg32 : std::uint8_t {
Eax,
Ecx,
Edx,
 
browser/gui/app.h added: 86, removed: 75, total 11
@@ -18,6 +18,7 @@
#include <SFML/Window/Cursor.hpp>
#include <tl/expected.hpp>
 
#include <cstdint>
#include <memory>
#include <string>
 
@@ -49,7 +50,7 @@ private:
std::string layout_str_{};
std::string nav_widget_extra_info_{};
 
enum class Canvas {
enum class Canvas : std::uint8_t {
OpenGL,
Sfml,
};
 
css/parser.cpp added: 86, removed: 75, total 11
@@ -19,6 +19,7 @@
#include <array>
#include <cassert>
#include <charconv>
#include <cstdint>
#include <cstdlib>
#include <cstring>
#include <optional>
@@ -507,7 +508,7 @@ void Parser::add_declaration(Declarations &declarations, std::string_view name,
 
// https://developer.mozilla.org/en-US/docs/Web/CSS/border
void Parser::expand_border(std::string_view name, Declarations &declarations, std::string_view value) {
enum class BorderSide { Left, Right, Top, Bottom };
enum class BorderSide : std::uint8_t { Left, Right, Top, Bottom };
 
static constexpr auto kIdsFor = [](BorderSide side) -> BorderOrOutlinePropertyIds {
switch (side) {
@@ -551,7 +552,7 @@ void Parser::expand_border_or_outline_impl(
return;
}
 
enum class BorderPropertyType { Color, Style, Width };
enum class BorderPropertyType : std::uint8_t { Color, Style, Width };
auto guess_type = [](std::string_view v) -> BorderPropertyType {
if (is_in_array<kBorderStyleKeywords>(v)) {
return BorderPropertyType::Style;
 
css/property_id.h added: 86, removed: 75, total 11
@@ -5,11 +5,12 @@
#ifndef CSS_PROPERTY_ID_H_
#define CSS_PROPERTY_ID_H_
 
#include <cstdint>
#include <string_view>
 
namespace css {
 
enum class PropertyId {
enum class PropertyId : std::uint8_t {
Unknown,
 
Azimuth,
 
css2/token.h added: 86, removed: 75, total 11
@@ -1,10 +1,12 @@
// SPDX-FileCopyrightText: 2022 Mikael Larsson <c.mikael.larsson@gmail.com>
// SPDX-FileCopyrightText: 2024 Robin Lindén <dev@robinlinden.eu>
//
// SPDX-License-Identifier: BSD-2-Clause
 
#ifndef CSS2_TOKEN_H_
#define CSS2_TOKEN_H_
 
#include <cstdint>
#include <string>
#include <variant>
 
@@ -26,7 +28,7 @@ struct AtKeywordToken {
};
 
struct HashToken {
enum class Type {
enum class Type : std::uint8_t {
Unrestricted,
Id,
};
@@ -58,7 +60,7 @@ struct DelimToken {
[[nodiscard]] bool operator==(DelimToken const &) const = default;
};
 
enum class NumericType {
enum class NumericType : std::uint8_t {
Integer,
Number,
};
 
css2/tokenizer.h added: 86, removed: 75, total 11
@@ -9,6 +9,7 @@
#include "css2/token.h"
 
#include <cstddef>
#include <cstdint>
#include <functional>
#include <optional>
#include <string>
@@ -19,7 +20,7 @@
namespace css2 {
 
// https://www.w3.org/TR/css-syntax-3/#tokenizer-algorithms
enum class State {
enum class State : std::uint8_t {
Main,
CommentStart,
Comment,
@@ -31,7 +32,7 @@ enum class State {
Whitespace,
};
 
enum class ParseError {
enum class ParseError : std::uint8_t {
EofInComment,
EofInEscapeSequence,
EofInString,
 
dom/dom.h added: 86, removed: 75, total 11
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2021-2023 Robin Lindén <dev@robinlinden.eu>
// SPDX-FileCopyrightText: 2021-2024 Robin Lindén <dev@robinlinden.eu>
//
// SPDX-License-Identifier: BSD-2-Clause
 
@@ -7,6 +7,7 @@
 
#include <algorithm>
#include <cstddef>
#include <cstdint>
#include <functional>
#include <iterator>
#include <map>
@@ -40,7 +41,7 @@ struct Document {
Node html_node;
 
// https://dom.spec.whatwg.org/#concept-document-mode
enum class Mode {
enum class Mode : std::uint8_t {
NoQuirks,
Quirks,
LimitedQuirks,
 
html2/iparser_actions.h added: 86, removed: 75, total 11
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2023 Robin Lindén <dev@robinlinden.eu>
// SPDX-FileCopyrightText: 2023-2024 Robin Lindén <dev@robinlinden.eu>
//
// SPDX-License-Identifier: BSD-2-Clause
 
@@ -9,13 +9,14 @@
#include "html2/token.h"
#include "html2/tokenizer.h"
 
#include <cstdint>
#include <span>
#include <string>
#include <string_view>
 
namespace html2 {
 
enum class QuirksMode {
enum class QuirksMode : std::uint8_t {
NoQuirks,
Quirks,
LimitedQuirks,
 
html2/tokenizer.h added: 86, removed: 75, total 11
@@ -19,7 +19,7 @@
namespace html2 {
 
// https://html.spec.whatwg.org/multipage/parsing.html#tokenization
enum class State {
enum class State : std::uint8_t {
Data = 1, // So the state enum values match the number in the spec.
Rcdata,
Rawtext,
@@ -102,7 +102,7 @@ enum class State {
NumericCharacterReferenceEnd,
};
 
enum class ParseError {
enum class ParseError : std::uint8_t {
AbruptClosingOfEmptyComment,
AbruptDoctypePublicIdentifier,
AbruptDoctypeSystemIdentifier,
 
img/gif.h added: 86, removed: 75, total 11
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2023 Robin Lindén <dev@robinlinden.eu>
// SPDX-FileCopyrightText: 2023-2024 Robin Lindén <dev@robinlinden.eu>
//
// SPDX-License-Identifier: BSD-2-Clause
 
@@ -13,7 +13,7 @@ namespace img {
 
class Gif {
public:
enum class Version {
enum class Version : std::uint8_t {
Gif87a,
Gif89a,
};
 
img/qoi.h added: 86, removed: 75, total 11
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2023 Robin Lindén <dev@robinlinden.eu>
// SPDX-FileCopyrightText: 2023-2024 Robin Lindén <dev@robinlinden.eu>
//
// SPDX-License-Identifier: BSD-2-Clause
 
@@ -13,7 +13,7 @@
 
namespace img {
 
enum class QoiError {
enum class QoiError : std::uint8_t {
AbruptEof,
InvalidMagic,
InvalidChannels,
 
js/ast.h added: 86, removed: 75, total 11
@@ -1,10 +1,11 @@
// SPDX-FileCopyrightText: 2022-2023 Robin Lindén <dev@robinlinden.eu>
// SPDX-FileCopyrightText: 2022-2024 Robin Lindén <dev@robinlinden.eu>
//
// SPDX-License-Identifier: BSD-2-Clause
 
#ifndef JS_AST_H_
#define JS_AST_H_
 
#include <cstdint>
#include <functional>
#include <map>
#include <memory>
@@ -118,7 +119,7 @@ struct Identifier {
};
 
// TODO(robinlinden): Support more operators.
enum class BinaryOperator {
enum class BinaryOperator : std::uint8_t {
Minus,
Plus,
};
@@ -163,7 +164,7 @@ struct VariableDeclarator {
 
struct VariableDeclaration {
std::vector<VariableDeclarator> declarations;
enum class Kind {
enum class Kind : std::uint8_t {
Var,
};
Kind kind{Kind::Var};
 
layout/layout_box.h added: 86, removed: 75, total 11
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2021-2023 Robin Lindén <dev@robinlinden.eu>
// SPDX-FileCopyrightText: 2021-2024 Robin Lindén <dev@robinlinden.eu>
//
// SPDX-License-Identifier: BSD-2-Clause
 
@@ -14,6 +14,7 @@
#include "style/styled_node.h"
 
#include <cassert>
#include <cstdint>
#include <optional>
#include <string>
#include <string_view>
@@ -23,7 +24,7 @@
 
namespace layout {
 
enum class LayoutType {
enum class LayoutType : std::uint8_t {
Inline,
Block,
AnonymousBlock, // Holds groups of sequential inline boxes.
 
protocol/response.h added: 86, removed: 75, total 11
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2021-2023 Robin Lindén <dev@robinlinden.eu>
// SPDX-FileCopyrightText: 2021-2024 Robin Lindén <dev@robinlinden.eu>
// SPDX-FileCopyrightText: 2021-2022 Mikael Larsson <c.mikael.larsson@gmail.com>
//
// SPDX-License-Identifier: BSD-2-Clause
@@ -7,6 +7,7 @@
#define PROTOCOL_RESPONSE_H_
 
#include <cstddef>
#include <cstdint>
#include <initializer_list>
#include <map>
#include <optional>
@@ -16,7 +17,7 @@
 
namespace protocol {
 
enum class Error {
enum class Error : std::uint8_t {
Ok,
Unresolved,
Unhandled,
 
style/styled_node.h added: 86, removed: 75, total 11
@@ -11,6 +11,7 @@
#include "util/string.h"
 
#include <algorithm>
#include <cstdint>
#include <optional>
#include <string>
#include <string_view>
@@ -20,7 +21,7 @@
 
namespace style {
 
enum class BorderStyle {
enum class BorderStyle : std::uint8_t {
None,
Hidden,
Dotted,
@@ -35,13 +36,13 @@ enum class BorderStyle {
 
using OutlineStyle = BorderStyle;
 
enum class DisplayValue {
enum class DisplayValue : std::uint8_t {
None,
Inline,
Block,
};
 
enum class FontStyle {
enum class FontStyle : std::uint8_t {
Normal,
Italic,
Oblique,
@@ -56,7 +57,7 @@ struct FontWeight {
static constexpr FontWeight bold() { return {kBold}; }
};
 
enum class TextDecorationLine {
enum class TextDecorationLine : std::uint8_t {
None,
Underline,
Overline,
@@ -64,7 +65,7 @@ enum class TextDecorationLine {
Blink,
};
 
enum class WhiteSpace {
enum class WhiteSpace : std::uint8_t {
Normal,
Pre,
Nowrap,
 
type/type.h added: 86, removed: 75, total 11
@@ -5,6 +5,7 @@
#ifndef TYPE_TYPE_H_
#define TYPE_TYPE_H_
 
#include <cstdint>
#include <memory>
#include <optional>
#include <string_view>
@@ -22,7 +23,7 @@ struct Px {
[[nodiscard]] bool operator==(Px const &) const = default;
};
 
enum class Weight {
enum class Weight : std::uint8_t {
Normal,
Bold,
};
 
url/url.h added: 86, removed: 75, total 11
@@ -24,7 +24,7 @@ namespace url {
 
void icu_cleanup();
 
enum class HostType { DnsDomain, Ip4Addr, Ip6Addr, Opaque, Empty };
enum class HostType : std::uint8_t { DnsDomain, Ip4Addr, Ip6Addr, Opaque, Empty };
 
struct Host {
HostType type;
@@ -110,7 +110,7 @@ struct Url {
bool operator==(Url const &b) const { return serialize() == b.serialize(); }
};
 
enum class ValidationError {
enum class ValidationError : std::uint8_t {
// IDNA
DomainToAscii,
DomainToUnicode,
@@ -155,7 +155,7 @@ public:
void set_on_error(std::function<void(ValidationError)> on_error) { on_error_ = std::move(on_error); }
 
private:
enum class ParserState {
enum class ParserState : std::uint8_t {
SchemeStart,
Scheme,
NoScheme,
 
wasm/byte_code_parser.cpp added: 86, removed: 75, total 11
@@ -414,7 +414,7 @@ std::optional<CodeSection> parse_code_section(std::istream &is) {
 
tl::expected<Module, ModuleParseError> ByteCodeParser::parse_module(std::istream &is) {
// https://webassembly.github.io/spec/core/binary/modules.html#sections
enum class SectionId {
enum class SectionId : std::uint8_t {
Custom = 0,
Type = 1,
Import = 2,
 
wasm/byte_code_parser.h added: 86, removed: 75, total 11
@@ -7,13 +7,14 @@
 
#include <tl/expected.hpp>
 
#include <cstdint>
#include <iosfwd>
#include <optional>
#include <string_view>
 
namespace wasm {
 
enum class ModuleParseError {
enum class ModuleParseError : std::uint8_t {
UnexpectedEof,
InvalidMagic,
UnsupportedVersion,
 
wasm/byte_code_parser_test.cpp added: 86, removed: 75, total 11
@@ -30,7 +30,7 @@ using wasm::ByteCodeParser;
namespace {
 
// https://webassembly.github.io/spec/core/binary/modules.html#sections
enum class SectionId {
enum class SectionId : std::uint8_t {
Custom = 0,
Type = 1,
Import = 2,
 
wasm/leb128.h added: 86, removed: 75, total 11
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2023 Robin Lindén <dev@robinlinden.eu>
// SPDX-FileCopyrightText: 2023-2024 Robin Lindén <dev@robinlinden.eu>
//
// SPDX-License-Identifier: BSD-2-Clause
 
@@ -16,7 +16,7 @@
 
namespace wasm {
 
enum class Leb128ParseError {
enum class Leb128ParseError : std::uint8_t {
Invalid,
NonZeroExtraBits,
UnexpectedEof,
 
wasm/types.h added: 86, removed: 75, total 11
@@ -16,7 +16,7 @@ using TypeIdx = std::uint32_t;
using FuncIdx = std::uint32_t;
 
// https://webassembly.github.io/spec/core/syntax/types.html
enum class ValueType {
enum class ValueType : std::uint8_t {
// Number types.
Int32,
Int64,
 
wasm/wasm.h added: 86, removed: 75, total 11
@@ -25,7 +25,7 @@ struct CustomSection {
 
// https://webassembly.github.io/spec/core/binary/types.html#binary-globaltype
struct GlobalType {
enum class Mutability {
enum class Mutability : std::uint8_t {
Const,
Var,
};
@@ -97,7 +97,7 @@ struct GlobalSection {
 
// https://webassembly.github.io/spec/core/binary/modules.html#binary-export
struct Export {
enum class Type { Function = 0, Table = 1, Memory = 2, Global = 3 };
enum class Type : std::uint8_t { Function = 0, Table = 1, Memory = 2, Global = 3 };
 
std::string name{};
Type type{};