草庐IT

c++ - Clang 为使用的类型别名发出 "unused type alias"警告

我有一些代码,Clang正在为其生成警告。这是对实际代码的简化,但精神是一样的。本地类中的this_t用于实例化其他一些模板类。templatestructvalue_holder{Tvalue;};templateintget_value(){structvalue_t{usingthis_t=value_t;//^herestaticvalue_holderval(){returnvalue_holder();}operatorint(){return0;}};returnvalue_t::val().value;}intmain(intargc,char**argv){retur

c++ - 如何使用Frama-Clang解析C++程序

我安装了Frama-c的插件Frama-Clang来解析C++程序。但是,我不知道如何正确使用它。我用一个非常简单的C++程序尝试了它,但失败了。这是test.cpp的代码:#includeusingnamespacestd;intmain(){cout我使用命令frama-ctest.cpp并得到以下错误:[kernel]Parsingtest.cpp(externalfront-end)Infileincludedfromtest.cpp:1:Infileincludedfrom/home/server3/.opam/system/share/frama-c/frama-clang

c++ - 警告: "when type is in parentheses, array cannot have dynamic size"?的原因是什么

我已经发布了一个关于与数组的动态内存分配相关的GCC错误的问题:Anerrorisissuedbygccrelativetoparsingtype-idinanewexpression现在使用ClangHEAD10.0.0我收到以下警告:rog.cc:9:37:warning:whentypeisinparentheses,arraycannothavedynamicsizeint(**a)[N3]=new(int(*[n1])[N3]);~~^~~当我运行这个演示程序时:#includeintmain(){constsize_tN3=4;size_tn1=2;int(**a)[N3]

c++ - 简化复杂的 C++ 模板符号

我正在开发调试/内存工具。我想显示来自C++的符号,问题是它们非常冗长。目前我只使用__cxa_demangle,但由于包含默认模板参数,这通常会产生超过500个字符的巨大字符串。clang++在报告符号时显然可以做一些聪明的事情,我有什么办法可以利用它吗?举个简单的例子,让我们来看:std::map,std::allocator>>::find(std::stringconst&)这显然可以报告为:std::map::find(std::stringconst&)..如果我有足够智能的工具。很明显,如果没有额外的知识(比如最初使用的包含-我可能会得到这些),这通常很难做到,但我将不胜

c++ - MinGW-Clang 的 libgcc_s_dw2-1.dll 丢失了吗?

当我尝试运行rubenvb'sClang3.2时,我得到:Theprogramcan'tstartbecauselibgcc_s_dw2-1.dllismissingfromyourcomputer.Tryreinstallingtheprogramtofixthisproblem.我在任何地方都找不到DLL...我缺少什么包/我该如何解决这个问题? 最佳答案 您还需要下载一个gcc包,Clang的构建没有C++库或任何东西。它的意思是与gcc包结合使用。来自here:HereyouwillfindthelatestClangcom

c++ - 常规初始化中的意外转换

Clang3.2报错如下代码,不明白为什么会出问题。该错误仅发生在模板函数中,并且仅在使用大括号进行初始化时发生。其他两个初始化按预期工作。structfoo{foo(){}~foo()=default;//deletedfoo(constfoo&rhs)=delete;foo(foo&&rhs)noexcept=delete;autooperator=(constfoo&rhs)->foo&=delete;autooperator=(foo&&rhs)noexcept->foo&=delete;};templatevoidbar(){fooa;//OKfoob{};//ERROR}i

c++ - 未使用的模板方法中的错误

structB{inta;voidfoo(){a=5;}};templatestructA{A(inti){B::foo();}A(doubled){}};intmain(){Aa(5.0);}gcc4.7.2编译它没有错误。clang3.4svn提示:$clang-Wall-Wextratest.cpptest.cpp:10:16:error:calltonon-staticmemberfunctionwithoutanobjectargumentA(inti){B::foo();}~~~^~~代码当然是错误的,但是哪个编译器是符合标准的呢?同样奇怪的是,如果您使用5而不是5.0,c

c++ - 通用模板化枚举空值

clang++提示变量未初始化:templatevoidfunc(){TEnumenumVar;//...if(something())enumVar=someValue();//...if(something())doSomethingWith(enumVar);//通常,为了避免这个警告,枚举可以有一个Unknown=-1值或类似的东西-但不幸的是,在这里枚举类型被用户传递为typenameTEnum,所以我不知道它是否包含“空值”。有什么办法可以解决这个问题吗?还是我应该忽略/禁止显示警告? 最佳答案 总是初始化,例如使用三元

c++ - 从 clang 中的 FunctionDecl 类获取参数信息

如何从clang中的FunctionDecl类获取参数信息作为字符串。我正在尝试,但对这么多的继承感到困惑。他们的编译器还说getReturnType()不是FunctionDecl的成员,但doxygen文档另有说明。请帮忙。http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.htmlusingnamespacestd;usingnamespaceclang;usingnamespaceclang::driver;usingnamespaceclang::tooling;usingnamespacellvm;.......

c++ - 获取 Clang 中变量的大小

使用Clang库,是否有一些可用的方法来获取变量的大小(就像我在常规C/C++程序中使用sizeof()一样?我能够(这就是我想做的)发现VarDecl,但目前我仍然无法在Clang命名空间中找到任何方法来获取我的var的大小发现了当前的VarDecl 最佳答案 类型的大小信息存储在与给定类型关联的TypeInfo中。您可以通过getTypeInfo函数从ASTContext中获取对应的FieldInfo对。该对的第一个元素是类型的大小(以位为单位)。第二个元素是以位为单位的类型对齐。boolVisitVarDecl(VarDecl