Skip to content

Commit 09c088d

Browse files
committed
prepare to fix problem of while (true)
Signed-off-by: cppbear <[email protected]>
1 parent 2a68d87 commit 09c088d

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed

.vscode/launch.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,10 @@
2727
"-p",
2828
"/home/chubei/utgen-focal/json/build",
2929
"/home/chubei/utgen-focal/json/include/nlohmann/detail/input/lexer.hpp",
30-
// "-f",
31-
// "scan_number"
30+
// "/home/chubei/utgen-focal/json/single_include/nlohmann/json.hpp",
31+
"-f",
32+
// "scan_number",
33+
"scan_comment",
3234
// "--cfg",
3335
// "--",
3436
// "-ferror-limit=0"

clang-tools-extra/brinfo/Analysis.cpp

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,9 @@ void Analysis::dfsTraverseCFGLoop(long Parent, CFGBlock *FirstBlk) {
343343
bool Flag = BlkCond.Flag;
344344
unsigned ID = Blk->getBlockID();
345345

346+
errs() << "Block: " << ID << " Parent: " << Parent << "\n";
347+
dumpBlkChain();
348+
346349
if (ColorOfBlk[ID] == 0)
347350
ColorOfBlk[ID] = 1;
348351

@@ -360,15 +363,15 @@ void Analysis::dfsTraverseCFGLoop(long Parent, CFGBlock *FirstBlk) {
360363
llvm::sort(SortedPath.begin(), SortedPath.end());
361364
// Loop detected
362365
if (binary_search(SortedPath.begin(), SortedPath.end(), Blk)) {
363-
// errs() << "Loop detected at Block " << Blk->getBlockID() << " in "
364-
// << Signature << "\n";
365-
// unsigned I = 0;
366-
// for (const CFGBlock *Blk : Path) {
367-
// if (I++ > 0)
368-
// errs() << " \033[36m\033[1m->\033[0m ";
369-
// errs() << Blk->getBlockID();
370-
// }
371-
// errs() << "\n";
366+
errs() << "Loop detected at Block " << Blk->getBlockID() << " in "
367+
<< Signature << "\n";
368+
unsigned I = 0;
369+
for (const CFGBlock *Blk : Path) {
370+
if (I++ > 0)
371+
errs() << " \033[36m\033[1m->\033[0m ";
372+
errs() << Blk->getBlockID();
373+
}
374+
errs() << "\n";
372375
bool Traverse = false;
373376
for (CFGBlock::AdjacentBlock Adj : Blk->succs()) {
374377
if (Adj.isReachable()) {
@@ -381,6 +384,7 @@ void Analysis::dfsTraverseCFGLoop(long Parent, CFGBlock *FirstBlk) {
381384
}
382385
}
383386
}
387+
// FIXME: do not clear loop like while (true)
384388
if (!Traverse) {
385389
unsigned PathSize = Path.size();
386390
for (unsigned I = PathSize - 1; I > 0; --I) {

0 commit comments

Comments
 (0)