Skip to content

Commit 6d9ee96

Browse files
jonmeowzygoloid
andauthored
Misc comment cleanups (#6200)
Just trying to apply a few scattered comment improvements that AI helped flag. --------- Co-authored-by: Richard Smith <[email protected]>
1 parent 72754ff commit 6d9ee96

File tree

7 files changed

+16
-10
lines changed

7 files changed

+16
-10
lines changed

common/array_stack.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ class ArrayStack {
8282
// Adds multiple values to the top array on the stack.
8383
auto AppendToTop(llvm::ArrayRef<ValueT> values) -> void {
8484
CARBON_CHECK(!array_offsets_.empty(),
85-
"Must call PushArray before PushValues.");
85+
"Must call PushArray before AppendToTop.");
8686
llvm::append_range(values_, values);
8787
}
8888

common/exe_path.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ namespace Carbon {
1313
// `argv0` is required to be null-terminated.
1414
//
1515
// A simplistic approach -- if the provided string isn't already a valid path,
16-
// we look it up in the PATH environment variable. Doesn't resolve any symlinks
17-
// and if it fails, returns the main executable path.
16+
// we look it up in the PATH environment variable. Doesn't resolve any symlinks.
17+
// If it doesn't find a value based on `argv[0]`, returns the main executable
18+
// path.
1819
auto FindExecutablePath(const char* argv0) -> std::string;
1920

2021
} // namespace Carbon

testing/file_test/file_test_base.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ class FileTestBase {
8585
}
8686

8787
// Returns a regex to match the default file when a line may not be present.
88-
// May return nullptr if unused. If GetLineNumberReplacements returns an entry
89-
// with has_file=false, this is required.
88+
// May return `std::nullopt` if unused. If `GetLineNumberReplacements` returns
89+
// an entry with `has_file=false`, this is required.
9090
virtual auto GetDefaultFileRE(llvm::ArrayRef<llvm::StringRef> /*filenames*/)
9191
const -> std::optional<RE2> {
9292
return std::nullopt;

toolchain/base/canonical_value_store.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ class CanonicalValueStore {
3030
using RefType = ValueStoreTypes<ValueT>::RefType;
3131
using ConstRefType = ValueStoreTypes<ValueT>::ConstRefType;
3232

33-
// Stores a canonical copy of the value and returns an ID to reference it.
33+
// Stores a canonical copy of the value and returns an ID to reference it. If
34+
// the value is already in the store, returns the ID of the existing value.
3435
auto Add(ValueType value) -> IdT;
3536

3637
// Returns the value for an ID.

toolchain/base/index_base.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ class IndexIterator
140140
return *this;
141141
}
142142

143-
// Prints the raw token index.
143+
// Prints the raw index.
144144
auto Print(llvm::raw_ostream& output) const -> void {
145145
output << index_.index;
146146
}

toolchain/base/kind_switch.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,8 +222,12 @@ consteval auto ForCase() -> auto {
222222
}
223223
}
224224

225-
// Given `CARBON_KIND_SWITCH(value)` and `CARBON_KIND(CaseT name)` this
226-
// generates `value.As<CaseT>()`.
225+
// Given `CARBON_KIND_SWITCH(value)` and `CARBON_KIND(CaseT name)` this converts
226+
// the `value` to `CaseT`.
227+
//
228+
// For types with a `kind()` accessor this uses `value.As<CaseT>`.
229+
//
230+
// For `std::variant<...>` this uses `std::get<CaseT>(value)`.
227231
template <typename CaseFnT, typename SwitchT>
228232
auto Cast(SwitchT&& kind_switch_value) -> decltype(auto) {
229233
using CaseT = llvm::function_traits<CaseFnT>::template arg_t<0>;

toolchain/sem_ir/file.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ using ExprRegionStore = ValueStore<ExprRegionId, ExprRegion>;
6464

6565
using CustomLayoutStore = BlockValueStore<CustomLayoutId, uint64_t>;
6666

67-
// Provides semantic analysis on a Parse::Tree.
67+
// The semantic IR for a single file.
6868
class File : public Printable<File> {
6969
public:
7070
using IdentifiedFacetTypeStore =

0 commit comments

Comments
 (0)