mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 16:21:04 +01:00
Add Dump functions to Check, Parse, and Lex (#4669)
- Provide `Check::Dump(context, arg)` and similar. - gdb and lldb should do contextual lookup, and `call Dump(*this, Lex::TokenIndex::Invalid)` has been tested with gdb. - Since this is only for debug, keeps the functions fully separated from code. - Uses alwayslink to ensure objects are correctly linked, even though there are no calls. - `-Wno-missing-prototypes` is needed when we don't have forward declarations. - Code is not linked in opt builds, using `#ifndef NDEBUG`. - This probably could be doing something in BUILD files with a `select()`, but the `#ifndef` seemed easier. This is based on #4620, but uses free functions instead of member functions. Co-authored-by: Dana Jansens <danakj@orodu.net> --------- Co-authored-by: danakj <danakj@orodu.net>
This commit is contained in:
co-authored by
Dana Jansens
parent
79ba184dab
commit
3ce0df67bb
@@ -481,7 +481,7 @@ auto Context::PrintForStackDump(llvm::raw_ostream& output) const -> void {
|
||||
|
||||
auto Context::PrintTokenForStackDump(llvm::raw_ostream& output,
|
||||
Lex::TokenIndex token) const -> void {
|
||||
output << " @ " << tokens_->GetLineNumber(tokens_->GetLine(token)) << ":"
|
||||
output << " @ " << tokens_->GetLineNumber(token) << ":"
|
||||
<< tokens_->GetColumnNumber(token) << ": token " << token << " : "
|
||||
<< tokens_->GetKind(token) << "\n";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user