<div dir="ltr">Hi Daniel,<br><br>This revision introduced warnings on one our of builders:<br><a href="http://lab.llvm.org:8011/builders/clang-3stage-ubuntu/builds/4719">http://lab.llvm.org:8011/builders/clang-3stage-ubuntu/builds/4719</a><br> <br>The warnings:<br><br>/home/buildbot/Buildbot/Slave1a/clang-3stage-ubuntu/llvm.src/tools/clang/lib/StaticAnalyzer/Core/CoreEngine.cpp:316:59: warning: suggest parentheses around assignment used as truth value [-Wparentheses]<br>/home/buildbot/Buildbot/Slave1a/clang-3stage-ubuntu/llvm.src/tools/clang/lib/StaticAnalyzer/Core/CoreEngine.cpp:316:16: warning: using the result of an assignment as a condition without parentheses [-Wparentheses]<br>1 warning generated.<br>/home/buildbot/Buildbot/Slave1a/clang-3stage-ubuntu/llvm.src/tools/clang/lib/StaticAnalyzer/Core/CoreEngine.cpp:316:16: warning: using the result of an assignment as a condition without parentheses [-Wparentheses]<br>1 warning generated.<br><br>Please have a look?<br><br>Thanks<br><br>Galina<br><br><br><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Oct 7, 2016 at 7:21 AM, Daniel Marjamaki via cfe-commits <span dir="ltr"><<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: danielmarjamaki<br>
Date: Fri Oct 7 09:21:08 2016<br>
New Revision: 283554<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=283554&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project?rev=283554&view=rev</a><br>
Log:<br>
[analyzer] Don't merge different return nodes in ExplodedGraph<br>
<br>
Returns when calling an inline function should not be merged in the ExplodedGraph unless they are same.<br>
<br>
Differential Revision: <a href="https://reviews.llvm.org/D25326" rel="noreferrer" target="_blank">https://reviews.llvm.org/<wbr>D25326</a><br>
<br>
Modified:<br>
cfe/trunk/include/clang/<wbr>Analysis/ProgramPoint.h<br>
cfe/trunk/include/clang/<wbr>StaticAnalyzer/Core/<wbr>PathSensitive/CoreEngine.h<br>
cfe/trunk/include/clang/<wbr>StaticAnalyzer/Core/<wbr>PathSensitive/ExprEngine.h<br>
cfe/trunk/include/clang/<wbr>StaticAnalyzer/Core/<wbr>PathSensitive/SubEngine.h<br>
cfe/trunk/lib/StaticAnalyzer/<wbr>Core/CoreEngine.cpp<br>
cfe/trunk/lib/StaticAnalyzer/<wbr>Core/ExprEngine.cpp<br>
cfe/trunk/test/Analysis/<wbr>inlining/<wbr>InlineObjCClassMethod.m<br>
cfe/trunk/test/Analysis/<wbr>unreachable-code-path.c<br>
<br>
Modified: cfe/trunk/include/clang/<wbr>Analysis/ProgramPoint.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/ProgramPoint.h?rev=283554&r1=283553&r2=283554&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/include/<wbr>clang/Analysis/ProgramPoint.h?<wbr>rev=283554&r1=283553&r2=<wbr>283554&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/include/clang/<wbr>Analysis/ProgramPoint.h (original)<br>
+++ cfe/trunk/include/clang/<wbr>Analysis/ProgramPoint.h Fri Oct 7 09:21:08 2016<br>
@@ -622,8 +622,8 @@ private:<br>
class CallExitBegin : public ProgramPoint {<br>
public:<br>
// CallExitBegin uses the callee's location context.<br>
- CallExitBegin(const StackFrameContext *L)<br>
- : ProgramPoint(nullptr, CallExitBeginKind, L, nullptr) {}<br>
+ CallExitBegin(const StackFrameContext *L, const ReturnStmt *RS)<br>
+ : ProgramPoint(RS, CallExitBeginKind, L, nullptr) { }<br>
<br>
private:<br>
friend class ProgramPoint;<br>
<br>
Modified: cfe/trunk/include/clang/<wbr>StaticAnalyzer/Core/<wbr>PathSensitive/CoreEngine.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h?rev=283554&r1=283553&r2=283554&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/include/<wbr>clang/StaticAnalyzer/Core/<wbr>PathSensitive/CoreEngine.h?<wbr>rev=283554&r1=283553&r2=<wbr>283554&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/include/clang/<wbr>StaticAnalyzer/Core/<wbr>PathSensitive/CoreEngine.h (original)<br>
+++ cfe/trunk/include/clang/<wbr>StaticAnalyzer/Core/<wbr>PathSensitive/CoreEngine.h Fri Oct 7 09:21:08 2016<br>
@@ -109,7 +109,8 @@ private:<br>
CoreEngine(const CoreEngine &) = delete;<br>
void operator=(const CoreEngine &) = delete;<br>
<br>
- ExplodedNode *generateCallExitBeginNode(<wbr>ExplodedNode *N);<br>
+ ExplodedNode *generateCallExitBeginNode(<wbr>ExplodedNode *N,<br>
+ const ReturnStmt *RS);<br>
<br>
public:<br>
/// Construct a CoreEngine object to analyze the provided CFG.<br>
@@ -172,7 +173,7 @@ public:<br>
<br>
/// \brief enqueue the nodes corresponding to the end of function onto the<br>
/// end of path / work list.<br>
- void enqueueEndOfFunction(<wbr>ExplodedNodeSet &Set);<br>
+ void enqueueEndOfFunction(<wbr>ExplodedNodeSet &Set, const ReturnStmt *RS);<br>
<br>
/// \brief Enqueue a single node created as a result of statement processing.<br>
void enqueueStmtNode(ExplodedNode *N, const CFGBlock *Block, unsigned Idx);<br>
<br>
Modified: cfe/trunk/include/clang/<wbr>StaticAnalyzer/Core/<wbr>PathSensitive/ExprEngine.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h?rev=283554&r1=283553&r2=283554&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/include/<wbr>clang/StaticAnalyzer/Core/<wbr>PathSensitive/ExprEngine.h?<wbr>rev=283554&r1=283553&r2=<wbr>283554&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/include/clang/<wbr>StaticAnalyzer/Core/<wbr>PathSensitive/ExprEngine.h (original)<br>
+++ cfe/trunk/include/clang/<wbr>StaticAnalyzer/Core/<wbr>PathSensitive/ExprEngine.h Fri Oct 7 09:21:08 2016<br>
@@ -262,7 +262,8 @@ public:<br>
/// Called by CoreEngine. Used to notify checkers that processing a<br>
/// function has ended. Called for both inlined and and top-level functions.<br>
void processEndOfFunction(<wbr>NodeBuilderContext& BC,<br>
- ExplodedNode *Pred) override;<br>
+ ExplodedNode *Pred,<br>
+ const ReturnStmt *RS=nullptr) override;<br>
<br>
/// Remove dead bindings/symbols before exiting a function.<br>
void removeDeadOnEndOfFunction(<wbr>NodeBuilderContext& BC,<br>
<br>
Modified: cfe/trunk/include/clang/<wbr>StaticAnalyzer/Core/<wbr>PathSensitive/SubEngine.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SubEngine.h?rev=283554&r1=283553&r2=283554&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/include/<wbr>clang/StaticAnalyzer/Core/<wbr>PathSensitive/SubEngine.h?rev=<wbr>283554&r1=283553&r2=283554&<wbr>view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/include/clang/<wbr>StaticAnalyzer/Core/<wbr>PathSensitive/SubEngine.h (original)<br>
+++ cfe/trunk/include/clang/<wbr>StaticAnalyzer/Core/<wbr>PathSensitive/SubEngine.h Fri Oct 7 09:21:08 2016<br>
@@ -109,7 +109,8 @@ public:<br>
/// Called by CoreEngine. Used to notify checkers that processing a<br>
/// function has ended. Called for both inlined and and top-level functions.<br>
virtual void processEndOfFunction(<wbr>NodeBuilderContext& BC,<br>
- ExplodedNode *Pred) = 0;<br>
+ ExplodedNode *Pred,<br>
+ const ReturnStmt *RS = nullptr) = 0;<br>
<br>
// Generate the entry node of the callee.<br>
virtual void processCallEnter(<wbr>NodeBuilderContext& BC, CallEnter CE,<br>
<br>
Modified: cfe/trunk/lib/StaticAnalyzer/<wbr>Core/CoreEngine.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/CoreEngine.cpp?rev=283554&r1=283553&r2=283554&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/lib/<wbr>StaticAnalyzer/Core/<wbr>CoreEngine.cpp?rev=283554&r1=<wbr>283553&r2=283554&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/lib/StaticAnalyzer/<wbr>Core/CoreEngine.cpp (original)<br>
+++ cfe/trunk/lib/StaticAnalyzer/<wbr>Core/CoreEngine.cpp Fri Oct 7 09:21:08 2016<br>
@@ -309,8 +309,19 @@ void CoreEngine::HandleBlockEdge(<wbr>const B<br>
assert (L.getLocationContext()-><wbr>getCFG()->getExit().size() == 0<br>
&& "EXIT block cannot contain Stmts.");<br>
<br>
+ // Get return statement..<br>
+ const ReturnStmt *RS = nullptr;<br>
+ if (!L.getSrc()->empty()) {<br>
+ if (Optional<CFGStmt> LastStmt = L.getSrc()->back().getAs<<wbr>CFGStmt>()) {<br>
+ if (RS = dyn_cast<ReturnStmt>(LastStmt-<wbr>>getStmt())) {<br>
+ if (!RS->getRetValue())<br>
+ RS = nullptr;<br>
+ }<br>
+ }<br>
+ }<br>
+<br>
// Process the final state transition.<br>
- SubEng.processEndOfFunction(<wbr>BuilderCtx, Pred);<br>
+ SubEng.processEndOfFunction(<wbr>BuilderCtx, Pred, RS);<br>
<br>
// This path is done. Don't enqueue any more nodes.<br>
return;<br>
@@ -589,13 +600,14 @@ void CoreEngine::enqueueStmtNode(<wbr>Explode<br>
WList->enqueue(Succ, Block, Idx+1);<br>
}<br>
<br>
-ExplodedNode *CoreEngine::<wbr>generateCallExitBeginNode(<wbr>ExplodedNode *N) {<br>
+ExplodedNode *CoreEngine::<wbr>generateCallExitBeginNode(<wbr>ExplodedNode *N,<br>
+ const ReturnStmt *RS) {<br>
// Create a CallExitBegin node and enqueue it.<br>
const StackFrameContext *LocCtx<br>
= cast<StackFrameContext>(N-><wbr>getLocationContext());<br>
<br>
// Use the callee location context.<br>
- CallExitBegin Loc(LocCtx);<br>
+ CallExitBegin Loc(LocCtx, RS);<br>
<br>
bool isNew;<br>
ExplodedNode *Node = G.getNode(Loc, N->getState(), false, &isNew);<br>
@@ -619,12 +631,12 @@ void CoreEngine::enqueue(<wbr>ExplodedNodeSet<br>
}<br>
}<br>
<br>
-void CoreEngine::<wbr>enqueueEndOfFunction(<wbr>ExplodedNodeSet &Set) {<br>
+void CoreEngine::<wbr>enqueueEndOfFunction(<wbr>ExplodedNodeSet &Set, const ReturnStmt *RS) {<br>
for (ExplodedNodeSet::iterator I = Set.begin(), E = Set.end(); I != E; ++I) {<br>
ExplodedNode *N = *I;<br>
// If we are in an inlined call, generate CallExitBegin node.<br>
if (N->getLocationContext()-><wbr>getParent()) {<br>
- N = generateCallExitBeginNode(N);<br>
+ N = generateCallExitBeginNode(N, RS);<br>
if (N)<br>
WList->enqueue(N);<br>
} else {<br>
<br>
Modified: cfe/trunk/lib/StaticAnalyzer/<wbr>Core/ExprEngine.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp?rev=283554&r1=283553&r2=283554&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/lib/<wbr>StaticAnalyzer/Core/<wbr>ExprEngine.cpp?rev=283554&r1=<wbr>283553&r2=283554&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/lib/StaticAnalyzer/<wbr>Core/ExprEngine.cpp (original)<br>
+++ cfe/trunk/lib/StaticAnalyzer/<wbr>Core/ExprEngine.cpp Fri Oct 7 09:21:08 2016<br>
@@ -1766,7 +1766,8 @@ void ExprEngine::<wbr>processBeginOfFunction(<br>
/// ProcessEndPath - Called by CoreEngine. Used to generate end-of-path<br>
/// nodes when the control reaches the end of a function.<br>
void ExprEngine::<wbr>processEndOfFunction(<wbr>NodeBuilderContext& BC,<br>
- ExplodedNode *Pred) {<br>
+ ExplodedNode *Pred,<br>
+ const ReturnStmt *RS) {<br>
// FIXME: Assert that stackFrameDoesNotContainInitia<wbr>lizedTemporaries(*Pred)).<br>
// We currently cannot enable this assert, as lifetime extended temporaries<br>
// are not modelled correctly.<br>
@@ -1788,7 +1789,7 @@ void ExprEngine::<wbr>processEndOfFunction(No<br>
getCheckerManager().<wbr>runCheckersForEndFunction(BC, Dst, Pred, *this);<br>
}<br>
<br>
- Engine.enqueueEndOfFunction(<wbr>Dst);<br>
+ Engine.enqueueEndOfFunction(<wbr>Dst, RS);<br>
}<br>
<br>
/// ProcessSwitch - Called by CoreEngine. Used to generate successor<br>
<br>
Modified: cfe/trunk/test/Analysis/<wbr>inlining/<wbr>InlineObjCClassMethod.m<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/inlining/InlineObjCClassMethod.m?rev=283554&r1=283553&r2=283554&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/test/<wbr>Analysis/inlining/<wbr>InlineObjCClassMethod.m?rev=<wbr>283554&r1=283553&r2=283554&<wbr>view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/test/Analysis/<wbr>inlining/<wbr>InlineObjCClassMethod.m (original)<br>
+++ cfe/trunk/test/Analysis/<wbr>inlining/<wbr>InlineObjCClassMethod.m Fri Oct 7 09:21:08 2016<br>
@@ -174,12 +174,12 @@ int foo4() {<br>
@implementation MyClassSelf<br>
+ (int)<wbr>testClassMethodByKnownVarDecl {<br>
int y = [MyParentSelf testSelf];<br>
- return 5/y; // Should warn here.<br>
+ return 5/y; // expected-warning{{Division by zero}}<br>
}<br>
@end<br>
int foo2() {<br>
int y = [MyParentSelf testSelf];<br>
- return 5/y; // Should warn here.<br>
+ return 5/y; // expected-warning{{Division by zero}}<br>
}<br>
<br>
// TODO: We do not inline 'getNum' in the following case, where the value of<br>
<br>
Modified: cfe/trunk/test/Analysis/<wbr>unreachable-code-path.c<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/unreachable-code-path.c?rev=283554&r1=283553&r2=283554&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/test/<wbr>Analysis/unreachable-code-<wbr>path.c?rev=283554&r1=283553&<wbr>r2=283554&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/test/Analysis/<wbr>unreachable-code-path.c (original)<br>
+++ cfe/trunk/test/Analysis/<wbr>unreachable-code-path.c Fri Oct 7 09:21:08 2016<br>
@@ -194,3 +194,15 @@ void test12(int x) {<br>
break;<br>
}<br>
}<br>
+<br>
+// Don't merge return nodes in ExplodedGraph unless they are same.<br>
+extern int table[];<br>
+static int inlineFunction(const int i) {<br>
+ if (table[i] != 0)<br>
+ return 1;<br>
+ return 0;<br>
+}<br>
+void test13(int i) {<br>
+ int x = inlineFunction(i);<br>
+ x && x < 10; // no-warning<br>
+}<br>
<br>
<br>
______________________________<wbr>_________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div></div>