[clang] 75f0d40 - CoverageMapping: Move `getParams<InnerParamTy>(MCDCParams)` into `mcdc::`
NAKAMURA Takumi via cfe-commits
cfe-commits at lists.llvm.org
Thu Feb 15 03:28:30 PST 2024
Author: NAKAMURA Takumi
Date: 2024-02-15T20:27:47+09:00
New Revision: 75f0d40507ea3f7c99dd3250ff0fbe6dab341910
URL: https://github.com/llvm/llvm-project/commit/75f0d40507ea3f7c99dd3250ff0fbe6dab341910
DIFF: https://github.com/llvm/llvm-project/commit/75f0d40507ea3f7c99dd3250ff0fbe6dab341910.diff
LOG: CoverageMapping: Move `getParams<InnerParamTy>(MCDCParams)` into `mcdc::`
Fixup for #81227
Added:
Modified:
clang/lib/CodeGen/CoverageMappingGen.cpp
llvm/include/llvm/ProfileData/Coverage/CoverageMapping.h
llvm/include/llvm/ProfileData/Coverage/MCDCTypes.h
Removed:
################################################################################
diff --git a/clang/lib/CodeGen/CoverageMappingGen.cpp b/clang/lib/CodeGen/CoverageMappingGen.cpp
index eb3beec23808e6..c10d85ea89ee61 100644
--- a/clang/lib/CodeGen/CoverageMappingGen.cpp
+++ b/clang/lib/CodeGen/CoverageMappingGen.cpp
@@ -190,8 +190,7 @@ class SourceMappingRegion {
}
const auto &getMCDCDecisionParams() const {
- return CounterMappingRegion::getParams<const mcdc::DecisionParameters>(
- MCDCParams);
+ return mcdc::getParams<const mcdc::DecisionParameters>(MCDCParams);
}
const mcdc::Parameters &getMCDCParams() const { return MCDCParams; }
diff --git a/llvm/include/llvm/ProfileData/Coverage/CoverageMapping.h b/llvm/include/llvm/ProfileData/Coverage/CoverageMapping.h
index e3b394287f3352..c5c9740f25c2ce 100644
--- a/llvm/include/llvm/ProfileData/Coverage/CoverageMapping.h
+++ b/llvm/include/llvm/ProfileData/Coverage/CoverageMapping.h
@@ -258,22 +258,12 @@ struct CounterMappingRegion {
/// Parameters used for Modified Condition/Decision Coverage
mcdc::Parameters MCDCParams;
- template <class MaybeConstInnerParameters, class MaybeConstMCDCParameters>
- static auto &getParams(MaybeConstMCDCParameters &MCDCParams) {
- using InnerParameters =
- typename std::remove_const<MaybeConstInnerParameters>::type;
- MaybeConstInnerParameters *Params =
- std::get_if<InnerParameters>(&MCDCParams);
- assert(Params && "InnerParameters unavailable");
- return *Params;
- }
-
const auto &getDecisionParams() const {
- return getParams<const mcdc::DecisionParameters>(MCDCParams);
+ return mcdc::getParams<const mcdc::DecisionParameters>(MCDCParams);
}
const auto &getBranchParams() const {
- return getParams<const mcdc::BranchParameters>(MCDCParams);
+ return mcdc::getParams<const mcdc::BranchParameters>(MCDCParams);
}
unsigned FileID = 0;
diff --git a/llvm/include/llvm/ProfileData/Coverage/MCDCTypes.h b/llvm/include/llvm/ProfileData/Coverage/MCDCTypes.h
index 51f528b7e78804..8c78bed4dec52f 100644
--- a/llvm/include/llvm/ProfileData/Coverage/MCDCTypes.h
+++ b/llvm/include/llvm/ProfileData/Coverage/MCDCTypes.h
@@ -14,6 +14,8 @@
#define LLVM_PROFILEDATA_COVERAGE_MCDCTYPES_H
#include <array>
+#include <cassert>
+#include <type_traits>
#include <variant>
namespace llvm::coverage::mcdc {
@@ -49,6 +51,19 @@ struct BranchParameters {
using Parameters =
std::variant<std::monostate, DecisionParameters, BranchParameters>;
+/// Check and get underlying params in MCDCParams.
+/// \tparam MaybeConstInnerParameters Type to get. May be const.
+/// \tparam MaybeConstMCDCParameters Expected inferred. May be const.
+/// \param MCDCParams May be const.
+template <class MaybeConstInnerParameters, class MaybeConstMCDCParameters>
+static auto &getParams(MaybeConstMCDCParameters &MCDCParams) {
+ using InnerParameters =
+ typename std::remove_const<MaybeConstInnerParameters>::type;
+ MaybeConstInnerParameters *Params = std::get_if<InnerParameters>(&MCDCParams);
+ assert(Params && "InnerParameters unavailable");
+ return *Params;
+}
+
} // namespace llvm::coverage::mcdc
#endif // LLVM_PROFILEDATA_COVERAGE_MCDCTYPES_H
More information about the cfe-commits
mailing list