[llvm] 7bb47a0 - [NFC] Improve file-level documentation for Sequence.h
Jakub Kuderski via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 30 07:29:07 PDT 2021
Author: Jakub Kuderski
Date: 2021-09-30T10:28:38-04:00
New Revision: 7bb47a046fe023c09cca2500e39eba5f440fbb99
URL: https://github.com/llvm/llvm-project/commit/7bb47a046fe023c09cca2500e39eba5f440fbb99
DIFF: https://github.com/llvm/llvm-project/commit/7bb47a046fe023c09cca2500e39eba5f440fbb99.diff
LOG: [NFC] Improve file-level documentation for Sequence.h
Add usage samples.
This was extracted from a bigger patch: https://reviews.llvm.org/D107378.
Reviewed By: aaron.ballman, gchatelet
Differential Revision: https://reviews.llvm.org/D110760
Added:
Modified:
llvm/include/llvm/ADT/Sequence.h
Removed:
################################################################################
diff --git a/llvm/include/llvm/ADT/Sequence.h b/llvm/include/llvm/ADT/Sequence.h
index 3e4bf0932222a..9fcb3034ee73f 100644
--- a/llvm/include/llvm/ADT/Sequence.h
+++ b/llvm/include/llvm/ADT/Sequence.h
@@ -6,9 +6,30 @@
//
//===----------------------------------------------------------------------===//
/// \file
-/// This routine provides some synthesis utilities to produce sequences of
-/// values. The names are intentionally kept very short as they tend to occur
-/// in common and widely used contexts.
+/// Provides some synthesis utilities to produce sequences of values. The names
+/// are intentionally kept very short as they tend to occur in common and
+/// widely used contexts.
+///
+/// The `seq(A, B)` function produces a sequence of values from `A` to up to
+/// (but not including) `B`, i.e., [`A`, `B`), that can be safely iterated over.
+/// `seq` supports both integral (e.g., `int`, `char`, `uint32_t`) and enum
+/// types. `seq_inclusive(A, B)` produces a sequence of values from `A` to `B`,
+/// including `B`.
+///
+/// Examples with integral types:
+/// ```
+/// for (int x : seq(0, 3))
+/// outs() << x << " ";
+/// ```
+///
+/// Prints: `0 1 2 `.
+///
+/// ```
+/// for (int x : seq_inclusive(0, 3))
+/// outs() << x << " ";
+/// ```
+///
+/// Prints: `0 1 2 3 `.
///
//===----------------------------------------------------------------------===//
More information about the llvm-commits
mailing list