Commit 87e67bb7 authored by Camillo Bruni's avatar Camillo Bruni Committed by V8 LUCI CQ

[toque] Change source position format

Use a url-like source position format for emited defnition
locations. Hopefully this will make links clickable on codesearch.

Change-Id: I343c6bc3cc4f159d5e3974d7ec5af4a578aaf03a
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3207887Reviewed-by: 's avatarNico Hartmann <nicohartmann@chromium.org>
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/main@{#77261}
parent 4ddc53d8
......@@ -14,8 +14,7 @@ void Function::PrintDeclarationHeader(std::ostream& stream,
if (!description_.empty()) {
stream << std::string(indentation, ' ') << "// " << description_ << "\n";
}
stream << std::string(indentation, ' ') << "// " << PositionAsString(pos_)
<< "\n";
stream << std::string(indentation, ' ') << "// " << pos_ << "\n";
stream << std::string(indentation, ' ');
if (IsExport()) stream << "V8_EXPORT_PRIVATE ";
if (IsV8Inline())
......@@ -68,8 +67,7 @@ void Function::PrintInlineDefinition(
void Function::PrintBeginDefinition(std::ostream& stream,
int indentation) const {
stream << std::string(indentation, ' ') << "// " << PositionAsString(pos_)
<< "\n";
stream << std::string(indentation, ' ') << "// " << pos_ << "\n";
std::string scope;
if (owning_class_) {
scope = owning_class_->GetName();
......
......@@ -1935,7 +1935,8 @@ void FailCallableLookup(
GenericCallable* generic = failure.first;
const std::string& fail_reason = failure.second;
stream << "\n " << generic->name() << " defined at "
<< generic->Position() << ":\n " << fail_reason << "\n";
<< PositionAsString(generic->Position()) << ":\n "
<< fail_reason << "\n";
}
}
ReportError(stream.str());
......@@ -3897,7 +3898,7 @@ class ClassFieldOffsetGenerator : public FieldOffsetsGenerator {
gen_name_(gen_name) {}
void WriteField(const Field& f, const std::string& size_string) override {
hdr_ << " // " << PositionAsString(f.pos) << "\n";
hdr_ << " // " << f.pos << "\n";
std::string field = "k" + CamelifyString(f.name_and_type.name) + "Offset";
std::string field_end = field + "End";
hdr_ << " static constexpr int " << field << " = " << previous_field_end_
......@@ -4034,7 +4035,7 @@ void CppClassGenerator::GenerateClass() {
stream << " return o.Is" << name_ << "();\n";
});
}
hdr_ << "// Definition " << PositionAsString(Position()) << "\n";
hdr_ << "// Definition " << Position() << "\n";
hdr_ << template_decl() << "\n";
hdr_ << "class " << gen_name_ << " : public P {\n";
hdr_ << " static_assert(\n"
......
......@@ -109,7 +109,9 @@ inline std::string PositionAsString(SourcePosition pos) {
}
inline std::ostream& operator<<(std::ostream& out, SourcePosition pos) {
return out << PositionAsString(pos);
return out << SourceFileMap::PathFromV8Root(pos.source)
<< "?l=" << (pos.start.line + 1)
<< "&c=" << (pos.start.column + 1);
}
} // namespace torque
......
......@@ -68,7 +68,7 @@ int WrappedMain(int argc, const char** argv) {
for (const TorqueMessage& message : result.messages) {
if (message.position) {
std::cerr << *message.position << ": ";
std::cerr << PositionAsString(*message.position) << ": ";
}
std::cerr << ErrorPrefixFor(message.kind) << ": " << message.message
......
......@@ -122,10 +122,6 @@ base::Optional<std::string> FileUriDecode(const std::string& uri) {
return decoded.str();
}
std::string CurrentPositionAsString() {
return PositionAsString(CurrentSourcePosition::Get());
}
MessageBuilder::MessageBuilder(const std::string& message,
TorqueMessage::Kind kind) {
base::Optional<SourcePosition> position;
......
......@@ -110,8 +110,6 @@ bool StartsWithSingleUnderscore(const std::string& str);
void ReplaceFileContentsIfDifferent(const std::string& file_path,
const std::string& contents);
std::string CurrentPositionAsString();
template <class T>
class Deduplicator {
public:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment