Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ static IntegerRange createFromType(const ASTContext &Context,
llvm::APSInt LowerValue(PrecisionBits + 2, /*isUnsigned*/ false);
LowerValue.setBit(PrecisionBits);
LowerValue.setSignBit();
return {LowerValue, UpperValue};
return {std::move(LowerValue), UpperValue};
Copy link
Member

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

Copy link
Contributor

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?

Copy link
Contributor Author

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

Copy link
Contributor Author

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?

Copy link
Contributor Author

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

Good point. I was only addressing the issues that the sanitizer identified.

Copy link
Contributor

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.

}
assert(T.isInteger() && "Unexpected builtin type");
uint64_t TypeSize = Context.getTypeSize(&T);
Expand Down
2 changes: 1 addition & 1 deletion clang-tools-extra/clangd/ConfigCompile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Line 520: this can now be a make_unique.

for (auto &Regex : *Filters)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
for (auto &Regex : *Filters)
for (const auto &Regex : *Filters)

Same for both cases in other file.

if (Regex.match(Path))
return true;
Expand Down
2 changes: 1 addition & 1 deletion clang-tools-extra/clangd/Headers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Copy link
Member

Choose a reason for hiding this comment

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

same thing in line 315

if (Filter(Suggested)) {
IsAngled = true;
break;
Expand Down
Loading