diff --git a/explorer/common/source_location.h b/explorer/common/source_location.h index a8f3bb305389..cc46cc37f736 100644 --- a/explorer/common/source_location.h +++ b/explorer/common/source_location.h @@ -48,14 +48,20 @@ class SourceLocation { auto file_kind() const -> FileKind { return file_kind_; } void Print(llvm::raw_ostream& out) const { - out << filename_ << ":" << line_num_; + if (file_kind_ == FileKind::Prelude) { + out << llvm::StringRef(filename_).rsplit("/").second << ":" << line_num_; + } else { + out << filename_ << ":" << line_num_; + } } + auto ToString() const -> std::string { std::string result; llvm::raw_string_ostream out(result); Print(out); return result; } + LLVM_DUMP_METHOD void Dump() const { Print(llvm::errs()); } private: diff --git a/explorer/testdata/assert/fail_assert.carbon b/explorer/testdata/assert/fail_assert.carbon index 577c96767a8d..b0cc77a14cab 100644 --- a/explorer/testdata/assert/fail_assert.carbon +++ b/explorer/testdata/assert/fail_assert.carbon @@ -3,7 +3,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // // AUTOUPDATE -// CHECK:STDERR: RUNTIME ERROR: /explorer/data/prelude.carbon:{{\d+}}: "HALLO WELT" +// CHECK:STDERR: RUNTIME ERROR: prelude.carbon:{{\d+}}: "HALLO WELT" package ExplorerTest api; diff --git a/explorer/testdata/assert/fail_convert.carbon b/explorer/testdata/assert/fail_convert.carbon index 4b4633105444..18cd6988a84a 100644 --- a/explorer/testdata/assert/fail_convert.carbon +++ b/explorer/testdata/assert/fail_convert.carbon @@ -3,7 +3,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // // AUTOUPDATE -// CHECK:STDERR: RUNTIME ERROR: /explorer/data/prelude.carbon:{{\d+}}: "Fail" +// CHECK:STDERR: RUNTIME ERROR: prelude.carbon:{{\d+}}: "Fail" package ExplorerTest api; diff --git a/explorer/testdata/destructor/fail_delete_base_without_virtual_destructor.carbon b/explorer/testdata/destructor/fail_delete_base_without_virtual_destructor.carbon index f93b2ffc0a6c..2b54b41f924d 100644 --- a/explorer/testdata/destructor/fail_delete_base_without_virtual_destructor.carbon +++ b/explorer/testdata/destructor/fail_delete_base_without_virtual_destructor.carbon @@ -3,7 +3,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // // AUTOUPDATE -// CHECK:STDERR: RUNTIME ERROR: /explorer/data/prelude.carbon:{{\d+}}: Deallocating a derived class from base class pointer requires a virtual destructor +// CHECK:STDERR: RUNTIME ERROR: prelude.carbon:{{\d+}}: Deallocating a derived class from base class pointer requires a virtual destructor package ExplorerTest api; diff --git a/explorer/testdata/operators/fail_left_shift_large_rhs.carbon b/explorer/testdata/operators/fail_left_shift_large_rhs.carbon index 3eb36e6f090c..ac869897c87c 100644 --- a/explorer/testdata/operators/fail_left_shift_large_rhs.carbon +++ b/explorer/testdata/operators/fail_left_shift_large_rhs.carbon @@ -3,7 +3,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // // AUTOUPDATE -// CHECK:STDERR: RUNTIME ERROR: /explorer/data/prelude.carbon:{{\d+}}: Integer overflow +// CHECK:STDERR: RUNTIME ERROR: prelude.carbon:{{\d+}}: Integer overflow package ExplorerTest api; diff --git a/explorer/testdata/operators/fail_left_shift_negative_rhs.carbon b/explorer/testdata/operators/fail_left_shift_negative_rhs.carbon index 9866b0e71bfc..7c17f7408e6e 100644 --- a/explorer/testdata/operators/fail_left_shift_negative_rhs.carbon +++ b/explorer/testdata/operators/fail_left_shift_negative_rhs.carbon @@ -3,7 +3,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // // AUTOUPDATE -// CHECK:STDERR: RUNTIME ERROR: /explorer/data/prelude.carbon:{{\d+}}: Integer overflow +// CHECK:STDERR: RUNTIME ERROR: prelude.carbon:{{\d+}}: Integer overflow package ExplorerTest api; diff --git a/explorer/testdata/operators/fail_right_shift_large_rhs.carbon b/explorer/testdata/operators/fail_right_shift_large_rhs.carbon index 8aa0c384e940..9bdce1d14eb9 100644 --- a/explorer/testdata/operators/fail_right_shift_large_rhs.carbon +++ b/explorer/testdata/operators/fail_right_shift_large_rhs.carbon @@ -3,7 +3,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // // AUTOUPDATE -// CHECK:STDERR: RUNTIME ERROR: /explorer/data/prelude.carbon:{{\d+}}: Integer overflow +// CHECK:STDERR: RUNTIME ERROR: prelude.carbon:{{\d+}}: Integer overflow package ExplorerTest api; diff --git a/explorer/testdata/operators/fail_right_shift_negative_rhs.carbon b/explorer/testdata/operators/fail_right_shift_negative_rhs.carbon index 9cc9ab6a15bb..1d8fe7ddba40 100644 --- a/explorer/testdata/operators/fail_right_shift_negative_rhs.carbon +++ b/explorer/testdata/operators/fail_right_shift_negative_rhs.carbon @@ -3,7 +3,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // // AUTOUPDATE -// CHECK:STDERR: RUNTIME ERROR: /explorer/data/prelude.carbon:{{\d+}}: Integer overflow +// CHECK:STDERR: RUNTIME ERROR: prelude.carbon:{{\d+}}: Integer overflow package ExplorerTest api; diff --git a/explorer/testdata/optional/fail_optional_get_empty.carbon b/explorer/testdata/optional/fail_optional_get_empty.carbon index c2f0d1560a69..85778a7dc24d 100644 --- a/explorer/testdata/optional/fail_optional_get_empty.carbon +++ b/explorer/testdata/optional/fail_optional_get_empty.carbon @@ -3,7 +3,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // // AUTOUPDATE -// CHECK:STDERR: RUNTIME ERROR: /explorer/data/prelude.carbon:{{\d+}}: "Attempted to unwrap empty Optional" +// CHECK:STDERR: RUNTIME ERROR: prelude.carbon:{{\d+}}: "Attempted to unwrap empty Optional" package ExplorerTest api; diff --git a/explorer/testdata/random/fail_empty_range.carbon b/explorer/testdata/random/fail_empty_range.carbon index 81b7d839cd57..ed54d200c287 100644 --- a/explorer/testdata/random/fail_empty_range.carbon +++ b/explorer/testdata/random/fail_empty_range.carbon @@ -3,7 +3,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // // AUTOUPDATE -// CHECK:STDERR: RUNTIME ERROR: /explorer/data/prelude.carbon:{{\d+}}: Rand inputs must be ordered for a non-empty range: 0 must be less than 0 +// CHECK:STDERR: RUNTIME ERROR: prelude.carbon:{{\d+}}: Rand inputs must be ordered for a non-empty range: 0 must be less than 0 package ExplorerTest api; diff --git a/explorer/testdata/random/fail_reverse_range.carbon b/explorer/testdata/random/fail_reverse_range.carbon index f8f6ece01961..addae9335c55 100644 --- a/explorer/testdata/random/fail_reverse_range.carbon +++ b/explorer/testdata/random/fail_reverse_range.carbon @@ -3,7 +3,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // // AUTOUPDATE -// CHECK:STDERR: RUNTIME ERROR: /explorer/data/prelude.carbon:{{\d+}}: Rand inputs must be ordered for a non-empty range: 1 must be less than -1 +// CHECK:STDERR: RUNTIME ERROR: prelude.carbon:{{\d+}}: Rand inputs must be ordered for a non-empty range: 1 must be less than -1 package ExplorerTest api; diff --git a/explorer/testdata/trace/context_all.carbon b/explorer/testdata/trace/context_all.carbon index 43df75e7b11e..b9f177e21ae1 100644 --- a/explorer/testdata/trace/context_all.carbon +++ b/explorer/testdata/trace/context_all.carbon @@ -15,7 +15,7 @@ fn Main() -> i32 { // ARGS: --trace_file=- --trace_phase=all --trace_file_context=all %s // NOAUTOUPDATE // SET-CHECK-SUBSET -// CHECK:STDOUT: *** declaring `interface As` ({{.*}}/explorer/data/prelude.carbon:14) +// CHECK:STDOUT: *** declaring `interface As` (prelude.carbon:14) // CHECK:STDOUT: *** declaring function `Main` (context_all.carbon:11) // CHECK:STDOUT: interface As { // CHECK:STDOUT: fn Main ()-> i32 { diff --git a/explorer/testdata/trace/context_prelude.carbon b/explorer/testdata/trace/context_prelude.carbon index 4794a7f5242b..fea2afd7a5d1 100644 --- a/explorer/testdata/trace/context_prelude.carbon +++ b/explorer/testdata/trace/context_prelude.carbon @@ -15,5 +15,5 @@ fn Main() -> i32 { // ARGS: --trace_file=- --trace_phase=all --trace_file_context=prelude %s // NOAUTOUPDATE // SET-CHECK-SUBSET -// CHECK:STDOUT: *** declaring `interface As` ({{.*}}/explorer/data/prelude.carbon:14) +// CHECK:STDOUT: *** declaring `interface As` (prelude.carbon:14) // CHECK:STDOUT: interface As {