Merge pull request #69917 from hamishknight/to-err

This commit is contained in:
Hamish Knight
2023-11-16 22:16:41 +00:00
committed by GitHub
16 changed files with 910 additions and 435 deletions

View File

@@ -162,7 +162,16 @@ public:
return Expressions;
}
void printCounter(llvm::raw_ostream &OS, llvm::coverage::Counter C) const;
/// Print a given profiling counter expression, given the reference to the
/// counter, and the list of counters it may reference.
static void
printCounter(llvm::raw_ostream &OS, llvm::coverage::Counter C,
ArrayRef<llvm::coverage::CounterExpression> Expressions);
/// Print a given profiling counter expression.
void printCounter(llvm::raw_ostream &OS, llvm::coverage::Counter C) const {
printCounter(OS, C, getExpressions());
}
/// Print the coverage map.
void print(llvm::raw_ostream &OS, bool Verbose = false,

View File

@@ -36,9 +36,10 @@ class ProfileCounterRef final {
public:
enum class Kind : uint8_t {
/// References an ASTNode.
// TODO: This is the currently the only kind, but it will be expanded in
// the future for e.g top-level entry and error branches.
Node
Node,
/// References the error branch for an apply or access.
ErrorBranch
};
private:
@@ -56,6 +57,12 @@ public:
return ProfileCounterRef(node, Kind::Node);
}
/// A profile counter that is associated with the error branch of a particular
/// error-throwing AST node.
static ProfileCounterRef errorBranchOf(ASTNode node) {
return ProfileCounterRef(node, Kind::ErrorBranch);
}
/// Retrieve the corresponding location of the counter.
SILLocation getLocation() const;
@@ -135,11 +142,13 @@ public:
/// Get the number of region counters.
unsigned getNumRegionCounters() const { return NumRegionCounters; }
/// Get the mapping from a \c ProfileCounterRef to its corresponding
/// profile counter.
const llvm::DenseMap<ProfileCounterRef, unsigned> &
getRegionCounterMap() const {
return RegionCounterMap;
/// Retrieve the counter index for a given counter reference, asserting that
/// it is present.
unsigned getCounterIndexFor(ProfileCounterRef ref);
/// Whether a counter has been recorded for the given counter reference.
bool hasCounterFor(ProfileCounterRef ref) {
return RegionCounterMap.contains(ref);
}
private: