Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
f6357fa
Remove the (void) parameter lists
zayenz Nov 5, 2026
100971f
Enable the clang-tidy checks that already pass
zayenz Nov 6, 2026
fa3c9c1
Round the TSP distances with llround
zayenz Nov 6, 2026
3630c2e
Reject reserved identifiers
zayenz Nov 6, 2026
4be1ccf
Enable the pointer iteration order check
zayenz Nov 6, 2026
dc9ffb9
Copy region heap blocks with std::copy_n
zayenz Nov 6, 2026
99e2483
Compare strcmp results explicitly
zayenz Nov 6, 2026
b8b82b3
Mark the deliberate grandparent calls in set LDSB
zayenz Nov 6, 2026
1484084
Make the CRTP base constructors private
zayenz Nov 6, 2026
8b61c5c
Move assignments out of if conditions
zayenz Nov 6, 2026
a78ece3
Return a non-const reference to *this from assignment
zayenz Nov 6, 2026
aa4fcae
Handle self-assignment explicitly
zayenz Nov 6, 2026
6f0c042
Point at const data in the sparse tuple loops
zayenz Nov 6, 2026
6913352
Define header functions and variables inline
zayenz Nov 6, 2026
5e41fde
Drop the anonymous namespace from the cumulatives header
zayenz Nov 6, 2026
b8c220f
Keep overrides at the visibility of the base
zayenz Nov 6, 2026
4f2486a
Remove expressions with equivalent operands
zayenz Nov 6, 2026
530cc3f
Say why catch blocks are empty
zayenz Nov 6, 2026
d3039df
Enable the exception escape check for destructors
zayenz Nov 6, 2026
d366d54
Drop static from anonymous namespaces
zayenz Nov 6, 2026
a9c7ffc
Test containers with empty
zayenz Nov 6, 2026
e6241aa
Test membership with contains
zayenz Nov 6, 2026
0bae6f4
Remove casts to the same type
zayenz Nov 6, 2026
2ba0c9b
Use ifdef and ifndef for single macros
zayenz Nov 6, 2026
367a505
Call static members through their class
zayenz Nov 6, 2026
0e033e7
Remove redundant member initializers
zayenz Nov 6, 2026
184b4cd
Remove redundant parentheses
zayenz Nov 6, 2026
7208564
Remove empty string initializers
zayenz Nov 6, 2026
ab3f1c9
Remove const from returned values
zayenz Nov 6, 2026
bce0a4b
Remove const from parameters in declarations
zayenz Nov 6, 2026
0a698d8
Use data() for the address of container contents
zayenz Nov 6, 2026
727f214
Remove redundant control flow
zayenz Nov 6, 2026
e70754b
Write literal suffixes in upper case
zayenz Nov 6, 2026
07b2878
Spell out auto pointers
zayenz Nov 6, 2026
f0ae83f
Remove redundant smart pointer get calls
zayenz Nov 6, 2026
be879ee
Clamp with std::min and std::max
zayenz Nov 6, 2026
ebd40a5
Do not return void expressions
zayenz Nov 6, 2026
4e34871
Brace the branches of an if consistently
zayenz Nov 6, 2026
ef13aae
Remove repeated access specifiers
zayenz Nov 6, 2026
43eb198
Use the trait aliases and variable templates
zayenz Nov 6, 2026
0249286
Create unique pointers with make_unique
zayenz Nov 6, 2026
e54a230
Create shared pointers with make_shared
zayenz Nov 6, 2026
59b0248
Construct container elements in place
zayenz Nov 6, 2026
70bbd76
Use raw string literals for escaped text
zayenz Nov 6, 2026
e5cfaae
Use starts_with and ends_with
zayenz Nov 6, 2026
9f2c932
Use range-based for loops
zayenz Nov 6, 2026
e3bb19a
Keep generated tables free of redundant expressions
zayenz Nov 6, 2026
7bc2380
Default special members made trivial by earlier changes
zayenz Nov 6, 2026
d71f002
Compare mixed-sign integers with std::cmp functions
zayenz Nov 6, 2026
39e50c3
Replace typedef with using
zayenz Nov 6, 2026
36f3923
Drop typename where C++20 no longer needs it
zayenz Nov 6, 2026
b14ea49
Use range algorithms
zayenz Nov 6, 2026
dfab33b
Use transparent functors
zayenz Nov 6, 2026
a7663e6
Use initializer lists for nested min and max
zayenz Nov 6, 2026
d233ce1
Constrain the Boolean expression templates with a concept
zayenz Nov 6, 2026
24a7f94
Take read-only array parameters as pointers to const
zayenz Nov 6, 2026
51a3280
Drop else after return
zayenz Nov 6, 2026
f7986b4
Simplify Boolean returns and assignments
zayenz Nov 6, 2026
727745f
Use the same parameter names in declarations and definitions
zayenz Nov 6, 2026
c8f0c8b
Check call arguments for likely swaps
zayenz Nov 6, 2026
fb2d980
Use nested namespace definitions
zayenz Nov 6, 2026
ccfac87
Replace C-style casts
zayenz Nov 6, 2026
8be365a
Make the LDSB test helper a variadic template
zayenz Nov 6, 2026
cff9baf
Enable checks from other groups that already pass
zayenz Nov 6, 2026
aac1be1
Keep malloc inside the heap allocator
zayenz Nov 6, 2026
a175867
Remove the default argument from a virtual function
zayenz Nov 6, 2026
24c10bf
Discard unused C library results explicitly
zayenz Nov 6, 2026
3fce2a8
Check that rvalue reference parameters are moved
zayenz Nov 6, 2026
2402ee0
Derive exceptions from std::exception
zayenz Nov 6, 2026
7390d5e
Give BranchPlugin a virtual destructor
zayenz Nov 6, 2026
84d3c47
Give file-local functions internal linkage
zayenz Nov 6, 2026
9f3eb2d
Enable the analyzer groups that fit
zayenz Nov 7, 2026
b008be3
Fix what the full lint found in sources and headers
zayenz Nov 7, 2026
0c8f9e7
Lint the FlatZinc parser and lexer actions
zayenz Nov 7, 2026
03ddd2a
Document the clang-tidy check selection
zayenz Nov 7, 2026
1cca79d
Remove a stray blank line from the unary test
zayenz Nov 7, 2026
bbdcc3b
Fix the MSVC builds
zayenz Nov 7, 2026
7ad34e5
Qualify the matrix slice conversion for MSVC again
zayenz Nov 7, 2026
908dbe1
Record the zdev areas for the Gecode 7 changes
zayenz Nov 20, 2026
58e3488
Remove the zdev records from the pull request
zayenz Nov 20, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
131 changes: 98 additions & 33 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -1,39 +1,88 @@
# Use clang-tidy 22. Keep checks focused on correctness and useful modernization.
# Use clang-tidy 22. Each group below is enabled as a whole, and a line that
# starts with a minus excludes a check that was tried and does not fit. The
# reasons are in docs/code-style.md. Checks from other groups are named one by
# one, because most of those groups are aliases of checks enabled here.
Checks: >-
-*,
clang-analyzer-core.*,
bugprone-assert-side-effect,
bugprone-dangling-handle,
bugprone-inaccurate-erase,
bugprone-integer-division,
bugprone-macro-repeated-side-effects,
bugprone-misplaced-widening-cast,
bugprone-move-forwarding-reference,
bugprone-sizeof-expression,
bugprone-suspicious-memory-comparison,
bugprone-suspicious-memset-usage,
bugprone-unused-raii,
bugprone-unused-return-value,
bugprone-use-after-move,
bugprone-virtual-near-miss,
modernize-deprecated-headers,
modernize-use-equals-default,
modernize-use-equals-delete,
modernize-use-nullptr,
modernize-use-override,
performance-avoid-endl,
performance-faster-string-find,
performance-for-range-copy,
performance-implicit-conversion-in-loop,
performance-inefficient-algorithm,
performance-inefficient-string-concatenation,
performance-inefficient-vector-operation,
performance-move-const-arg,
performance-move-constructor-init,
performance-no-automatic-move,
performance-unnecessary-copy-initialization,
performance-unnecessary-value-param,
readability-identifier-naming
clang-analyzer-cplusplus.*,
-clang-analyzer-cplusplus.NewDeleteLeaks,
clang-analyzer-deadcode.*,
clang-analyzer-nullability.*,
clang-analyzer-optin.*,
-clang-analyzer-optin.core.EnumCastOutOfRange,
-clang-analyzer-optin.cplusplus.UninitializedObject,
-clang-analyzer-optin.performance.Padding,
clang-analyzer-security.*,
-clang-analyzer-security.ArrayBound,
clang-analyzer-unix.*,
-clang-analyzer-unix.Malloc,
clang-analyzer-valist.*,
cert-err33-c,
google-default-arguments,
cppcoreguidelines-no-malloc,
cppcoreguidelines-rvalue-reference-param-not-moved,
cppcoreguidelines-misleading-capture-default-by-value,
cppcoreguidelines-missing-std-forward,
google-build-explicit-make-pair,
google-global-names-in-headers,
hicpp-exception-baseclass,
bugprone-*,
-bugprone-branch-clone,
-bugprone-derived-method-shadowing-base-method,
-bugprone-easily-swappable-parameters,
-bugprone-implicit-widening-of-multiplication-result,
-bugprone-inc-dec-in-conditions,
-bugprone-macro-parentheses,
-bugprone-multi-level-implicit-pointer-conversion,
-bugprone-narrowing-conversions,
-bugprone-signed-char-misuse,
-bugprone-switch-missing-default-case,
-bugprone-throwing-static-initialization,
-bugprone-unchecked-string-to-number-conversion,
concurrency-*,
-concurrency-mt-unsafe,
misc-*,
-misc-confusable-identifiers,
-misc-const-correctness,
-misc-header-include-cycle,
-misc-include-cleaner,
-misc-multiple-inheritance,
-misc-new-delete-overloads,
-misc-no-recursion,
-misc-non-private-member-variables-in-classes,
-misc-static-assert,
-misc-use-anonymous-namespace,
modernize-*,
-modernize-avoid-c-arrays,
-modernize-pass-by-value,
-modernize-return-braced-init-list,
-modernize-use-auto,
-modernize-use-default-member-init,
-modernize-use-designated-initializers,
-modernize-use-nodiscard,
-modernize-use-std-numbers,
-modernize-use-trailing-return-type,
performance-*,
-performance-enum-size,
-performance-no-int-to-ptr,
portability-*,
-portability-template-virtual-member-function,
readability-*,
-readability-avoid-nested-conditional-operator,
-readability-braces-around-statements,
-readability-convert-member-functions-to-static,
-readability-function-cognitive-complexity,
-readability-function-size,
-readability-identifier-length,
-readability-implicit-bool-conversion,
-readability-isolate-declaration,
-readability-magic-numbers,
-readability-make-member-function-const,
-readability-math-missing-parentheses,
-readability-named-parameter,
-readability-redundant-declaration,
-readability-use-anyofallof
WarningsAsErrors: '*'
HeaderFilterRegex: '(gecode|test|examples|tools)/'
ExcludeHeaderFilterRegex: 'gecode/flatzinc/(parser\.tab\.(cpp|hpp)|lexer\.yy\.cpp)$'
Expand All @@ -42,6 +91,22 @@ FormatStyle: file
CheckOptions:
# Explicit discards document intentional ownership handoffs.
bugprone-unused-return-value.AllowCastToVoid: true
bugprone-empty-catch.IgnoreCatchWithKeywords: 'Expected;Ignored'
# main reports nothing useful by catching, and the move members this
# reports are implicit ones of value types and lambdas.
bugprone-exception-escape.CheckMain: false
bugprone-exception-escape.CheckMoveMemberFunctions: false
# glibc needs this feature macro defined before any system header.
bugprone-reserved-identifier.AllowedIdentifiers: '_GNU_SOURCE'
cert-err33-c.AllowCastToVoid: true
# Checking functions finds the real cases; classes and test registration
# objects in .cpp files would only need wrapping in anonymous namespaces.
misc-use-internal-linkage.AnalyzeTypes: false
misc-use-internal-linkage.AnalyzeVariables: false
# De Morgan rewrites do not make these conditions easier to read.
readability-simplify-boolean-expr.SimplifyDeMorgan: false
# Sites without a fix-it declare variables in the condition.
readability-else-after-return.WarnOnUnfixable: false
readability-identifier-naming.FunctionCase: lower_case
readability-identifier-naming.MethodCase: lower_case
readability-identifier-naming.VariableCase: lower_case
Expand Down
2 changes: 1 addition & 1 deletion .github/ci/32-bit-linkage-smoke.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ EOF
cat > "$consumer_dir/main.cpp" <<'EOF'
#include <gecode/search.hh>

int main(void) {
int main() {
Gecode::Search::Statistics statistics;
Gecode::Search::Options options;

Expand Down
2 changes: 1 addition & 1 deletion .github/ci/cmake-consumer-smoke-msys2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ cat > "$work/main.cpp" <<'EOF'
#include <gecode/int.hh>
#include <gecode/support/config.hpp>

int main(void) {
int main() {
Gecode::IntArgs values(1);
values[0] = 0;
return values[0];
Expand Down
6 changes: 3 additions & 3 deletions .github/ci/cmake-consumer-smoke-vcpkg.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ target_link_libraries(consumer_a PRIVATE Gecode::gecode)
'@ | Set-Content -Encoding utf8 (Join-Path $work "a\CMakeLists.txt")
@'
#include <gecode/support/config.hpp>
int main(void) { return 0; }
int main() { return 0; }
'@ | Set-Content -Encoding utf8 (Join-Path $work "a\main.cpp")

@'
Expand All @@ -61,7 +61,7 @@ target_link_libraries(consumer_b PRIVATE Gecode::gecodedriver)
'@ | Set-Content -Encoding utf8 (Join-Path $work "b\CMakeLists.txt")
@'
#include <gecode/driver.hh>
int main(void) {
int main() {
Gecode::Options options("consumer_b");
return options.model();
}
Expand Down Expand Up @@ -103,7 +103,7 @@ target_link_libraries(consumer_d PRIVATE Gecode::gecodefloat)
#error "Expected installed Gecode package to enable MPFR"
#endif
#include <gecode/float.hh>
int main(void) {
int main() {
Gecode::Float::Rounding rounding;
return rounding.exp_down(1.0) > 0.0 ? 0 : 1;
}
Expand Down
6 changes: 3 additions & 3 deletions .github/ci/cmake-consumer-smoke.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ target_link_libraries(consumer_a PRIVATE Gecode::gecode)
'@ | Set-Content -Encoding utf8 (Join-Path $work "a\CMakeLists.txt")
@'
#include <gecode/support/config.hpp>
int main(void) { return 0; }
int main() { return 0; }
'@ | Set-Content -Encoding utf8 (Join-Path $work "a\main.cpp")

@'
Expand All @@ -46,7 +46,7 @@ target_link_libraries(consumer_b PRIVATE Gecode::gecodedriver)
'@ | Set-Content -Encoding utf8 (Join-Path $work "b\CMakeLists.txt")
@'
#include <gecode/driver.hh>
int main(void) {
int main() {
Gecode::Options options("consumer_b");
return options.model();
}
Expand Down Expand Up @@ -131,7 +131,7 @@ target_link_libraries(manual_consumer PRIVATE "${GECODE_SUPPORT_LIBRARY}")
'@ | Set-Content -Encoding utf8 (Join-Path $work "manual\CMakeLists.txt")
@'
#include <gecode/support.hh>
int main(void) {
int main() {
(void) Gecode::Support::hwrnd();
return 0;
}
Expand Down
14 changes: 7 additions & 7 deletions .github/ci/cmake-consumer-smoke.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ target_link_libraries(consumer_a PRIVATE Gecode::gecode)
EOF
cat > "$work/a/main.cpp" <<'EOF'
#include <gecode/support/config.hpp>
int main(void) { return 0; }
int main() { return 0; }
EOF

cat > "$work/b/CMakeLists.txt" <<'EOF'
Expand All @@ -70,7 +70,7 @@ target_link_libraries(consumer_b PRIVATE Gecode::gecodedriver)
EOF
cat > "$work/b/main.cpp" <<'EOF'
#include <gecode/driver.hh>
int main(void) {
int main() {
Gecode::Options options("consumer_b");
return options.model();
}
Expand Down Expand Up @@ -116,7 +116,7 @@ cat > "$work/d/main.cpp" <<'EOF'
#error "Expected installed Gecode package to enable MPFR"
#endif
#include <gecode/float.hh>
int main(void) {
int main() {
Gecode::Float::Rounding rounding;
return rounding.exp_down(1.0) > 0.0 ? 0 : 1;
}
Expand Down Expand Up @@ -145,7 +145,7 @@ cat > "$work/e/main.cpp" <<'EOF'
#error "Expected installed Gecode package to enable MPFR"
#endif
#include <gecode/float.hh>
int main(void) {
int main() {
Gecode::Float::Rounding rounding;
return rounding.log_down(2.0) >= 0.0 ? 0 : 1;
}
Expand All @@ -172,7 +172,7 @@ target_link_libraries(consumer_f PRIVATE ${Gecode_LIBRARIES})
EOF
cat > "$work/f/main.cpp" <<'EOF'
#include <gecode/support.hh>
int main(void) { return Gecode::Support::Thread::npu() > 0 ? 0 : 1; }
int main() { return Gecode::Support::Thread::npu() > 0 ? 0 : 1; }
EOF

cat > "$work/g/CMakeLists.txt" <<'EOF'
Expand Down Expand Up @@ -209,7 +209,7 @@ target_link_libraries(consumer_j PRIVATE ${Gecode_LIBRARIES})
EOF
cat > "$work/j/main.cpp" <<'EOF'
#include <gecode/gist.hh>
int main(void) { return 0; }
int main() { return 0; }
EOF

cat > "$work/k/CMakeLists.txt" <<'EOF'
Expand All @@ -228,7 +228,7 @@ target_link_libraries(consumer_k PRIVATE ${Gecode_LIBRARIES})
EOF
cat > "$work/k/main.cpp" <<'EOF'
#include <gecode/float.hh>
int main(void) { Gecode::Float::Rounding rounding; return rounding.sqrt_down(4.0) == 2.0 ? 0 : 1; }
int main() { Gecode::Float::Rounding rounding; return rounding.sqrt_down(4.0) == 2.0 ? 0 : 1; }
EOF

cat > "$work/l/CMakeLists.txt" <<'EOF'
Expand Down
2 changes: 1 addition & 1 deletion .github/ci/qt-gist-consumer-smoke.sh
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ using FloatCompare = std::string (*)(const std::string&, Gecode::FloatVar, Gecod
FloatCompare float_compare = &Gecode::Gist::Comparator::compare;
#endif

int main(void) {
int main() {
#ifdef GECODE_HAS_SET_VARS
if (set_compare == nullptr)
return 1;
Expand Down
2 changes: 1 addition & 1 deletion .github/ci/qt5-gist-consumer-smoke.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ using FloatCompare = std::string (*)(const std::string&, Gecode::FloatVar, Gecod
FloatCompare float_compare = &Gecode::Gist::Comparator::compare;
#endif

int main(void) {
int main() {
#ifdef GECODE_HAS_SET_VARS
if (set_compare == nullptr)
return 1;
Expand Down
17 changes: 17 additions & 0 deletions changelog.in
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,23 @@ Date: unreleased
This release contains breaking changes. See the entries below for the
changes downstream code needs.

[ENTRY]
Module: flatzinc
What: change
Rank: minor
[DESCRIPTION]
Derive FlatZinc::Error and FlatZinc::AST::TypeError from std::exception, so that
a handler for std::exception also catches them. AST::TypeError::what now returns
const char* instead of std::string.

[ENTRY]
Module: flatzinc
What: bug
Rank: minor
[DESCRIPTION]
Give FlatZinc::BranchPlugin a virtual destructor, so that a plugin deleted
through its interface is destroyed correctly.

[ENTRY]
Module: other
What: change
Expand Down
Loading
Loading