Author: hokein Date: Wed May 29 05:03:41 2019 New Revision: 361951 URL: http://llvm.org/viewvc/llvm-project?rev=361951&view=rev Log: [clangd] Another improvement for std include mapping.
Summary: 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). Reviewers: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D62575 Modified: clang-tools-extra/trunk/clangd/StdSymbolMap.inc clang-tools-extra/trunk/clangd/include-mapping/gen_std.py clang-tools-extra/trunk/clangd/include-mapping/test.py Modified: clang-tools-extra/trunk/clangd/StdSymbolMap.inc URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/StdSymbolMap.inc?rev=361951&r1=361950&r2=361951&view=diff ============================================================================== --- clang-tools-extra/trunk/clangd/StdSymbolMap.inc (original) +++ clang-tools-extra/trunk/clangd/StdSymbolMap.inc Wed May 29 05:03:41 2019 @@ -454,11 +454,24 @@ SYMBOL(includes, std::, <algorithm>) 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(u16string_view, std::, <string_vi 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>) Modified: clang-tools-extra/trunk/clangd/include-mapping/gen_std.py URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/include-mapping/gen_std.py?rev=361951&r1=361950&r2=361951&view=diff ============================================================================== --- clang-tools-extra/trunk/clangd/include-mapping/gen_std.py (original) +++ clang-tools-extra/trunk/clangd/include-mapping/gen_std.py Wed May 29 05:03:41 2019 @@ -84,10 +84,9 @@ def ParseSymbolPage(symbol_page_html, sy 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'): Modified: clang-tools-extra/trunk/clangd/include-mapping/test.py URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/include-mapping/test.py?rev=361951&r1=361950&r2=361951&view=diff ============================================================================== --- clang-tools-extra/trunk/clangd/include-mapping/test.py (original) +++ clang-tools-extra/trunk/clangd/include-mapping/test.py Wed May 29 05:03:41 2019 @@ -85,7 +85,11 @@ class TestStdGen(unittest.TestCase): <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 @@ class TestStdGen(unittest.TestCase): <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 @@ class TestStdGen(unittest.TestCase): 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"><cstdint></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() _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits