.agents/skills/toolchain_development/SKILL.md
toolchain/:
toolchain/docs for detailed
architecture design and patterns.
ValueStore, formatting
.def files, struct reflection) used throughout the implementation..def files and expanded by way of macros.Handle<StateName> in parse/handle_*.cpp.HandleParseNode in check/handle_*.cpp.HandleInst in lower/handle_*.cpp.bazelisk test //...bazelisk test //toolchain/testing:file_testbazelisk test //toolchain/testing:file_test --test_arg=--file_tests=<path_to_carbon_file>bazelisk build //toolchain/...Carbon tests often use file_test (for example,
//toolchain/testing/file_test). For detailed guidelines on authoring tests,
including file splits, naming conventions (fail_, todo_), and generating
minimal output with SemIR dumps, please refer to the Toolchain tests skill.
If you change compiler behavior, you likely need to update expected test outputs. Do not manually edit thousands of lines of expected output. Use the script:
./toolchain/autoupdate_testdata.py
# Or for a specific file:
./toolchain/autoupdate_testdata.py toolchain/check/testdata/my_test.carbon
llvm::errs() << "debug info\n";.
std::cout (it may interfere with tool output).Print method or operator<<.inst.Print(llvm::errs())--sandbox_debug if needed,
but often running the binary directly from bazel-bin/ is easier for
debugging.ErrorOr<T>: Return ErrorOr<T> for fallible operations.
if (auto result = Function(); result) { Use(*result); }llvm::Expected<T>: Similar to ErrorOr, used when interfacing with
LLVM.llvm::cast<T>(obj) (checked, asserts on failure).llvm::dyn_cast<T>(obj) (returns null on failure).llvm::isa<T>(obj) (boolean check).dynamic_cast and standard RTTI.common/ and toolchain/base/ over LLVM ADTs. For example,
use Map instead of llvm::DenseMap.llvm::SmallVector, llvm::StringRef).StringRef is a view; be careful with lifetimes.explorer references: The explorer prototype has been moved.
Ignore references to it in proposals or old docs; focus on toolchain.autoupdate_testdata.py
can do it for you.std::string unnecessarily: Prefer llvm::StringRef for
arguments.clang-format).