mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 06:31:03 +01:00
Explorer: Add methods to trace for line prefixes (#3076)
Defines methods into `TraceStream` for adding line prefixes. Instead of directly using string literals. Example usage, ``` trace_stream_->Start() << "declaring ... " << ... ; ``` will result in, ``` ->> declaring ... ```
This commit is contained in:
@@ -27,9 +27,9 @@ auto StaticScope::Add(std::string_view name, ValueNodeView entity,
|
||||
}
|
||||
} else {
|
||||
if (trace_stream_->is_enabled()) {
|
||||
*trace_stream_ << "--- declared `" << name << "` as `" << entity
|
||||
<< "` in `" << PrintAsID(*this) << "` ("
|
||||
<< entity.base().source_loc() << ")\n";
|
||||
trace_stream_->Result()
|
||||
<< "declared `" << name << "` as `" << entity << "` in `"
|
||||
<< PrintAsID(*this) << "` (" << entity.base().source_loc() << ")\n";
|
||||
}
|
||||
}
|
||||
return Success();
|
||||
@@ -57,9 +57,9 @@ void StaticScope::MarkDeclared(std::string_view name) {
|
||||
if (it->second.status == NameStatus::KnownButNotDeclared) {
|
||||
it->second.status = NameStatus::DeclaredButNotUsable;
|
||||
if (trace_stream_->is_enabled()) {
|
||||
*trace_stream_ << "--- marked `" << name
|
||||
<< "` declared but not usable in `" << PrintAsID(*this)
|
||||
<< "`\n";
|
||||
trace_stream_->Result()
|
||||
<< "marked `" << name << "` declared but not usable in `"
|
||||
<< PrintAsID(*this) << "`\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -69,8 +69,8 @@ void StaticScope::MarkUsable(std::string_view name) {
|
||||
CARBON_CHECK(it != declared_names_.end()) << name << " not found";
|
||||
it->second.status = NameStatus::Usable;
|
||||
if (trace_stream_->is_enabled()) {
|
||||
*trace_stream_ << "--- marked `" << name << "` usable in `"
|
||||
<< PrintAsID(*this) << "`\n";
|
||||
trace_stream_->Result()
|
||||
<< "marked `" << name << "` usable in `" << PrintAsID(*this) << "`\n";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,9 +130,9 @@ auto StaticScope::TryResolveHere(std::string_view name,
|
||||
|
||||
auto exit_scope_function = llvm::make_scope_exit([&]() {
|
||||
if (trace_stream_->is_enabled()) {
|
||||
*trace_stream_ << "--- resolved `" << name << "` as `"
|
||||
<< it->second.entity << "` in `" << PrintAsID(*this)
|
||||
<< "` (" << source_loc << ")\n";
|
||||
trace_stream_->Result()
|
||||
<< "resolved `" << name << "` as `" << it->second.entity << "` in `"
|
||||
<< PrintAsID(*this) << "` (" << source_loc << ")\n";
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user