[PATCH] D62883: [analyzer] Track conditions of terminator statements on which the reported node depends on
Artem Dergachev via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Jun 17 14:32:13 PDT 2019
NoQ added inline comments.
================
Comment at: clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp:1609-1613
+ if (B->rbegin()->getKind() != CFGElement::Kind::Statement)
+ return nullptr;
+
+ // This should be the condition of the terminator block.
+ const Stmt *S = B->rbegin()->castAs<CFGStmt>().getStmt();
----------------
A bit clearner:
```lang=c++
auto StmtElem = B->rbegin().getAs<CFGStmt>();
if (!StmtElem)
return nullptr;
const Stmt *S = StmtElem->getStmt();
```
Also how about `CFGBlock::getTerminatorCondition()`?
================
Comment at: clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp:1640-1642
+ CFGBlock *OriginB = GetRelevantBlock(Origin);
+ if (!OriginB || !NB)
+ return nullptr;
----------------
`// TODO: This can be cached.`
================
Comment at: clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp:1646
+ if (const Expr *Condition = getTerminatorCondition(NB))
+ if (BR.addTrackedCondition(Condition))
+ bugreporter::trackExpressionValue(
----------------
All right, i still don't understand this caching based on condition expression.
You mean, like, if we're encountering the same condition multiple times (say, in a loop), we should only track it once? Why? Like, its values (which are the thing we'll really be tracking) may be different (say, on different loop iterations).
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D62883/new/
https://reviews.llvm.org/D62883
More information about the cfe-commits
mailing list