srctree

Robin Linden parent 137ac89d 3e7dc5ed
meta: Enable bugprone-* clang-tidy checks

inlinesplit
.clang-tidy added: 33, removed: 10, total 23
@@ -1,4 +1,11 @@
---
# -bugprone-exception-escape: We don't use exceptions and will be building with
# -fno-exceptions soon.
#
# -bugprone-narrowing-conversions: Very noisy for not much gain.
#
# -bugprone-unchecked-optional-access: Lots of false positives.
#
# -clang-analyzer-cplusplus.NewDeleteLeaks: Lots of false positives w/
# -std=c++2b when calling std::make_shared in the JS AST.
# js/ast_executor_test.cpp:176:5: error: Potential leak of memory pointed to by
@@ -24,8 +31,12 @@
#
# -misc-non-private-member-variables-in-classes: TODO(robinlinden): Fix.
Checks: >
bugprone-*,
google-*,
misc-*,
-bugprone-exception-escape,
-bugprone-narrowing-conversions,
-bugprone-unchecked-optional-access,
-clang-analyzer-cplusplus.NewDeleteLeaks,
-clang-analyzer-optin.cplusplus.UninitializedObject,
-clang-diagnostic-builtin-macro-redefined,
 
browser/gui/app.cpp added: 33, removed: 10, total 23
@@ -106,6 +106,8 @@ std::vector<dom::Node const *> gather_node_and_parents(style::StyledNode const &
}
 
namespace im {
// TODO(robinlinden): Stronger types.
// NOLINTNEXTLINE(bugprone-easily-swappable-parameters)
void window(char const *title, ImVec2 const &position, ImVec2 const &size, auto content) {
ImGui::SetNextWindowPos(position, ImGuiCond_FirstUseEver);
ImGui::SetNextWindowSize(size, ImGuiCond_FirstUseEver);
 
html2/tokenizer.cpp added: 33, removed: 10, total 23
@@ -127,6 +127,8 @@ void Tokenizer::run() {
case '<':
state_ = State::TagOpen;
continue;
// TODO(robinlinden): Remove when the data state is more complete.
// NOLINTNEXTLINE(bugprone-branch-clone)
case '\0':
// This is an unexpected-null-character parse error.
emit(CharacterToken{*c});
 
html2/tree_constructor.cpp added: 33, removed: 10, total 23
@@ -170,6 +170,8 @@ std::shared_ptr<dom2::Element> TreeConstructor::create_element_for_token(
std::shared_ptr<dom2::Element> TreeConstructor::create_element([[maybe_unused]] dom2::Document const &document,
std::string local_name,
[[maybe_unused]] std::string_view ns,
// Maybe not needed once we've implemented this.
// NOLINTNEXTLINE(bugprone-easily-swappable-parameters):
[[maybe_unused]] std::optional<std::string_view> prefix,
[[maybe_unused]] std::optional<std::string_view> is_value,
[[maybe_unused]] bool synchronous_custom_elements) const {
 
img/png_test.cpp added: 33, removed: 10, total 23
@@ -24,7 +24,8 @@ int main() {
auto expected_pixels = [] {
std::array<unsigned char, 3> pixel_pattern{181, 208, 208};
std::vector<unsigned char> expected;
expected.resize(256 * 256 * 3);
static constexpr auto kPixelCount = std::size_t{256} * 256 * 3;
expected.resize(kPixelCount);
 
for (std::size_t i = 0; i < expected.size(); ++i) {
expected[i] = pixel_pattern[i % pixel_pattern.size()];
 
os/linux_test.cpp added: 33, removed: 10, total 23
@@ -6,6 +6,7 @@
#ifdef _POSIX_C_SOURCE
#undef _POSIX_C_SOURCE
#endif
// NOLINTNEXTLINE(bugprone-reserved-identifier)
#define _POSIX_C_SOURCE 200112L
 
#include "os/os.h"
 
style/styled_node.h added: 33, removed: 10, total 23
@@ -41,6 +41,10 @@ struct StyledNode {
 
template<css::PropertyId T>
auto get_property() const {
// Some of these branches have the same content, but we still want to
// keep related properties grouped together and away from unrelated
// ones, e.g. all border-<side>-color properties in the same branch.
// NOLINTNEXTLINE(bugprone-branch-clone)
if constexpr (T == css::PropertyId::BackgroundColor) {
return get_color_property(T);
} else if constexpr (T == css::PropertyId::BorderBottomColor || T == css::PropertyId::BorderLeftColor
 
util/history.h added: 33, removed: 10, total 23
@@ -63,7 +63,7 @@ public:
}
 
constexpr std::optional<T> next() const {
if (auto next_index = static_cast<std::size_t>(current_index_ + 1); next_index < entries_.size()) {
if (auto next_index = static_cast<std::size_t>(current_index_) + 1; next_index < entries_.size()) {
return entries_[next_index];
}