[PATCH] D97183: [analyzer] Add NoteTag for smart-ptr get()
Raphael Isemann via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri May 21 01:04:21 PDT 2021
teemperor added inline comments.
================
Comment at: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp:243
+ // If b is a get() expression, then we can return a note
+ if (auto Report = bugReportOnGet(Node, BRC, RHS)) {
+ return Report;
----------------
LLVM-code style mandates no curly braces around single-line ifs.
================
Comment at: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp:256
+ BugReporterContext &BRC, const Stmt *S, const SVal InnerPtrVal) {
+ if (const auto *DS = llvm::dyn_cast<DeclStmt>(S)) {
+ const Decl *D = DS->getSingleDecl();
----------------
(I think this was already pointed out, but early-exits are the way to go in LLVM.
```
const auto *DS = llvm::dyn_cast<DeclStmt>(S));
if (!DS)
return nullptr;
const Decl *D = DS->getSingleDecl();
const auto *VD = llvm::dyn_cast<VarDecl>(D);
if (!VD)
return nullptr;
....
``
================
Comment at: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp:179-180
+ // P.get()
+ if (const auto *InnerCastExpr =
+ llvm::dyn_cast<ImplicitCastExpr>(Sub)) {
+ Sub = InnerCastExpr->getSubExpr();
----------------
RedDocMD wrote:
> vsavchenko wrote:
> > I think it's better to `IgnoreParensAndCasts` instead of manual traversal.
> What is IgnoreParensAndCasts`? I didn't find it in the source code anywhere (ripgrep, that is).
Just a typo, the actual name is `IgnoreParenCasts` (Expr::IgnoreParenCasts)
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D97183/new/
https://reviews.llvm.org/D97183
More information about the cfe-commits
mailing list