https://github.com/evelez7 updated 
https://github.com/llvm/llvm-project/pull/174887

>From be256e47ff52a24fe4a2c63a210d1aa1bbdd7ca4 Mon Sep 17 00:00:00 2001
From: Erick Velez <[email protected]>
Date: Wed, 7 Jan 2026 15:36:21 -0800
Subject: [PATCH] [clang-doc] Don't serialize non-existant locations in HTML

The function template didn't check to see if a `Location` existed before
emitting the definition location line.
---
 clang-tools-extra/clang-doc/assets/function-template.mustache | 4 +++-
 clang-tools-extra/test/clang-doc/json/class.cpp               | 1 -
 clang-tools-extra/test/clang-doc/templates.cpp                | 2 --
 3 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/clang-tools-extra/clang-doc/assets/function-template.mustache 
b/clang-tools-extra/clang-doc/assets/function-template.mustache
index 1e81f34196137..354e26b7b05b0 100644
--- a/clang-tools-extra/clang-doc/assets/function-template.mustache
+++ b/clang-tools-extra/clang-doc/assets/function-template.mustache
@@ -17,5 +17,7 @@
             {{>Comments}}
         </div>
         {{/Description}}
-        <p>Defined at line {{Location.LineNumber}} of file 
{{Location.Filename}}</p>
+        {{#Location}}
+        <p>Defined at line {{LineNumber}} of file {{Filename}}</p>
+        {{/Location}}
 </div>
diff --git a/clang-tools-extra/test/clang-doc/json/class.cpp 
b/clang-tools-extra/test/clang-doc/json/class.cpp
index 5c63aa5ec45ef..c4f0b2166a3f8 100644
--- a/clang-tools-extra/test/clang-doc/json/class.cpp
+++ b/clang-tools-extra/test/clang-doc/json/class.cpp
@@ -335,7 +335,6 @@ struct MyClass {
 // HTML-NEXT:     <div>
 // HTML-NEXT:         <div id="{{([0-9A-F]{40})}}" class="delimiter-container">
 // HTML-NEXT:                 <pre><code class="language-cpp 
code-clang-doc">int protectedMethod ()</code></pre>
-// HTML-NEXT:                 <p>Defined at line  of file </p>
 // HTML-NEXT:         </div>
 // HTML-NEXT:     </div>
 // HTML-NEXT: </section>
diff --git a/clang-tools-extra/test/clang-doc/templates.cpp 
b/clang-tools-extra/test/clang-doc/templates.cpp
index c9f1370a19e6e..27fff6ed5a09d 100644
--- a/clang-tools-extra/test/clang-doc/templates.cpp
+++ b/clang-tools-extra/test/clang-doc/templates.cpp
@@ -79,8 +79,6 @@ void ParamPackFunction(T... args);
 
 // HTML:        <pre><code class="language-cpp code-clang-doc">template 
&lt;class... T&gt;</code></pre>
 // HTML-NEXT:      <pre><code class="language-cpp code-clang-doc">void 
ParamPackFunction (T... args)</code></pre>
-// COM:            FIXME: Omit defined line if not defined, or emit 
declaration line.
-// HTML-NEXT:      <p>Defined at line of file </p>
 // HTML-NEXT:  </div>
 
 template <typename T, int U = 1>

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to