hokein created this revision.
hokein added a reviewer: sammccall.
Herald added subscribers: kadircet, arphaman, jkorous, MaskRay, ilya-biryukov.
Herald added a project: clang.

Improve the way of checking a symbol name is in the first cell. The previous way
is not very robost for cases where a cell lists multiple symbols (e.g. int8_t).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D62575

Files:
  clang-tools-extra/clangd/StdSymbolMap.inc
  clang-tools-extra/clangd/include-mapping/gen_std.py
  clang-tools-extra/clangd/include-mapping/test.py

Index: clang-tools-extra/clangd/include-mapping/test.py
===================================================================
--- clang-tools-extra/clangd/include-mapping/test.py
+++ clang-tools-extra/clangd/include-mapping/test.py
@@ -85,7 +85,11 @@
     <td></td>
   </tr>
   <tr class="t-dcl">
-    <td>void foo()</td>
+    <td>
+      <span>void</span>
+      foo
+      <span>()</span>
+    </td>
     <td>this is matched</td>
   </tr>
 </tbody></table>
@@ -108,7 +112,11 @@
 <td></td>
 </tr>
 <tr class="t-dcl">
-  <td>void foo()</td>
+  <td>
+    <span>void</span>
+    foo
+    <span>()</span>
+  </td>
   <td>this is matched</td>
 </tr>
 </tbody></table>
@@ -116,6 +124,32 @@
     self.assertEqual(ParseSymbolPage(html, "foo"),
                      set(['<algorithm>', '<utility>']))
 
+  def testParseSymbolPage_MulSymbolsInSameTd(self):
+    # defined in header <cstdint>
+    #   int8_t
+    #   int16_t
+    html = """
+<table class="t-dcl-begin"><tbody>
+<tr class="t-dsc-header">
+<td><div>
+     Defined in header <code><a href="cstdint.html" title="cstdint">&lt;cstdint&gt;</a></code><br>
+</div></td>
+<td></td>
+</tr>
+<tr class="t-dcl">
+  <td>
+    <span>int8_t</span>
+    <span>int16_t</span>
+  </td>
+  <td>this is matched</td>
+</tr>
+</tbody></table>
+"""
+    self.assertEqual(ParseSymbolPage(html, "int8_t"),
+                     set(['<cstdint>']))
+    self.assertEqual(ParseSymbolPage(html, "int16_t"),
+                     set(['<cstdint>']))
+
 
 if __name__ == '__main__':
   unittest.main()
Index: clang-tools-extra/clangd/include-mapping/gen_std.py
===================================================================
--- clang-tools-extra/clangd/include-mapping/gen_std.py
+++ clang-tools-extra/clangd/include-mapping/gen_std.py
@@ -84,10 +84,9 @@
     for row in table.select('tr'):
       if HasClass(row, 't-dcl', 't-dsc'):
         was_decl = True
-        # Declaration is in the first cell.
-        text = row.find('td').text
-        # Decl may not be for the symbol name we're looking for.
-        if not re.search("\\b%s\\b" % symbol_name, text):
+        # Symbols are in the first cell.
+        found_symbols = row.find('td').stripped_strings
+        if not symbol_name in found_symbols:
           continue
         headers.update(current_headers)
       elif HasClass(row, 't-dsc-header'):
Index: clang-tools-extra/clangd/StdSymbolMap.inc
===================================================================
--- clang-tools-extra/clangd/StdSymbolMap.inc
+++ clang-tools-extra/clangd/StdSymbolMap.inc
@@ -454,11 +454,24 @@
 SYMBOL(inclusive_scan, std::, <numeric>)
 SYMBOL(independent_bits_engine, std::, <random>)
 SYMBOL(indirect_array, std::, <valarray>)
+SYMBOL(initializer_list, std::, <initializer_list>)
 SYMBOL(inner_product, std::, <numeric>)
 SYMBOL(inplace_merge, std::, <algorithm>)
 SYMBOL(input_iterator_tag, std::, <iterator>)
 SYMBOL(insert_iterator, std::, <iterator>)
 SYMBOL(inserter, std::, <iterator>)
+SYMBOL(int16_t, std::, <cstdint>)
+SYMBOL(int32_t, std::, <cstdint>)
+SYMBOL(int64_t, std::, <cstdint>)
+SYMBOL(int8_t, std::, <cstdint>)
+SYMBOL(int_fast16_t, std::, <cstdint>)
+SYMBOL(int_fast32_t, std::, <cstdint>)
+SYMBOL(int_fast64_t, std::, <cstdint>)
+SYMBOL(int_fast8_t, std::, <cstdint>)
+SYMBOL(int_least16_t, std::, <cstdint>)
+SYMBOL(int_least32_t, std::, <cstdint>)
+SYMBOL(int_least64_t, std::, <cstdint>)
+SYMBOL(int_least8_t, std::, <cstdint>)
 SYMBOL(integer_sequence, std::, <utility>)
 SYMBOL(integral_constant, std::, <type_traits>)
 SYMBOL(internal, std::, <ios>)
@@ -1150,6 +1163,18 @@
 SYMBOL(u32streampos, std::, <ios>)
 SYMBOL(u32string, std::, <string>)
 SYMBOL(u32string_view, std::, <string_view>)
+SYMBOL(uint16_t, std::, <cstdint>)
+SYMBOL(uint32_t, std::, <cstdint>)
+SYMBOL(uint64_t, std::, <cstdint>)
+SYMBOL(uint8_t, std::, <cstdint>)
+SYMBOL(uint_fast16_t, std::, <cstdint>)
+SYMBOL(uint_fast32_t, std::, <cstdint>)
+SYMBOL(uint_fast64_t, std::, <cstdint>)
+SYMBOL(uint_fast8_t, std::, <cstdint>)
+SYMBOL(uint_least16_t, std::, <cstdint>)
+SYMBOL(uint_least32_t, std::, <cstdint>)
+SYMBOL(uint_least64_t, std::, <cstdint>)
+SYMBOL(uint_least8_t, std::, <cstdint>)
 SYMBOL(uintmax_t, std::, <cstdint>)
 SYMBOL(uintptr_t, std::, <cstdint>)
 SYMBOL(uncaught_exceptions, std::, <exception>)
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
  • [PATCH] D62575: [clangd] Anothe... Haojian Wu via Phabricator via cfe-commits

Reply via email to