Repository navigation
Enable modernize-use-nodiscard clang-tidy check - #126158
Conversation
…gests Enable the `modernize-use-nodiscard` clang-tidy check, which marks `const` member functions that return a value as `[[nodiscard]]`, so the compiler reports a discarded result with `-Wunused-result`. The attributes were added by running the check with `--fix` over all translation units of the clang-tidy build. Some `const` functions are mostly called for their side effect: they throw on failure, send a request, or signal an event, and the result is only a convenience. For them the attribute is not added, and the declaration has `NOLINT(modernize-use-nodiscard)`. Examples are `assertTableExpression`, `checkRemoteHostFilter`, `EventFD::read` and `EventFD::write`, `ExternalLoader::load` and `loadOrReload`, and `validateCodecAndGetPreprocessedAST`. Calls of pure getters made only to validate an argument or to trigger an exception (e.g. `getNameForValue` to check an enum value, or `CompressionCodecFactory::get` to check a codec) are cast to `void`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
alexey-milovidov
left a comment
There was a problem hiding this comment.
Reviewed, all good. This improves the code in general and eliminates potential bugs.
|
@alexey-milovidov are you sure you want to merge this? How can I review a 2200 file change PR? |
|
@PedroTadim as usual, just read it. |
|
It is very easy - don't hesitate, open the diff, and review if you'd like. Or leave it to me. |
|
Ok, let me try |
|
Why this is being labeled to |
…e-nodiscard Conflicts (412 files, mostly from the function-signatures refactor) are resolved by taking the `master` side of each hunk and re-applying `[[nodiscard]]` to lines that are otherwise unchanged.
Re-ran `run-clang-tidy -checks='-*,modernize-use-nodiscard' -fix` over the translation units touched by `master` since the previous merge base and by the conflict resolution, and cast to `void` the calls made only for validation or inside `EXPECT_THROW` (`reinterpretAs` signature check and three gtests). Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🕵 @PedroTadim it is how I have also merged |
|
Workflow [PR], commit [f415f9e] Summary: ✅
AI ReviewSummaryEnables Final Verdict✅ Approve. No changes requested. |
…e-nodiscard # Conflicts: # src/Interpreters/DiskSet.h # src/Interpreters/DiskSetImpl.h # src/Processors/Transforms/DistinctSetFilter.h # src/Storages/MergeTree/MergeTreeReaderIndex.h
Fix the `modernize-use-nodiscard` findings of the `arm_tidy` build and the new ones from the latest merge of `master`. https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=126158&sha=ec2c275be42d7af1b235c4b47d253b6ebb63ffe2&name_0=PR #126158 Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts: # src/DataTypes/Serializations/ISerialization.h # src/DataTypes/Serializations/SerializationDynamic.cpp # src/DataTypes/Serializations/SerializationDynamic.h # src/DataTypes/Serializations/SerializationDynamicElement.cpp # src/DataTypes/Serializations/SerializationLowCardinality.cpp # src/DataTypes/Serializations/SerializationMap.cpp # src/DataTypes/Serializations/SerializationMap.h # src/DataTypes/Serializations/SerializationMapKeyValue.cpp # src/DataTypes/Serializations/SerializationMapKeysOrValues.cpp # src/DataTypes/Serializations/SerializationMapSize.cpp # src/DataTypes/Serializations/SerializationObject.cpp # src/DataTypes/Serializations/SerializationObject.h # src/DataTypes/Serializations/SerializationObjectCombinedPath.cpp # src/DataTypes/Serializations/SerializationObjectDistinctPaths.cpp # src/DataTypes/Serializations/SerializationObjectDynamicPath.cpp # src/DataTypes/Serializations/SerializationObjectSharedData.cpp # src/DataTypes/Serializations/SerializationObjectSharedData.h # src/DataTypes/Serializations/SerializationObjectSharedDataPath.cpp # src/DataTypes/Serializations/SerializationSparse.cpp # src/DataTypes/Serializations/SerializationString.h # src/DataTypes/Serializations/SerializationSubObject.cpp # src/DataTypes/Serializations/SerializationSubObjectSharedData.cpp # src/DataTypes/Serializations/SerializationTuple.cpp # src/DataTypes/Serializations/SerializationVariant.cpp # src/DataTypes/Serializations/SerializationVariant.h # src/DataTypes/Serializations/SerializationVariantElement.cpp # src/DataTypes/Serializations/SerializationVariantElementNullMap.cpp # src/Disks/DiskObjectStorage/MetadataStorages/Web/MetadataStorageFromIndexPages.h # src/Disks/DiskObjectStorage/ObjectStorages/AzureBlobStorage/AzureBlobStorageCommon.h # src/Functions/FunctionsNullSafeCmp.h # src/Functions/geoToH3.cpp # src/Functions/icebergTruncate.cpp # src/Functions/identity.h # src/Functions/toNullable.cpp # src/Functions/toTypeName.cpp # src/Interpreters/IJoin.h # src/Processors/Formats/Impl/ArrowIPC/RecordBatchDecoder.h # src/Processors/QueryPlan/JoinStepLogical.h # src/Processors/QueryPlan/Optimizations/applyStreamDisjointness.cpp # src/Storages/MergeTree/MergeTreeIndices.h # src/Storages/Statistics/StatisticsBasic.h # src/Storages/StorageMerge.h
Fix the new `modernize-use-nodiscard` findings from the latest merge of `master`, found by running the check over the translation units touched by `master` since the previous merge. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The `arm_tidy` build also checks the `unit_tests_dbms` translation units, which the previous pass missed. Fix the `modernize-use-nodiscard` findings there, found by running the check over all unit test sources. https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=126158&sha=3e3b2b40b8056460a15828c5499877cc72b48a4c&name_0=PR&name_1=Build%20%28arm_tidy%2C%201%2F4%29 #126158 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
@alexey-milovidov are you sure you want to continue with this? |
…e-nodiscard Conflicts were resolved by taking the code from `master` and keeping the `[[nodiscard]]` attributes the PR added to the unchanged declarations.
Fix the new `modernize-use-nodiscard` findings from the latest merge of `master`, found by running the check over the translation units touched by `master` since the previous merge. `checkOrDropServerManagedCredentials` is marked with `NOLINT` instead, because some callers use it only for the exception it throws. https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=126158&sha=819057700fb473a4fd61aa567b1fd21f73e2e8ff&name_0=PR&name_1=Build%20%28arm_tidy%2C%201%2F4%29 #126158 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🕵 Merged the latest |
# Conflicts: # src/AggregateFunctions/Combinators/AggregateFunctionNull.h # src/Client/BuzzHouse/Generator/SQLCatalog.h # src/Disks/DiskObjectStorage/MetadataStorages/PlainRewritable/PlainRewritableLayout.h # src/Disks/DiskObjectStorage/ObjectStorages/Cached/CachedObjectStorage.h # src/Functions/FunctionBaseAI.h # src/Functions/FunctionTopKFilter.cpp # src/Functions/IFunction.h # src/Functions/aiEmbed.cpp # src/Functions/aiSimilarity.cpp # src/IO/S3/ReadBufferFromGetObjectResult.h # src/Interpreters/Set.h # src/Processors/Formats/Impl/ArrowIPC/RecordBatchDecoder.h # src/Processors/Formats/Impl/ParquetMetadataCache.h # src/Processors/QueryPlan/IQueryPlanStep.h # src/Processors/QueryPlan/JoinStepLogical.h # src/Processors/QueryPlan/SourceStepWithFilter.h # src/Storages/ObjectStorage/DataLakes/IDataLakeMetadata.h # src/Storages/ObjectStorage/StorageObjectStorageConfiguration.h
Fixes the `modernize-use-nodiscard` findings in the `arm_tidy` builds (e.g. `jsonRemove.cpp`, `ALPEncoding.cpp`), found by running `clang-tidy` with this check over the files changed on `master` since the start of the PR. https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=126158&sha=6f42c86f18d378ba7d21f25a3b439eb322319586&name_0=PR&name_1=Build%20%28arm_tidy%2C%202%2F4%29 #126158 Co-Authored-By: Claude Opus 5.5 <[email protected]>
ClickHouse#131664 added the declaration while ClickHouse#126158 enabled modernize-use-nodiscard; each passed CI on its own, together they break the clang-tidy build on master. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…-order-dry-run-not-ready-set Resolve the conflict in `src/Functions/array/arrayFold.cpp`: master added `[[nodiscard]]` to `executeImpl` (`modernize-use-nodiscard`, ClickHouse#126158), which this branch split into `executeImpl`, `executeImplDryRun` and `executeImplCommon`. All three now carry `[[nodiscard]]`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Master enables clang-tidy `modernize-use-nodiscard` (ClickHouse#126158) and marks every `executeImpl` `[[nodiscard]]`; the `executeImplDryRun` and `executeImplCommon` overrides added by this branch get the same attribute. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Conflict in src/Analyzer/TrivialGroupByLimit.cpp: master added `[[nodiscard]]` to `CheckArrayJoinExistsVisitor` (ClickHouse#126158), which this branch moved to src/Analyzer/Utils.cpp. Keep the move and add the two `[[nodiscard]]` attributes there, as `modernize-use-nodiscard` now requires. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…uffer-insert-auth-ebd9 Resolve the conflicts with #125946 and #126158. - `StorageBuffer::writeBlockToDestination` keeps the identity and the flush stage of this branch and takes master's `query_context`: the direct write passes the inserting query's context to share its `max_threads` snapshot, a flush passes `nullptr` as on master. The snapshot is shared on the context this branch builds before restoring the identity. - `getSQLSecurityOverriddenContext` keeps both master's snapshot sharing and the background-operation marker of this branch. - `AsynchronousInsertQueue::InsertQuery::toTupleCmp` keeps master's `[[nodiscard]]` and the `auth_initial_address` key of this branch. Co-authored-by: yakov <[email protected]>
…h-dynamic-json Resolve the conflicts with the `[[nodiscard]]` attributes of ClickHouse#126158 in `MergedData.h` and `MergingSortedAlgorithm.h`, and mark the new const getters `extraBytesPerRow` and `maxBlockSizeBytes` `[[nodiscard]]` as well, since master now enables `modernize-use-nodiscard`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
modernize-use-nodiscard is enabled on master since ClickHouse#126158. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Master now enforces clang-tidy `modernize-use-nodiscard` (ClickHouse#126158), so the `canRejectValues` overrides get `[[nodiscard]]` like the neighbouring `isTrivial` overrides, and bans plain `std::vector` in `src/Processors/Formats` (ClickHouse#126530), so the decode ranges use `VectorWithMemoryTracking`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
`modernize-use-nodiscard`, enabled on master by #126158, flags them in the tidy build: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=131080&sha=880cf81312c55ffe12826730ffb6729b3ca71a12&name_0=PR&name_1=Build%20%28arm_tidy%2C%204%2F4%29 Co-authored-by: yakov <[email protected]>
`modernize-use-nodiscard` of clang-tidy is enabled on master since 2026-11-15, and the new `enumerateSettings` and `enumerateSettingsWithConstraints` const methods of the engine settings failed the tidy build without the attribute. https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=123041&sha=cd63e43cc1f37c1d7ee95901c404cc54aace9c1b&name_0=PR&name_1=Build%20%28arm_tidy%2C%201%2F4%29 Related: ClickHouse#123041 Related: ClickHouse#126158 Co-Authored-By: Claude Opus 5.5 <[email protected]>
master enabled the `modernize-use-nodiscard` clang-tidy check in ClickHouse#126158, after this PR's last CI run. The merge queue's `Clang-tidy (changed files)` job then flagged the new declaration (RuntimeFilterLookup.h:251 in the merge commit) and removed the PR from the queue. This matches master's `ExactSetRuntimeFilter::getValuesColumn`, which the same check annotated. Co-Authored-By: Claude Opus 5.5 <[email protected]>
`modernize-use-nodiscard`, enabled on master by ClickHouse#126158, flags it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…w-defer-plan-optimization Since ClickHouse#130552 a DEFINER view read by its definer is not sealed, so the views of the clone cases in 05257 now have another definer: the default user still reads them sealed with the plan visible. ReadFromSealedViewStep takes the comment on getBuiltChildPlans that ClickHouse#132608 added to the class in StorageView.cpp, and [[nodiscard]] for modernize-use-nodiscard (ClickHouse#126158). Co-Authored-By: Claude Opus 5.5 <[email protected]>
`modernize-use-nodiscard` is enabled on master (ClickHouse#126158); the other virtual predicates of `SourceStepWithFilterBase` carry the attribute too. Co-Authored-By: Claude Opus 5.5 <[email protected]>
clang-tidy's modernize-use-nodiscard (on since ClickHouse#126158) failed every Build (arm_tidy) shard on LegacyHeaderNames::empty, and on getLegacyName, hasNoCandidates and the const getLegacyActionNodeNames in PlannerContext.h. Test comments: say "case" instead of "arm", and stop claiming the quoting helper treats exactly six words as keywords (master quotes more). Co-Authored-By: Claude Opus 5.5 <[email protected]>
Resolve the conflicts of the cherry-pick of #132416 to 26.9. The fix applies in full; the differences from the original diff come only from master-only neighbours that 26.9 does not have: - `ArrowIPCBlockInputFormat.cpp`: 26.9 still checks that dictionary values are unique after registering them (master dropped the check in #125677). Keep the check and look the values up by the dictionary use, as the registry is now keyed by it. - `RecordBatchDecoder.cpp`: 26.9 has no `TypeKind::RunEndEncoded` case in `collectDictionaryUses` (run-end encoding, #126207, is master-only), so there is no call to pass `below_union` to there. The struct case keeps the 26.9 helpers `tupleElementHint` / `childPath` (master renamed them in #125674) and passes `below_union` as the original change does. - `RecordBatchDecoder.cpp`: include `base/scope_guard.h` for the two new `SCOPE_EXIT` uses. On master the include came with the big-endian reader (#126562); 26.9 does not include it, directly or transitively. - `RecordBatchDecoder.h`: no `[[nodiscard]]` on the changed declarations, as on the rest of the 26.9 file (master added them in #126158). Co-authored-by: yakov <[email protected]>
Resolve the conflicts of the cherry-pick of #132416 to 26.10. The fix applies in full; the differences from the original diff come only from master-only neighbours that 26.10 does not have: - `RecordBatchDecoder.cpp`: 26.10 has no `TypeKind::RunEndEncoded` case in `collectDictionaryUses` (run-end encoding, #126207, is master-only), so there is no call to pass `below_union` to there. The struct case keeps the 26.10 helpers `tupleElementHint` / `childPath` (master renamed them in #125674) and passes `below_union` as the original change does. - `RecordBatchDecoder.cpp`: include `base/scope_guard.h` for the two new `SCOPE_EXIT` uses. On master the include came with the big-endian reader (#126562); 26.10 does not include it, directly or transitively. - `RecordBatchDecoder.h`: no `[[nodiscard]]` on the changed declarations, as on the rest of the 26.10 file (master added them in #126158). Co-authored-by: yakov <[email protected]>
…g-merge-no-per-row-rowref Conflicts resolved against master: - ClickHouse#126158 added [[nodiscard]] to lines this PR edits: kept, except on RowRefWithOwnedChunk::firstNonEqualSortColumnsWith, which this PR removes. - ClickHouse#131513 gated the part-level shortcut of rowsHaveDifferentSortColumns with nonzero_level_parts_have_unique_keys: the cursor overload keeps that gate, so CollapsingMergeTree still compares rows of merged parts. - ClickHouse#131560 counts selected rows in vertical FINAL: kept, the selection is appended with push_back instead of insert(Field). Co-Authored-By: Claude Opus 5.5 <[email protected]>
…scard]] Master enabled `modernize-use-nodiscard` (ClickHouse#126158), which flags them. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Enable the
modernize-use-nodiscardclang-tidy check, which was disabled in.clang-tidy. It marksconstmember functions that return a value as[[nodiscard]], so-Wunused-result(an error with-Werror) catches a call whose result is dropped by mistake.The attributes were added by running the check with
--fixover all non-contrib translation units of the clang-tidy build (aarch64). About 14k declarations in 2200 files are changed.Some
constfunctions are mostly called for their side effect: they throw on failure, send a request, or signal an event, and the result is only a convenience. These get no attribute and are markedNOLINT(modernize-use-nodiscard)instead:assertTableExpression,checkRemoteHostFilter,EventFD::read/write,ExternalLoader::load/loadOrReload/reloadAllTriedToLoad,unloadDictionary,validateCodecAndGetPreprocessedAST,forEachPair,iterateGroups,finishWriting,checkTimeLimit,assertValid,SubmitBatch, and ACMEdoJWSRequest/finalizeOrder.Calls of pure getters made only for validation or to trigger an exception (e.g.
getNameForValueto check an enum value,CompressionCodecFactory::getto check a codec, and getters insideEXPECT_THROWin gtests) are cast tovoid.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Enable the
modernize-use-nodiscardclang-tidy check and add[[nodiscard]]toconstmember functions.🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/126158]
Version info
26.11.1.2395-master(included in26.11and later)