بنقرة واحدة
toolchain-development
Instructions for checking, building, debugging, and understanding the Carbon toolchain.
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
Instructions for checking, building, debugging, and understanding the Carbon toolchain.
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
استنادا إلى تصنيف SOC المهني
Instructions for registering, mapping, constant evaluating, and lowering builtin functions in the Carbon toolchain.
Instructions for declaring, formatting, emitting, testing, and styling diagnostic messages (errors, warnings, notes) in the Carbon toolchain.
Guidelines and restrictions on shell commands and file manipulation tools for AI assistants.
Instructions that **MUST** be followed when using Bazel or Bazelisk to build, test, and debug in the Carbon repository.
Instructions for using Jujutsu (jj) for version control in the Carbon repository.
Instructions for running prek, the Carbon pre-submit/style/lint checker, that *MUST* be run before submitting an change.
| name | Toolchain development |
| description | Instructions for checking, building, debugging, and understanding the Carbon toolchain. |
toolchain/:
toolchain/docs for detailed
architecture design and patterns.
ValueStore, formatting
.def files, struct reflection) used throughout the implementation."int.convert_float")..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.When declaring and emitting errors, ensure semantic wording matches the exact context:
IntLiteral or FloatLiteral. For example, use
RealLiteralTooLargeForUnsizedInt instead of a diagnostic referencing an
"integer type".MaxIntWidth) to align message structures and parameter expectations.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.Before implementing custom algorithms for mathematical, logical, or bitwise operations, inspect target LLVM ADT class APIs:
APInt, APFloat, or
APSInt) already offer native equivalents (for example, .pow(),
ilogb(), .changeSign(), convertFromAPInt()). Avoid duplicate, naive,
or inefficient custom loops.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).