[llvm] [DebugCounter] Add support for non-continous ranges. (PR #89470)

Nicolai Hähnle via llvm-commits llvm-commits at lists.llvm.org
Thu May 16 12:47:32 PDT 2024


================
@@ -7,6 +7,83 @@
 
 using namespace llvm;
 
+namespace llvm {
+
+void Chunk::print(llvm::raw_ostream &OS) {
+  if (Begin == End)
+    OS << Begin;
+  else
+    OS << Begin << "-" << End;
+}
+
+void printChunks(raw_ostream &OS, ArrayRef<Chunk> Chunks) {
+  if (Chunks.empty()) {
+    OS << "empty";
+  } else {
+    bool IsFirst = true;
+    for (auto E : Chunks) {
+      if (!IsFirst)
+        OS << ":";
----------------
nhaehnle wrote:

More idiomatic:
```suggestion
        OS << ':';
```

https://github.com/llvm/llvm-project/pull/89470


More information about the llvm-commits mailing list