diff options
Diffstat (limited to 'clang/lib/CodeGen/CoverageMappingGen.cpp')
-rw-r--r-- | clang/lib/CodeGen/CoverageMappingGen.cpp | 35 |
1 files changed, 13 insertions, 22 deletions
diff --git a/clang/lib/CodeGen/CoverageMappingGen.cpp b/clang/lib/CodeGen/CoverageMappingGen.cpp index 3b711c0..93c3c31 100644 --- a/clang/lib/CodeGen/CoverageMappingGen.cpp +++ b/clang/lib/CodeGen/CoverageMappingGen.cpp @@ -593,11 +593,6 @@ struct EmptyCoverageMappingBuilder : public CoverageMappingBuilder { /// creation. struct MCDCCoverageBuilder { - struct DecisionIDPair { - mcdc::ConditionID TrueID = 0; - mcdc::ConditionID FalseID = 0; - }; - /// The AST walk recursively visits nested logical-AND or logical-OR binary /// operator nodes and then visits their LHS and RHS children nodes. As this /// happens, the algorithm will assign IDs to each operator's LHS and RHS side @@ -688,14 +683,14 @@ struct MCDCCoverageBuilder { private: CodeGenModule &CGM; - llvm::SmallVector<DecisionIDPair> DecisionStack; + llvm::SmallVector<mcdc::ConditionIDs> DecisionStack; MCDC::State &MCDCState; llvm::DenseMap<const Stmt *, mcdc::ConditionID> &CondIDs; mcdc::ConditionID NextID = 1; bool NotMapped = false; /// Represent a sentinel value of [0,0] for the bottom of DecisionStack. - static constexpr DecisionIDPair DecisionStackSentinel{0, 0}; + static constexpr mcdc::ConditionIDs DecisionStackSentinel{0, 0}; /// Is this a logical-AND operation? bool isLAnd(const BinaryOperator *E) const { @@ -732,7 +727,7 @@ public: } /// Return the LHS Decision ([0,0] if not set). - const DecisionIDPair &back() const { return DecisionStack.back(); } + const mcdc::ConditionIDs &back() const { return DecisionStack.back(); } /// Push the binary operator statement to track the nest level and assign IDs /// to the operator's LHS and RHS. The RHS may be a larger subtree that is @@ -750,7 +745,7 @@ public: if (NotMapped) return; - const DecisionIDPair &ParentDecision = DecisionStack.back(); + const mcdc::ConditionIDs &ParentDecision = DecisionStack.back(); // If the operator itself has an assigned ID, this means it represents a // larger subtree. In this case, assign that ID to its LHS node. Its RHS @@ -766,18 +761,18 @@ public: // Push the LHS decision IDs onto the DecisionStack. if (isLAnd(E)) - DecisionStack.push_back({RHSid, ParentDecision.FalseID}); + DecisionStack.push_back({ParentDecision[false], RHSid}); else - DecisionStack.push_back({ParentDecision.TrueID, RHSid}); + DecisionStack.push_back({RHSid, ParentDecision[true]}); } /// Pop and return the LHS Decision ([0,0] if not set). - DecisionIDPair pop() { + mcdc::ConditionIDs pop() { if (!CGM.getCodeGenOpts().MCDCCoverage || NotMapped) return DecisionStack.front(); assert(DecisionStack.size() > 1); - DecisionIDPair D = DecisionStack.back(); + mcdc::ConditionIDs D = DecisionStack.back(); DecisionStack.pop_back(); return D; } @@ -1026,15 +1021,12 @@ struct CounterCoverageMappingBuilder return (Cond->EvaluateAsInt(Result, CVM.getCodeGenModule().getContext())); } - using MCDCDecisionIDPair = MCDCCoverageBuilder::DecisionIDPair; - /// Create a Branch Region around an instrumentable condition for coverage /// and add it to the function's SourceRegions. A branch region tracks a /// "True" counter and a "False" counter for boolean expressions that /// result in the generation of a branch. - void - createBranchRegion(const Expr *C, Counter TrueCnt, Counter FalseCnt, - const MCDCDecisionIDPair &IDPair = MCDCDecisionIDPair()) { + void createBranchRegion(const Expr *C, Counter TrueCnt, Counter FalseCnt, + const mcdc::ConditionIDs &Conds = {}) { // Check for NULL conditions. if (!C) return; @@ -1047,8 +1039,7 @@ struct CounterCoverageMappingBuilder mcdc::Parameters BranchParams; mcdc::ConditionID ID = MCDCBuilder.getCondID(C); if (ID > 0) - BranchParams = - mcdc::BranchParameters{ID, IDPair.TrueID, IDPair.FalseID}; + BranchParams = mcdc::BranchParameters{ID, Conds}; // If a condition can fold to true or false, the corresponding branch // will be removed. Create a region with both counters hard-coded to @@ -2134,8 +2125,8 @@ static void dump(llvm::raw_ostream &OS, StringRef FunctionName, if (const auto *BranchParams = std::get_if<mcdc::BranchParameters>(&R.MCDCParams)) { - OS << " [" << BranchParams->ID << "," << BranchParams->TrueID; - OS << "," << BranchParams->FalseID << "] "; + OS << " [" << BranchParams->ID << "," << BranchParams->Conds[true]; + OS << "," << BranchParams->Conds[false] << "] "; } if (R.Kind == CounterMappingRegion::ExpansionRegion) |