CLion 2017.3无法使用clang 5通过unique_ptr自动完成(适用于4.0.1) [英] CLion 2017.3 unable to autocomplete through unique_ptr using clang 5 (works with 4.0.1)

查看:101
本文介绍了CLion 2017.3无法使用clang 5通过unique_ptr自动完成(适用于4.0.1)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

编辑:滚动到下面的粗体部分以了解当前状态。

CLion似乎无法自动完成由所指向类型的成员在clang 5中的unique_ptr。我要么收到没有建议,要么得到 unique_ptr 本身的成员函数建议:

CLion seems to be unable to autocomplete members of a type pointed to by a unique_ptr in clang 5. I either get "no suggestions" or I get suggestions for member functions on the unique_ptr itself:

但是,对于4.0.1,一切正常:

However, with 4.0.1, everything works fine:

我还注意到,如果我要求CLion跳转到-> 在 c-> 上,在4.0.1中找到:

I also noticed that if I ask CLion to jump to the definition of the -> on c->, in 4.0.1 it finds it:

    _LIBCPP_INLINE_VISIBILITY pointer operator->() const _NOEXCEPT {return __ptr_.first();}

但是在5.0.0中,相同的命令说:找不到要去的声明,因此似乎更接近问题的根源。

But in 5.0.0, the same command says: Cannot find declaration to go to, so that seems to be closer to the root of the problem.

shared_ptr->< AUTOCOMPLETE> 在两个版本中都能正常工作。

shared_ptr-><AUTOCOMPLETE> works fine in both versions.

unique_ptr :: operator-> 的返回类型简化<内存> 中的代码更改为 element_type * 可以解决此问题,但是更改核心包含文件并不是我喜欢做的事情。令人困惑的是,5.0中的部分代码与

Simplifying the code in <memory> for unique_ptr::operator->'s return type to element_type * fixes the problem, but changing core include files isn't something I love doing. Confusingly, that part of the code in 5.0 is the same as it is in 4.0.1 where it works fine.

  _LIBCPP_INLINE_VISIBILITY
  element_type * operator->() const _NOEXCEPT {
      return __ptr_.first();
  }  _LIBCPP_INLINE_VISIBILITY

    // original code that doesn't play nice with CLion
//    pointer operator->() const _NOEXCEPT {
//        return __ptr_.first();
//    }

我对任何解决方法都感兴趣,甚至只是对是什么原因造成的。

I'm interested in any workarounds or even just an explanation as to what is going on to cause this.

我正在从llvm下载站点下载Mac上的预编译二进制文件。我想知道Apple clang编号方案与 real clang版本号是否有关。也许lang分析器认为我使用的是旧版本的(苹果)c,而不是现代的真实 c。

I'm on a Mac pre-built binaries from the llvm download site. I'm wondering if it's an issue with the Apple clang numbering scheme vs the real clang version numbers. Maybe the clang analyzer thinks I'm on some ancient version of (apple) clang instead of modern "real" clang.

谢谢。

推荐答案

一种解决方法是更改​​ unique_ptr :: operator-> 中的返回类型。 code>内存标头。

A workaround is to change the return type of unique_ptr::operator-> in the memory header.

  _LIBCPP_INLINE_VISIBILITY
  element_type * operator->() const _NOEXCEPT {
      return __ptr_.first();
  }  _LIBCPP_INLINE_VISIBILITY

    // original code that doesn't play nice with CLion
//    pointer operator->() const _NOEXCEPT {
//        return __ptr_.first();
//    }

使事情工作,并更紧密地反映 shared_ptr ,可以直接使用。

Makes things work and more closely mirrors how things are done in shared_ptr, which works out of the box.

这篇关于CLion 2017.3无法使用clang 5通过unique_ptr自动完成(适用于4.0.1)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆