}
}
- /// \brief If the given statement is a compound statement,
- /// map '}' with the same count as '{'.
- void VisitSubStmtRBraceState(const Stmt *S) {
- if (!isa<CompoundStmt>(S))
- return Visit(S);
- const auto *CS = cast<CompoundStmt>(S);
- auto State = getCurrentState();
- mapSourceCodeRange(CS->getLBracLoc());
- for (Stmt::const_child_range I = S->children(); I; ++I) {
- if (*I)
- this->Visit(*I);
- }
- CoverageMappingBuilder::mapSourceCodeRange(State, CS->getRBracLoc(),
- CS->getRBracLoc());
- }
-
void VisitDecl(const Decl *D) {
if (!D->hasBody())
return;
auto Body = D->getBody();
RegionMapper Cnt(this, Body);
Cnt.beginRegion();
- VisitSubStmtRBraceState(Body);
+ Visit(Body);
}
void VisitDeclStmt(const DeclStmt *S) {
}
void VisitCompoundStmt(const CompoundStmt *S) {
+ SourceMappingState State = getCurrentState();
mapSourceCodeRange(S->getLBracLoc());
for (Stmt::const_child_range I = S->children(); I; ++I) {
if (*I)
this->Visit(*I);
}
- mapSourceCodeRange(S->getRBracLoc(), S->getRBracLoc());
+ CoverageMappingBuilder::mapSourceCodeRange(State, S->getRBracLoc(),
+ S->getRBracLoc());
}
void VisitReturnStmt(const ReturnStmt *S) {
// Visit the body region first so the break/continue adjustments can be
// included when visiting the condition.
Cnt.beginRegion();
- VisitSubStmtRBraceState(S->getBody());
+ Visit(S->getBody());
Cnt.adjustForControlFlow();
// ...then go back and propagate counts through the condition. The count
RegionMapper Cnt(this, S);
BreakContinueStack.push_back(BreakContinue());
Cnt.beginRegion(/*AddIncomingFallThrough=*/true);
- VisitSubStmtRBraceState(S->getBody());
+ Visit(S->getBody());
Cnt.adjustForControlFlow();
BreakContinue BC = BreakContinueStack.pop_back_val();
// Visit the body region first. (This is basically the same as a while
// loop; see further comments in VisitWhileStmt.)
Cnt.beginRegion();
- VisitSubStmtRBraceState(S->getBody());
+ Visit(S->getBody());
Cnt.adjustForControlFlow();
// The increment is essentially part of the body but it needs to include
// Visit the body region first. (This is basically the same as a while
// loop; see further comments in VisitWhileStmt.)
Cnt.beginRegion();
- VisitSubStmtRBraceState(S->getBody());
+ Visit(S->getBody());
Cnt.adjustForControlFlow();
BreakContinue BC = BreakContinueStack.pop_back_val();
Cnt.applyAdjustmentsToRegion(addCounters(BC.BreakCount, BC.ContinueCount));
RegionMapper Cnt(this, S);
BreakContinueStack.push_back(BreakContinue());
Cnt.beginRegion();
- VisitSubStmtRBraceState(S->getBody());
+ Visit(S->getBody());
BreakContinue BC = BreakContinueStack.pop_back_val();
Cnt.adjustForControlFlow();
Cnt.applyAdjustmentsToRegion(addCounters(BC.BreakCount, BC.ContinueCount));
// the "else" part, if it exists, will be calculated from this counter.
RegionMapper Cnt(this, S);
Cnt.beginRegion();
- VisitSubStmtRBraceState(S->getThen());
+ Visit(S->getThen());
Cnt.adjustForControlFlow();
if (S->getElse()) {
Cnt.beginElseRegion();
- VisitSubStmtRBraceState(S->getElse());
+ Visit(S->getElse());
Cnt.adjustForControlFlow();
}
Cnt.applyAdjustmentsToRegion();
// Counter tracks the catch statement's handler block.
RegionMapper Cnt(this, S);
Cnt.beginRegion();
- VisitSubStmtRBraceState(S->getHandlerBlock());
+ Visit(S->getHandlerBlock());
}
void VisitAbstractConditionalOperator(const AbstractConditionalOperator *E) {