Skip to content

Conversation

@evelez7
Copy link
Member

@evelez7 evelez7 commented Jan 7, 2026

The function template didn't check to see if a Location existed before
emitting the definition location line.

@evelez7 evelez7 requested review from ilovepi and petrhosek January 7, 2026 23:38
@evelez7 evelez7 marked this pull request as ready for review January 7, 2026 23:38
@llvmbot
Copy link
Member

llvmbot commented Jan 7, 2026

@llvm/pr-subscribers-clang-tools-extra

Author: Erick Velez (evelez7)

Changes

The function template didn't check to see if a Location existed before
emitting the definition location line.


Full diff: https://github.com/llvm/llvm-project/pull/174887.diff

3 Files Affected:

  • (modified) clang-tools-extra/clang-doc/assets/function-template.mustache (+3-1)
  • (modified) clang-tools-extra/test/clang-doc/json/class.cpp (-1)
  • (modified) clang-tools-extra/test/clang-doc/templates.cpp (-2)
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>

@evelez7 evelez7 force-pushed the users/evelez7/clang-doc-protected-methods branch from 9f8ecf5 to 2aa48a0 Compare January 8, 2026 06:13
@evelez7 evelez7 force-pushed the users/evelez7/clang-doc-empty-locations branch from 008f9df to 0c46055 Compare January 8, 2026 06:14
Base automatically changed from users/evelez7/clang-doc-protected-methods to main January 9, 2026 01:01
The function template didn't check to see if a `Location` existed before
emitting the definition location line.
@evelez7 evelez7 force-pushed the users/evelez7/clang-doc-empty-locations branch from 0c46055 to be256e4 Compare January 9, 2026 01:03
Copy link
Member Author

evelez7 commented Jan 9, 2026

Merge activity

  • Jan 9, 1:27 AM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Jan 9, 1:29 AM UTC: @evelez7 merged this pull request with Graphite.

@evelez7 evelez7 merged commit 4fa0767 into main Jan 9, 2026
10 checks passed
@evelez7 evelez7 deleted the users/evelez7/clang-doc-empty-locations branch January 9, 2026 01:29
kshitijvp pushed a commit to kshitijvp/llvm-project that referenced this pull request Jan 9, 2026
The function template didn't check to see if a `Location` existed before
emitting the definition location line.
Priyanshu3820 pushed a commit to Priyanshu3820/llvm-project that referenced this pull request Jan 18, 2026
The function template didn't check to see if a `Location` existed before
emitting the definition location line.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants