diff --git a/test/tools/opt-viewer/Outputs/basic/basic_or.c.html b/test/tools/opt-viewer/Outputs/basic/basic_or.c.html
index 0a706b631c9..225ebabdbde 100644
--- a/test/tools/opt-viewer/Outputs/basic/basic_or.c.html
+++ b/test/tools/opt-viewer/Outputs/basic/basic_or.c.html
@@ -1,5 +1,6 @@
+
or.c
diff --git a/test/tools/opt-viewer/Outputs/basic/basic_or.h.html b/test/tools/opt-viewer/Outputs/basic/basic_or.h.html
index 6ca5a18f29d..7cbda8a66c7 100644
--- a/test/tools/opt-viewer/Outputs/basic/basic_or.h.html
+++ b/test/tools/opt-viewer/Outputs/basic/basic_or.h.html
@@ -1,5 +1,6 @@
+or.h
diff --git a/test/tools/opt-viewer/Outputs/suppress/s.swift.html b/test/tools/opt-viewer/Outputs/suppress/s.swift.html
index eae4c4f5610..813db9f9820 100644
--- a/test/tools/opt-viewer/Outputs/suppress/s.swift.html
+++ b/test/tools/opt-viewer/Outputs/suppress/s.swift.html
@@ -1,5 +1,6 @@
+s.swift
diff --git a/test/tools/opt-viewer/Outputs/unicode-function-name/s.swift.html b/test/tools/opt-viewer/Outputs/unicode-function-name/s.swift.html
index 470c7f8061a..67514d556c3 100644
--- a/test/tools/opt-viewer/Outputs/unicode-function-name/s.swift.html
+++ b/test/tools/opt-viewer/Outputs/unicode-function-name/s.swift.html
@@ -1,5 +1,6 @@
+s.swift
diff --git a/tools/opt-viewer/opt-viewer.py b/tools/opt-viewer/opt-viewer.py
index a3eaba1495c..4887043e0f9 100755
--- a/tools/opt-viewer/opt-viewer.py
+++ b/tools/opt-viewer/opt-viewer.py
@@ -44,6 +44,7 @@ def suppress(remark):
class SourceFileRenderer:
def __init__(self, source_dir, output_dir, filename, no_highlight):
+ self.filename = filename
existing_filename = None
if os.path.exists(filename):
existing_filename = filename
@@ -131,6 +132,7 @@ class SourceFileRenderer:
print('''
+{}
@@ -147,7 +149,7 @@ class SourceFileRenderer:
Inline Context
- | ''', file=self.stream)
+'''.format(os.path.basename(self.filename)), file=self.stream)
self.render_source_lines(self.source_stream, line_remarks)
print('''