[cfe-commits] r45288 - /cfe/trunk/AST/CFG.cpp
Ted Kremenek
kremenek at apple.com
Fri Dec 21 11:49:00 PST 2007
Author: kremenek
Date: Fri Dec 21 13:49:00 2007
New Revision: 45288
URL: http://llvm.org/viewvc/llvm-project?rev=45288&view=rev
Log:
Fixed successor order for CFG basic blocks when handling: x && y. The bug
is best explained by illustration:
[ B2 ]
1: x
T: [B2.1] && ...
Predecessors (1): B4
Successors (2): B3 B1
Block "B3" should be the block where we evaluate "y" when "x" evaluates to
true. Previously we had the successor list reversed. Now this behavior matches
with how we handle other conditional branches.
Thanks to Nuno Lopes for reporting this problem.
Modified:
cfe/trunk/AST/CFG.cpp
Modified: cfe/trunk/AST/CFG.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/AST/CFG.cpp?rev=45288&r1=45287&r2=45288&view=diff
==============================================================================
--- cfe/trunk/AST/CFG.cpp (original)
+++ cfe/trunk/AST/CFG.cpp Fri Dec 21 13:49:00 2007
@@ -340,14 +340,23 @@
// create the block evaluating the LHS
CFGBlock* LHSBlock = createBlock(false);
- LHSBlock->addSuccessor(ConfluenceBlock);
- LHSBlock->setTerminator(B);
+ LHSBlock->setTerminator(B);
// create the block evaluating the RHS
Succ = ConfluenceBlock;
Block = NULL;
CFGBlock* RHSBlock = Visit(B->getRHS());
- LHSBlock->addSuccessor(RHSBlock);
+
+ // Now link the LHSBlock with RHSBlock.
+ if (B->getOpcode() == BinaryOperator::LOr) {
+ LHSBlock->addSuccessor(ConfluenceBlock);
+ LHSBlock->addSuccessor(RHSBlock);
+ }
+ else {
+ assert (B->getOpcode() == BinaryOperator::LAnd);
+ LHSBlock->addSuccessor(RHSBlock);
+ LHSBlock->addSuccessor(ConfluenceBlock);
+ }
// Generate the blocks for evaluating the LHS.
Block = LHSBlock;
More information about the cfe-commits
mailing list