草庐IT

clang-omp

全部标签

c++ - 关于表达式副作用的 Clang 警告

给定以下源代码:#include#includestructBase{virtual~Base();};structDerived:Base{};intmain(){std::unique_ptrptr_foo=std::make_unique();typeid(*ptr_foo).name();return0;}并编译它:clang++-std=c++14-Wall-Wextra-Werror-Wpedantic-g-otesttest.cpp环境设置:linuxx86_64clangversion5.0.0由于警告(注意-Werror),它无法编译:error:expression

c++ - clang 静态分析器是否因从 unique_ptr 列表中弹出前面而感到困惑?

以下C++11代码是我认为会在clang中触发误报的最小示例:#include#include#includeclassElementType{};intmain(intargc,constchar*argv[]){std::list>theList(5);theList.pop_front();for(constauto&element:theList){//(*)std::cout在标有星号(*)的行上,clang分析器声明...filePath.../main.cpp:21:29:Useofmemoryafteritisfreed(withinacallto'begin')就我的

c++ - 自动模板参数 : g++ 7. 3 vs clang++ 6.0 : Which compiler is correct?

对于这个代码示例,两个编译器会产生不同的结果。Clang生成两种不同的类型。G++对fu和fi使用相同的类型。哪个符合标准?#includetemplatestructfoo{decltype(IVAL)x=-IVAL;};intmain(){foofu;foofi;std::coutg++-7.3输出:42949672864294967286clang-6.0输出:-104294967286 最佳答案 gcc在这里是错误的,这显然是两种不同的类型。并确认-此错误已在gcc8.0.1中修复Samplecode

c++ - 模板别名冲突类型。 g++ 编译成功而 clang 失败

我遇到了一个非常奇怪的编译器错误。由于某种原因,发布的代码确实可以使用g++(7.3.0)正确编译,而clang(7.0.0)失败:../TemplateAlias/main.cpp:64:9:error:nomatchingfunctionforcallto'freeFunc'freeFunc(newFunc,dummyField);^~~~~~~~../TemplateAlias/main.cpp:73:12:note:ininstantiationofmemberfunction'Helper>::func'requestedherehelper.func();^../Templ

c++ - Windows 中的 clang "hello, world!"链接错误

我刚刚下载了CLang源代码,使用CMake创建了一个VisualC++10IDE工作区,并从VisualC++10.0(express)构建了所有内容。现在我在helloworld上遇到了一堆链接器错误:d:\dev\test>typecon>foo.cpp#includeusingnamespacestd;intmain(){coutclang++foo.cppfoo-839435.o:errorLNK2019:unresolvedexternalsymbol__ZSt4coutreferencedinfunction_mainfoo-839435.o:errorLNK2019:u

c++ - 带有 decltype : bug in clang or gcc? 的 sfinae

Clang-3.2可以编译并且代码按预期运行:structhave_f{intf(inti){return10;}};structempty{};templatestructouter{Tt;//ifThavef(),defineouter_f()templateintouter_f(inti){returnt.f(i);}};intmain(){outero1;outero2;//tosilenceunusedvarwarningreturno1.outer_f(10)+sizeof(o2);}任何版本的GCC拒绝:t.cc:13:6:error:‘structempty’hasno

c++ - Clang 编译有效,而 gcc 不适用于菱形继承(钻石问题)

我不确定我是否在这里遗漏了什么但似乎以下代码(在另一个我找不到的答案中可以找到类似的代码,顺便说一句,这里的问题是不同的)正在编译justfineforclang和notcompilingforgcc#includeusingnamespacestd;classbase{public:base(inti){};private:base(){};};classderivedA:virtualpublicbase{public:derivedA(inti):base(i){};protected:derivedA():base(0){};};classderivedB:virtualpub

c++ - constexpr 表达式和变量生命周期,g++ 和 clang 不一致的例子

考虑简单的C++11代码:templatestructFoo{};templateconstexprintsize(constFoo&){returnN;}templatevoiduse_size(constFoo&foo){constexprintn=size(foo);}intmain(){Foofoo;constexprintx=size(foo);//workswithgccandclang//_but_use_size(foo);//thesamestatementintheuse_size()//function_only_worksforgcc}我可以用g++-std=c

c++ - 使用 clang 获取类中的方法列表

在常见的IDE(选择一个)中,您通常有一个大纲View,显示特定类的方法列表。假设我在IFoo.h中有一个如下所示的C++接口(interface)类:#ifndefIFOO_H_#defineIFOO_H_classIFoo{public:virtual~IFoo(){}virtualvoidbar()=0;};#endif我如何(以编程方式)使用clang库为我的IFoo.h文件获取这样的IDE大纲列表?对于第一次开始,如果我能得到一个函数名称列表会有所帮助。我特别打算使用clang,因此非常感谢任何有关如何使用clang分析我的头文件的帮助。与此同时,我将在这里查看clang教程

c++ - 在 QtCreator 中是否有隐藏 clang 内联警告的选项?

问题可以配置QtCreator在编辑器窗口中隐藏警告,同时仍然在左侧显示警告图标吗?描述启用了Clang代码模型的QtCreator4.5在2个位置显示警告:内嵌在代码编辑器中在将鼠标悬停在左侧图标上时出现的弹出窗口中在我看来,前者使GUI变得困惑,而后者既足够又干扰性较小。举个例子:我查看了QtCreator选项,包括代码模型选项,但找不到任何设置。 最佳答案 对于QtCreator4.7.0,你必须去:工具>选项>文本编辑器>显示然后取消选中“行注释”选项 关于c++-在QtCrea