1
0
mirror of https://github.com/gabime/spdlog.git synced 2025-01-16 01:37:58 +00:00

Compare commits

...

3 Commits

Author SHA1 Message Date
Gabi Melman
0120dcc787
Update logger-inl.h 2020-02-29 13:20:26 +02:00
Gabi Melman
6bfc0ec3a7
Merge pull request #1457 from Ruffel/fix-clang-tidy-warning
Resolve erroneous clang-tidy warning about using a moved from pointer
2020-02-29 13:16:49 +02:00
Steven Cartmell
f999d879d5
fix: Break from loop on last iteration to resolve clang-tidy warning
The clang-tidy warning `clang-analyzer-cplusplus.Move` warns when a
moved from object is deferenced. This is triggered in spdlog because
clang-tidy fails to detect that the `logger:set_formatter` will only
move the unique_ptr on the last iteration of the loop, assuming that
`f->clone` may be called on it afterwards.

To fix, add a break statement after moving the pointer (on the last
iteration) to let clang-tidy know the logger pointer is not used after
this point.
2020-02-28 21:09:31 +00:00

View File

@ -89,6 +89,7 @@ SPDLOG_INLINE void logger::set_formatter(std::unique_ptr<formatter> f)
{
// last element - we can be move it.
(*it)->set_formatter(std::move(f));
break; // to prevent clang-tidy warning
}
else
{