Clangd gives up (and it is fine but it is not fine)

Hi guys,
i have a very costly and large consteval-function that get executed at compile-time and may take several seconds to execute.

As soon as I invoke the function to initialize a static constexpr variable, clangd completely gives up on the file and code-completion, syntax-highlighting and everything clangd-related stops working within the file.

I fully understand that clangd has to give up at some point - i think this is actually reasonable. But it also cripples the IDEs functionality.

Basically, above the invocation of the function, everything works as expected, and below the invocation the IDE is nothing more than a text editor.

Is there a way to shortcut the compile-time function if, and only if, clangd pareses it?
Something along the lines of..

consteval ReturnType ComplicatedFunction()
{
#if CLANGD
return ReturnType{};
#else
//compliced stuff
return ReturnType{results};
#endif
}

?

0
1 comment

So far, i found, that clangd defines __clang__ macro during parsing. This enables a workaround as long my actual compiler is GCC.

What if my compiler was clang? Would clang actually fail where clangd gives up?

0

Please sign in to leave a comment.