-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[NFC] Fixes proposed by code sanitizer. #134138
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
Changes from 3 commits
608f582
5f453eb
0ab8d53
c9bfb44
c51acef
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -535,7 +535,7 @@ struct FragmentCompiler { | |||||
| } | ||||||
| if (Filters->empty()) | ||||||
| return std::nullopt; | ||||||
| auto Filter = [Filters](llvm::StringRef Path) { | ||||||
| auto Filter = [Filters = std::move(Filters)](llvm::StringRef Path) { | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Line 520: this can now be a |
||||||
| for (auto &Regex : *Filters) | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Same for both cases in other file. |
||||||
| if (Regex.match(Path)) | ||||||
| return true; | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -305,7 +305,7 @@ IncludeInserter::calculateIncludePath(const HeaderFile &InsertedHeader, | |
| if (llvm::sys::path::is_absolute(Suggested)) | ||
| return std::nullopt; | ||
| bool IsAngled = false; | ||
| for (auto Filter : AngledHeaders) { | ||
| for (auto &Filter : AngledHeaders) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same thing in line 315 |
||
| if (Filter(Suggested)) { | ||
| IsAngled = true; | ||
| break; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this doesn't have any impact.
And if using move, why not for a second too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this actually an antipattern? What exactly do you mean by "code sanitizer", can you show the actual error message?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the error message:
" LowerValue is passed-by-value as parameter to llvm::APSInt::APSInt(llvm::APSInt const &) /implicit =default/, when it could be moved instead"
"Use std::move(LowerValue) instead of LowerValue."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think this should be reverted?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. I was only addressing the issues that the sanitizer identified.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What tool did you use to get that error message?
I do not see the point of this change, please revert. We must not blindly do what tools tell us, we must critically think if they make sense or not.