Skip to content

avoid unnecessary copy in openHeader() - detected by upcoming clang-tidy check performance-unnecessary-copy-on-last-use #276

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 20, 2022

Conversation

firewave
Copy link
Collaborator

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`
@danmar danmar merged commit 501c9c6 into danmar:master Nov 20, 2022
@firewave firewave deleted the last-use branch November 20, 2022 11:17
}

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

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).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed in #281.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants