草庐IT

clang_complete

全部标签

c++ - 如何使 clang-format 跳过 c++ 代码的部分

有什么方法可以配置clang-format工具来跳过我的Qt::connect函数调用吗?我的构造函数中有几个连接,如下所示:connect(m_Job,SIGNAL(error(constQString&,constQString&)),this,SLOT(onError(constQString&,constQString&)));connect(m_Job,SIGNAL(message(constQString&)),this,SLOT(onMessage(constQString&)));connect(m_Job,SIGNAL(progress(int,int)),this,

带有 clang 的 C++ 11 线程

我想学习使用C++11线程来加速我的语言的编译(是的,我正在构建一个编译器:x)。我尝试的第一个示例用clang(3.3SVN)抛出了几个错误。它在GCC(4.6.3)下编译良好。我从llvm.org的SVN下载了clang和libc++。clang是用GCC(4.6.3)编译的,libc++是用clang编译的。两个makefile都是使用CMake生成的。对于clang,我遵循了这个指南:http://llvm.org/docs/GettingStarted.html#checkout对于libc++,我遵循了这个指南:http://libcxx.llvm.org/我要编译的代码(

c++ - 为什么 -O2 或更大的 clang 优化会破坏此代码?

我在网站上查看了类似的问题,但在这里找不到与我的情况相符的任何问题。这是我要运行的代码(需要C++14):#include#include#includeusingnamespacestd;classcountdownTimer{public:usingduration_t=chrono::high_resolution_clock::duration;countdownTimer(duration_tduration):duration{duration},paused{true}{}countdownTimer(constcountdownTimer&)=default;count

c++ - 构造函数上的 SFINAE 在 VC2017 中有效,但在 clang/gcc 中无效

这个问题在这里已经有了答案:std::enable_iftoconditionallycompileamemberfunction(8个答案)关闭4年前。#includetemplatestructS{template>S(){}template>S(int){}};Ss{};//errorinclang/gcc,OKinVC2017Ss{0};//errorinclang/gcc,OKinVC2017在这两种情况下,clang/gcc都尝试实例化由于SFINAE实际上应该丢弃的ctor。错误信息是:error:notypenamed'type'in'std::enable_if';'

c++ - clang 格式在 gVim 下不工作

我通过apt-get安装了clang-format-3.8。现在我尝试在gVim中使用它,但它不起作用。我检查过文件夹/usr/share/vim/addons/syntax中存在clang-format-3.8。但是当我在vim命令行中输入:pyf/usr/share/vim/addons/syntax/clang-format-3.8.py时,它返回:E319:抱歉,该命令在此版本中不可用。我在Ubuntu16.04下使用gVim7.4。 最佳答案 Dahn的回答是正确的,Ubuntu16.04附带的Vim二进制文件是用Pyth

c++ - 如何使用 clang 格式控制数组初始值设定项的缩进?

有时clang-format会这样做:SomeTypeVariableName[]={Thing1,Thing2,Thing3}有时clang-format会这样做:SomeTypeVariableName[]={Thing1,Thing2,Thing3}并且单个字符的变化可以使它在两者之间切换。有什么方法可以控制它的作用吗?我正在从最新的git源构建,所以最新的选项可用。 最佳答案 根据thisanswer,clang-format在某些步骤中将尽可能多的内容放在一行中,并在其上应用ColumnLimit。这可以解释行为之间的切换

c++ - 某些标准库类的 clang++ 链接器错误

我遇到了clang++的一个奇怪的链接器问题-它能够找到std::string类的定义,但不能找到std::ios_base::failure类的定义。$catfoo.cpp#include#includeintmain(){std::stringmsg="helloworld";std::ios_base::failuref(msg);std::cout,std::allocator>const&)'clang-3.7:error:linkercommandfailedwithexitcode1(use-vtoseeinvocation)$clang++--versionclangv

c++ - clang 不喜欢 boost::signals2?

一整天,我一直在使用Boost::Signals2库从部分代码中获取编译器错误。我已经将我想要做的事情简化为一个最小的例子:#includeintfoo();structfirst_nonzero{usingresult_type=int;templateresult_typeoperator()(Itfirst,Itlast)const{while(first!=last){if(*first!=0){return*first;}}return0;}};intfoo(){usingsignal=boost::signals2::signal;signals;returns();}当我

c++ - 当模板template-parameter的模板参数为pack expansion时,gcc失败,clang成功

templatestructS{templatestructA{};templatestructB{};templateclass>structC{};};S::C::B>s1;S::C::A>s2;//gcc5.1.0fails,clang3.6.0succeedsintmain(){}你可以在这里测试http://melpon.org/wandbox/permlink/hhy70gO9LMjLq9nU哪个是正确的,gcc还是clang? 最佳答案 这个问题在gcc6.0中已经解决 关

c++ - 我是否在简单的 OpenMP for 循环中误用了引用变量,还是 clang 错误?

我想我发现了一个clang++错误,但希望就我的代码是否正确提出建议。Clang静态分析器认为它没问题,并且编译没有问题,但是当使用clang3.7编译时,它从传递的引用vector中获取的大小完全错误。GCC和clang3.8都给出了正确的答案。我已将其简化为这个测试用例:#include#include//includingorexcludingompmakesnodifference#includevoiddoSomething(std::vector&k){#pragmaompforfor(inti=0;iv;v.push_back(1);std::vector&j=v;doS