STEllAR-GROUP / hpx

The C++ Standard Library for Parallelism and Concurrency

Home Page:https://hpx.stellar-group.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Clangd (Language Server) throws error for __integer_pack at pack.hpp

andreichalapco opened this issue · comments

I've built the hpx from source (using master from Jun 2023) using a gcc 13.1.1 compiler. My Ide for development is sometimes clion and also nvim that both use clangd language server.

When going trough examples from the hpx I instantly get errors from the language server: Use of undeclared identifier __integer_pack in pack.hpp:49. I know this is a placeholder for the gcc compiler but when running this with clangd it is pretty nerving sometimes...

Should pack.hpp use something in the direction of this:

#if __has_builtin(__make_integer_seq)
      template<typename, size_t... _Indices>
	using _IdxTuple = _Index_tuple<_Indices...>;

      // Clang defines __make_integer_seq for this purpose.
      using __type = __make_integer_seq<_IdxTuple, size_t, _Num>;
#else
      // For GCC and other compilers, use __integer_pack instead.
      using __type = _Index_tuple<__integer_pack(_Num)...>;
#endif

(this is basically taken from this)

In order to reproduce this just run:

clangd --check=main.cpp

Where main.cpp include

#include <hpx/hpx_main.hpp>
#include <hpx/iostream.hpp>

int main()
{
    // Say hello to the world!
    hpx::cout << "Hello World!\n" << std::flush;
    return 0;
}

One other option I tried was using clangd with --query-driver to query the gcc driver for the necessary system headers but this didn't fix the problem.

Is there any solution to make the language server work with the source code of hpx ... ?

I'm not sure if clangd language server is a high priority now ... but I thought I mention this. If needed I could try to make a pull request.

On further checking the cmake building process I discovered this:

  # Check the availability of certain C++ builtins
  hpx_check_for_builtin_integer_pack(DEFINITIONS HPX_HAVE_BUILTIN_INTEGER_PACK)

  hpx_check_for_builtin_make_integer_seq(
    DEFINITIONS HPX_HAVE_BUILTIN_MAKE_INTEGER_SEQ
  )

So basically if building the source with clang ... I can avoid the macro HPX_HAVE_BUILTIN_INTEGER_PACK ... and have HPX_HAVE_BUILTIN_MAKE_INTEGER_SEQ.

I still believe this is not something good ... because there are for sure many people that want to compile everything with gcc but still use the clangd language server ... (so basically use clion)

I'm not sure if anybody I know uses clangd for their work, so I wouldn't know whom to ask. This is probably caused by HPX being configured by one compiler (gcc) and being used with another one (clangd). The decision of what is supported is being made at configuration time, so that later on clangd sees things to be used that it doesn't support.

I'd very much appreciate it if you had the time and interest to come up with a possible fix (PR) for this.

So the issue is related to clangd (clion also uses this language server). I posted an issue and it was fixed in the newer versions of clang.
see clangd/clangd#1906.

Let's not close this issue. We've had similar reports in other contexts. I believe this can be fixed.

Yeah! I think you're right! As a feedback after using hpx there a lot of problems with the clangd lanaguge server, which is a real pity, because I think it is nowadays the most used one (it' s also open source). It would be nice if some efforts would be directed in this direction.

Yeah! I think you're right! As a feedback after using hpx there a lot of problems with the clangd lanaguge server, which is a real pity, because I think it is nowadays the most used one (it' s also open source). It would be nice if some efforts would be directed in this direction.

What other problems are there?