MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / checkBranch

Function checkBranch

lib/forwardanalyzer.cpp:386–410  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

384 }
385
386 bool checkBranch(Branch& branch) const {
387 Analyzer::Action a = analyzeScope(branch.endBlock);
388 branch.action = a;
389 std::vector<ForwardTraversal> ft1 = tryForkUpdateScope(branch.endBlock, a.isModified());
390 const bool bail = hasGoto(branch.endBlock);
391 if (!a.isModified() && !bail) {
392 if (ft1.empty()) {
393 // Traverse into the branch to see if there is a conditional escape
394 if (!branch.escape && hasInnerReturnScope(branch.endBlock->previous(), branch.endBlock->link())) {
395 ForwardTraversal ft2 = fork(true);
396 ft2.updateScope(branch.endBlock);
397 if (ft2.terminate == Analyzer::Terminate::Escape) {
398 branch.escape = true;
399 branch.escapeUnknown = false;
400 }
401 }
402 } else {
403 if (ft1.front().terminate == Analyzer::Terminate::Escape) {
404 branch.escape = true;
405 branch.escapeUnknown = false;
406 }
407 }
408 }
409 return bail;
410 }
411
412 bool reentersLoop(Token* endBlock, const Token* condTok, const Token* stepTok) const {
413 if (!condTok)

Callers 1

updateRangeFunction · 0.85

Calls 9

analyzeScopeFunction · 0.85
tryForkUpdateScopeFunction · 0.85
hasGotoFunction · 0.85
hasInnerReturnScopeFunction · 0.85
forkFunction · 0.85
frontMethod · 0.80
isModifiedMethod · 0.45
emptyMethod · 0.45
updateScopeMethod · 0.45

Tested by

no test coverage detected