-
Notifications
You must be signed in to change notification settings - Fork 14.9k
[clang-tidy][NFC] Enable performance-unnecessary-value-param in the codebase
#163686
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
base: main
Are you sure you want to change the base?
Changes from all commits
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 |
|---|---|---|
|
|
@@ -65,7 +65,8 @@ void NonTrivialTypesLibcMemoryCallsCheck::storeOptions( | |
| void NonTrivialTypesLibcMemoryCallsCheck::registerMatchers( | ||
| MatchFinder *Finder) { | ||
| using namespace ast_matchers::internal; | ||
| auto IsStructPointer = [](Matcher<CXXRecordDecl> Constraint = anything(), | ||
| auto IsStructPointer = [](const Matcher<CXXRecordDecl> &Constraint = | ||
| anything(), | ||
| bool Bind = false) { | ||
| return expr(unaryOperator( | ||
| hasOperatorName("&"), | ||
|
|
@@ -76,7 +77,7 @@ void NonTrivialTypesLibcMemoryCallsCheck::registerMatchers( | |
| auto IsRecordSizeOf = | ||
| expr(sizeOfExpr(hasArgumentOfType(equalsBoundNode("Record")))); | ||
| auto ArgChecker = [&](Matcher<CXXRecordDecl> RecordConstraint, | ||
|
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. This is strange: why |
||
| BindableMatcher<Stmt> SecondArg = expr()) { | ||
| const BindableMatcher<Stmt> &SecondArg = expr()) { | ||
| return allOf(argumentCountIs(3), | ||
| hasArgument(0, IsStructPointer(RecordConstraint, true)), | ||
| hasArgument(1, SecondArg), hasArgument(2, IsRecordSizeOf)); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -464,10 +464,9 @@ createOptionsProvider(llvm::IntrusiveRefCntPtr<vfs::FileSystem> FS) { | |
| } | ||
|
|
||
| static llvm::IntrusiveRefCntPtr<vfs::FileSystem> | ||
| getVfsFromFile(const std::string &OverlayFile, | ||
| llvm::IntrusiveRefCntPtr<vfs::FileSystem> BaseFS) { | ||
| getVfsFromFile(const std::string &OverlayFile, vfs::FileSystem &BaseFS) { | ||
|
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 question about |
||
| llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> Buffer = | ||
| BaseFS->getBufferForFile(OverlayFile); | ||
| BaseFS.getBufferForFile(OverlayFile); | ||
| if (!Buffer) { | ||
| llvm::errs() << "Can't load virtual filesystem overlay file '" | ||
| << OverlayFile << "': " << Buffer.getError().message() | ||
|
|
@@ -583,7 +582,7 @@ static llvm::IntrusiveRefCntPtr<vfs::OverlayFileSystem> createBaseFS() { | |
|
|
||
| if (!VfsOverlay.empty()) { | ||
| IntrusiveRefCntPtr<vfs::FileSystem> VfsFromFile = | ||
| getVfsFromFile(VfsOverlay, BaseFS); | ||
| getVfsFromFile(VfsOverlay, *BaseFS); | ||
| if (!VfsFromFile) | ||
| return nullptr; | ||
| BaseFS->pushOverlay(std::move(VfsFromFile)); | ||
|
|
||
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.
How could we know that original object of
OverlayFileSystem &will outlive this reference. From docs I assume thatIntrusiveRefCntPtrhasshared_ptrsemantics but this convertion to reference seems bugprone.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.
It will be easier to accept if we write
const IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem>&or move the pointerUh oh!
There was an error while loading. Please reload this page.
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.
It’s possible that the referenced object is destroyed right after this function ends, but that’s okay, because this function doesn’t store the reference anywhere, so it can’t dangle. The equation doesn’t change even if the function takes an
IntrusiveRefCntPtr: it could be the last pointer to this object, so when the function ends, the pointed-to object is destroyed. Same argument applies to the other case below.