Merge remote-tracking branch 'origin/topic/timw/clang-tidy-fix'

* origin/topic/timw/clang-tidy-fix:
  Fix use-after-move reported by clang-tidy
This commit is contained in:
Tim Wojtulewicz 2025-07-31 10:34:43 -07:00
commit b9a5a635bd
3 changed files with 10 additions and 4 deletions

View file

@ -1,3 +1,9 @@
8.0.0-dev.817 | 2025-07-31 10:34:43 -0700
* Fix use-after-move reported by clang-tidy (Tim Wojtulewicz, Corelight)
This was introduced by 9eb94ee151ec437fd076ef16d016af372391af65.
8.0.0-dev.815 | 2025-07-31 16:10:33 +0100 8.0.0-dev.815 | 2025-07-31 16:10:33 +0100
* Add tests for the deprecated-dpd-log.zeek policy script (Johanna Amann, Corelight) * Add tests for the deprecated-dpd-log.zeek policy script (Johanna Amann, Corelight)

View file

@ -1 +1 @@
8.0.0-dev.815 8.0.0-dev.817

View file

@ -1022,8 +1022,6 @@ private:
int i = 0; int i = 0;
for ( auto& ci : rt->creation_inits ) { for ( auto& ci : rt->creation_inits ) {
if ( ! ci.second->IsDeferrable() ) { if ( ! ci.second->IsDeferrable() ) {
rt->creation_inits[i++] = std::move(ci);
// A non-deferrable field with a &default attribute is expected to also exist in deferred_inits // A non-deferrable field with a &default attribute is expected to also exist in deferred_inits
// such that re-initialization after deletion of the field works. // such that re-initialization after deletion of the field works.
if ( rt->FieldDecl(ci.first)->GetAttr(detail::ATTR_DEFAULT) != detail::Attr::nil ) { if ( rt->FieldDecl(ci.first)->GetAttr(detail::ATTR_DEFAULT) != detail::Attr::nil ) {
@ -1031,10 +1029,12 @@ private:
zeek::reporter->InternalError("non-deferrable field %s$%s with &default not in deferred_inits", zeek::reporter->InternalError("non-deferrable field %s$%s with &default not in deferred_inits",
rt->GetName().c_str(), rt->FieldName(i)); rt->GetName().c_str(), rt->FieldName(i));
if ( rt->deferred_inits[ci.first] != rt->creation_inits[i - 1].second ) else if ( rt->deferred_inits[ci.first] != ci.second )
zeek::reporter->InternalError("non-deferrable field %s$%s with &default has inconsistent inits", zeek::reporter->InternalError("non-deferrable field %s$%s with &default has inconsistent inits",
rt->GetName().c_str(), rt->FieldName(i)); rt->GetName().c_str(), rt->FieldName(i));
} }
rt->creation_inits[i++] = std::move(ci);
} }
else { else {
// If deferred_inits already has a value, it should be the same as the one // If deferred_inits already has a value, it should be the same as the one