/
githubmirror
/
carbon-lang
Обзор
Документация
Войти
/
githubmirror
/
carbon-lang
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
trunk
toolchain/lex/dump.cpp
40 строк
1003 B
Chandler Carruth
Remove the `Dump` method from `Printable` (#7118)
26 апр 2026, 19:21
Не верифицирован
26 апр 2026, 19:21
df6a5a5
Код
Авторство
О чём код?
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #ifndef NDEBUG #include "toolchain/lex/dump.h" #include <string> #include "common/raw_string_ostream.h" namespace Carbon::Lex { static LLVM_DUMP_METHOD auto Dump(const TokenizedBuffer& tokens) -> std::string { return PrintToString(tokens); } LLVM_DUMP_METHOD auto Dump(const TokenizedBuffer& tokens, TokenIndex token) -> std::string { RawStringOstream out; if (!token.has_value()) { out << "TokenIndex(<none>)"; return out.TakeStr(); } auto kind = tokens.GetKind(token); auto line = tokens.GetLineNumber(token); auto col = tokens.GetColumnNumber(token); out << "TokenIndex(kind: " << kind << ", loc: " << FormatEscaped(tokens.source().filename()) << ":" << line << ":" << col << ")"; return out.TakeStr(); } } // namespace Carbon::Lex #endif // NDEBUG