[all-commits] [llvm/llvm-project] 16cb3b: [analyzer] Deadstore static analysis: Fix false po...
Fred Tingaud via All-commits
all-commits at lists.llvm.org
Tue Aug 23 09:34:04 PDT 2022
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 16cb3be62600621361644ebd15d071c711d6aa86
https://github.com/llvm/llvm-project/commit/16cb3be62600621361644ebd15d071c711d6aa86
Author: Fred Tingaud <frederic.tingaud at sonarsource.com>
Date: 2022-08-23 (Tue, 23 Aug 2022)
Changed paths:
M clang/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp
M clang/test/Analysis/dead-stores.cpp
Log Message:
-----------
[analyzer] Deadstore static analysis: Fix false positive on C++17 assignments
Dead store detection automatically checks that an expression is a
CXXConstructor and skips it because of potential side effects. In C++17,
with guaranteed copy elision, this check can fail because we actually
receive the implicit cast of a CXXConstructor.
Most checks in the dead store analysis were already stripping all casts
and parenthesis and those that weren't were either forgotten (like the
constructor) or would not suffer from it, so this patch proposes to
factorize the stripping.
It has an impact on where the dead store warning is reported in the case
of an explicit cast, from
auto a = static_cast<B>(A());
^~~~~~~~~~~~~~~~~~~
to
auto a = static_cast<B>(A());
^~~
which we think is an improvement.
Patch By: frederic-tingaud-sonarsource
Reviewed By: steakhal
Differential Revision: https://reviews.llvm.org/D126534
More information about the All-commits
mailing list