[PATCH] D137205: [clang-tidy] Add performance-unnecessary-copy-on-last-use check
Aaron Gokaslan via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sun Nov 13 09:45:59 PST 2022
Skylion007 added a comment.
The main false positive I also keep seeing is in pybind11 where it suggests call an std::move() for an implicit conversion, but the target of the implicit conversion does not have an rvalue. (In this case, we have a py::object which inherits from py::handle, and is just py::handle with ownership semantics. This allows implicit conversion to a reference at anytime, and therefore std::move has no effect here except to complicate the code a bit.
================
Comment at: clang-tools-extra/clang-tidy/performance/UnnecessaryCopyOnLastUseCheck.cpp:114-115
+static Usage definiteLastUse(ASTContext *Context, CFG *const TheCFG,
+ DeclRefExpr const *DeclRef) {
+ assert(TheCFG != nullptr);
+
----------------
This assertion is not valid. The crash I linked above is due to "TheCFG" sometimes being null unfortunately. Making it return Usage::Error stops the crash at least. Seems to happen when it cannot find an include .
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D137205/new/
https://reviews.llvm.org/D137205
More information about the cfe-commits
mailing list