Clangd code analysis seems to be using incorrect C++ version than specified in CMake

Upgraded from CLion 2021.1 to 2021.2 and started getting a bunch of code analysis errors for code which compiles just fine. The nature of the errors makes me think that CLion 2021.2 introduced a bug where Clangd is not using the correct C++ standard. Upgrading to CLion 2021.2.1 did not fix the issue.

For example, I am getting the following error with the following line of code:

No template named 'remove_cvref_t' in namespace 'std'; did you mean '_Remove_cvref_t'?

template < typename T, bool isBaseType = false, bool isConst = false >
struct ResolveTypeImpl : public ResolveTypeImpl< std::remove_cvref_t< T >, true, std::is_const_v< T > >

The MSVC sources (which can be found here: https://github.com/microsoft/STL/blob/main/stl/inc/xtr1common) have the following lines which specify that `remove_cvref_t` is only defined if _HAS_CXX20 is defined:

template <class _Ty>
using _Remove_cvref_t = remove_cv_t<remove_reference_t<_Ty>>;

#if _HAS_CXX20
template <class _Ty>
using remove_cvref_t = _Remove_cvref_t<_Ty>;

In my CMake I have:

set( CMAKE_CXX_STANDARD "20" )
set( CMAKE_CXX_EXTENSIONS OFF )

Searching through the CMake API reply .json files results, I find that the compile commands have a valid C++20 enabler:

"fragment" : "-std:c++latest"

Any help with this is much appreciated! Thank you in advance!

CLion 2021.2.1
Build #CL-212.5080.54, built on August 24, 2021
Licensed to Stellar Science / Reece Broughton
Subscription is active until June 3, 2022.
Runtime version: 11.0.11+9-b1504.16 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Windows 10 10.0
GC: ParNew, ConcurrentMarkSweep
Memory: 5987M
Cores: 12
Registry: debugger.watches.in.variables=false, run.processes.with.pty=true
Non-Bundled Plugins: com.jetbrains.plugins.ini4idea (212.4746.57), com.intellij.plugins.watcher (212.5080.8), com.markskelton.one-dark-theme (5.3.0)

0

请先登录再写评论。