[llvm] [clang] `llvm-cov` assertion failure when handling MC/DC that involves macros (PR #80098)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 30 20:42:45 PST 2024
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff c19436eec1c236cbe622c04e33f35f1f9478fa15 cd5a33851187c872c0de7a766528be097bcc68ad -- clang/lib/CodeGen/CoverageMappingGen.cpp llvm/include/llvm/ProfileData/Coverage/CoverageMapping.h llvm/lib/ProfileData/Coverage/CoverageMappingReader.cpp llvm/lib/ProfileData/Coverage/CoverageMappingWriter.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/clang/lib/CodeGen/CoverageMappingGen.cpp b/clang/lib/CodeGen/CoverageMappingGen.cpp
index ecd90fe058..565979c5c3 100644
--- a/clang/lib/CodeGen/CoverageMappingGen.cpp
+++ b/clang/lib/CodeGen/CoverageMappingGen.cpp
@@ -888,20 +888,20 @@ struct CounterCoverageMappingBuilder
if (EndLoc && EndLoc->isInvalid())
EndLoc = std::nullopt;
RegionStack.emplace_back(Count, FalseCount,
- MCDCParameters{
- 0, 0,
- ID, TrueID, FalseID, GroupID},
+ MCDCParameters{0, 0, ID, TrueID, FalseID, GroupID},
StartLoc, EndLoc);
return RegionStack.size() - 1;
}
- size_t pushRegion(unsigned BitmapIdx, unsigned Conditions, MCDCConditionID GroupID,
+ size_t pushRegion(unsigned BitmapIdx, unsigned Conditions,
+ MCDCConditionID GroupID,
std::optional<SourceLocation> StartLoc = std::nullopt,
std::optional<SourceLocation> EndLoc = std::nullopt) {
- RegionStack.emplace_back(MCDCParameters{BitmapIdx, Conditions, 0, 0, 0, GroupID}, StartLoc,
- EndLoc);
+ RegionStack.emplace_back(
+ MCDCParameters{BitmapIdx, Conditions, 0, 0, 0, GroupID}, StartLoc,
+ EndLoc);
return RegionStack.size() - 1;
}
@@ -1059,7 +1059,8 @@ struct CounterCoverageMappingBuilder
// CodeGenFunction.c always returns false, but that is very heavy-handed.
if (ConditionFoldsToBool(C))
popRegions(pushRegion(Counter::getZero(), getStart(C), getEnd(C),
- Counter::getZero(), ID, TrueID, FalseID, GroupID));
+ Counter::getZero(), ID, TrueID, FalseID,
+ GroupID));
else
// Otherwise, create a region with the True counter and False counter.
popRegions(pushRegion(TrueCnt, getStart(C), getEnd(C), FalseCnt, ID,
@@ -1070,7 +1071,8 @@ struct CounterCoverageMappingBuilder
/// Create a Decision Region with a BitmapIdx and number of Conditions. This
/// type of region "contains" branch regions, one for each of the conditions.
/// The visualization tool will group everything together.
- void createDecisionRegion(const Expr *C, unsigned BitmapIdx, unsigned Conds, MCDCConditionID GroupID) {
+ void createDecisionRegion(const Expr *C, unsigned BitmapIdx, unsigned Conds,
+ MCDCConditionID GroupID) {
popRegions(pushRegion(BitmapIdx, Conds, GroupID, getStart(C), getEnd(C)));
}
@@ -1156,10 +1158,9 @@ struct CounterCoverageMappingBuilder
if (I.isBranch())
SourceRegions.emplace_back(
I.getCounter(), I.getFalseCounter(),
- MCDCParameters{0, 0, I.getMCDCParams().ID,
- I.getMCDCParams().TrueID,
- I.getMCDCParams().FalseID,
- I.getMCDCParams().GroupID},
+ MCDCParameters{
+ 0, 0, I.getMCDCParams().ID, I.getMCDCParams().TrueID,
+ I.getMCDCParams().FalseID, I.getMCDCParams().GroupID},
Loc, getEndOfFileOrMacro(Loc), I.isBranch());
else
SourceRegions.emplace_back(I.getCounter(), Loc,
@@ -2016,11 +2017,13 @@ struct CounterCoverageMappingBuilder
// Create Branch Region around LHS condition.
createBranchRegion(E->getLHS(), RHSExecCnt,
- subtractCounters(ParentCnt, RHSExecCnt), DecisionLHS, MCDCDebugCounter);
+ subtractCounters(ParentCnt, RHSExecCnt), DecisionLHS,
+ MCDCDebugCounter);
// Create Branch Region around RHS condition.
createBranchRegion(E->getRHS(), RHSTrueCnt,
- subtractCounters(RHSExecCnt, RHSTrueCnt), DecisionRHS, MCDCDebugCounter);
+ subtractCounters(RHSExecCnt, RHSTrueCnt), DecisionRHS,
+ MCDCDebugCounter);
}
// Determine whether the right side of OR operation need to be visited.
``````````
</details>
https://github.com/llvm/llvm-project/pull/80098
More information about the llvm-commits
mailing list