From 319c427d2f97d39ac3e8dae892eb487330cedf82 Mon Sep 17 00:00:00 2001 From: Marc Chevrier Date: Mon, 1 Sep 2025 09:37:13 +0200 Subject: [PATCH] cmPropertySentinel: update definition Reported by https://pvs-studio.com/en/blog/posts/cpp/1277/ (N8) Issue: #27159 --- Source/cmState.cxx | 4 ++++ Source/cmStateDirectory.cxx | 6 +++--- Source/cmStatePrivate.h | 3 +-- Source/cmStateSnapshot.cxx | 3 ++- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/Source/cmState.cxx b/Source/cmState.cxx index 81f53c2a5e..16198f3e2c 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -27,6 +27,10 @@ #include "cmSystemTools.h" #include "cmake.h" +namespace cmStateDetail { +std::string const PropertySentinel = std::string{}; +} // namespace cmStateDetail + cmState::cmState(Mode mode, ProjectKind projectKind) : StateMode(mode) , StateProjectKind(projectKind) diff --git a/Source/cmStateDirectory.cxx b/Source/cmStateDirectory.cxx index 1c69b3bf3a..8f5ea97994 100644 --- a/Source/cmStateDirectory.cxx +++ b/Source/cmStateDirectory.cxx @@ -66,7 +66,7 @@ cmBTStringRange GetPropertyContent(T const& content, U contentEndPosition) auto end = content.begin() + contentEndPosition; auto rbegin = cm::make_reverse_iterator(end); - rbegin = std::find(rbegin, content.rend(), cmPropertySentinel); + rbegin = std::find(rbegin, content.rend(), cmStateDetail::PropertySentinel); return cmMakeRange(rbegin.base(), end); } @@ -130,7 +130,7 @@ void cmStateDirectory::PrependIncludeDirectoriesEntry( auto rend = this->DirectoryState->IncludeDirectories.rend(); auto rbegin = cm::make_reverse_iterator(entryEnd); - rbegin = std::find(rbegin, rend, cmPropertySentinel); + rbegin = std::find(rbegin, rend, cmStateDetail::PropertySentinel); auto entryIt = rbegin.base(); @@ -244,7 +244,7 @@ void cmStateDirectory::PrependLinkDirectoriesEntry(const BT& vec) auto rend = this->DirectoryState->LinkDirectories.rend(); auto rbegin = cm::make_reverse_iterator(entryEnd); - rbegin = std::find(rbegin, rend, cmPropertySentinel); + rbegin = std::find(rbegin, rend, cmStateDetail::PropertySentinel); auto entryIt = rbegin.base(); diff --git a/Source/cmStatePrivate.h b/Source/cmStatePrivate.h index afcf1fca95..44de663100 100644 --- a/Source/cmStatePrivate.h +++ b/Source/cmStatePrivate.h @@ -22,10 +22,9 @@ namespace cmStateDetail { struct BuildsystemDirectoryStateType; struct PolicyStackEntry; +extern std::string const PropertySentinel; } // namespace cmStateDetail -static std::string const cmPropertySentinel = std::string(); - struct cmStateDetail::SnapshotDataType { cmStateDetail::PositionType ScopeParent; diff --git a/Source/cmStateSnapshot.cxx b/Source/cmStateSnapshot.cxx index 3b35c4adb8..44f226704e 100644 --- a/Source/cmStateSnapshot.cxx +++ b/Source/cmStateSnapshot.cxx @@ -270,7 +270,8 @@ void InitializeContentFromParent(T& parentContent, T& thisContent, auto parentRbegin = cm::make_reverse_iterator(parentEnd); auto parentRend = parentContent.rend(); - parentRbegin = std::find(parentRbegin, parentRend, cmPropertySentinel); + parentRbegin = + std::find(parentRbegin, parentRend, cmStateDetail::PropertySentinel); auto parentIt = parentRbegin.base(); thisContent = std::vector>(parentIt, parentEnd);