◐ Shell
clean mode source ↗

avoid unnecessary copy in `openHeader()` - detected by upcoming clang-tidy check `performance-unnecessary-copy-on-last-use` by firewave · Pull Request #276 · cppcheck-opensource/simplecpp

Conversation

@firewave

I looks like a false positive but using a non-POD variable in a ternary causes it to be copied - see https://reviews.llvm.org/D137205#3939210.

Since simplecpp also supports pre-C++11 standards std:move() could not be used and I refactored the code instead getting rid of the ternaries.

…-tidy check `performance-unnecessary-copy-on-last-use`

firewave

ret = openHeaderRelative(f, sourcefile, header);
return ret.empty() ? openHeaderIncludePath(f, dui, header) : ret;
if (ret.empty())
openHeaderIncludePath(f, dui, header);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing the return.

Like I pointed out in other PRs we need have tests which use include files (which need to exist on the filesystem).

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 participants

@firewave @danmar