tree-sitter / node-tree-sitter

Node.js bindings for tree-sitter
https://www.npmjs.com/package/tree-sitter
MIT License
648 stars 113 forks source link

fix: compilation with clang >=18 #204

Closed deepak1556 closed 4 months ago

deepak1556 commented 4 months ago

LLVM >= 18 has deprecated and removed char_trait implementation for non char types in https://github.com/llvm/llvm-project/commit/c3668779c13596e223c26fbd49670d18cd638c40, for VSCode we build the native modules using libc++ and clang to align with the runtime, building current node-tree-sitter leads to the following error

/mnt/vss/_work/1/s/.build/libcxx_headers/include/__string/char_traits.h:617:23: error: implicit instantiation of undefined template 'std::char_traits<unsigned short>'
  617 |   const _CharT* __r = _Traits::find(__p + __pos, __sz - __pos, __c);
      |                       ^
/mnt/vss/_work/1/s/.build/libcxx_headers/include/string:3375:15: note: in instantiation of function template specialization 'std::__str_find<unsigned short, unsigned long, std::char_traits<unsigned short>, 18446744073709551615UL>' requested here
 3375 |   return std::__str_find<value_type, size_type, traits_type, npos>(data(), size(), __c, __pos);
      |               ^
../src/node.cc:484:51: note: in instantiation of member function 'std::basic_string<unsigned short>::find' requested here
  484 |   bool contains(TSSymbol symbol) { return symbols.find(symbol) != symbols.npos; }
      |                                                   ^
/mnt/vss/_work/1/s/.build/libcxx_headers/include/__fwd/string.h:23:29: note: template is declared here
   23 | struct _LIBCPP_TEMPLATE_VIS char_traits;
amaanq commented 4 months ago

thanks!