草庐IT

clang-omp

全部标签

c++ - 哪个 Clang 警告等同于 GCC 的 Wzero-as-null-pointer-constant?

我们的项目使用C++11/14,我们希望使用nullptr而不是0或NULL指针,即使0(作为整数文字)是允许的。我有以下代码:intmain(){int*ptr1=nullptr;//#1int*ptr2=0;//#2}如果我使用GCC(5.3.0)和标记-Wzero-as-null-pointer-constant进行编译,它会在#2中发出警告,但我可以'在Clang中找不到类似的标志。如果我使用Clang(3.7.1)和标志-Weverything编译代码,我不会收到任何关于#2的警告。那么,有什么办法可以在Clang中得到类似的警告吗? 最佳答案

c++ - 使用 C++11 在 Cygwin 上使用 Clang

我在Cygwin上安装了Clang并尝试编译这段代码:#includeintmain(){std::cout如果我执行clang++file.cpp,效果很好。如果我执行clang++file.cpp-std=c++11,它将不起作用。我从这样的标准header中得到错误:Infileincludedfromfile.cpp:1:Infileincludedfrom/usr/lib/gcc/i686-pc-cygwin/4.5.3/include/c++/iostream:39:Infileincludedfrom/usr/lib/gcc/i686-pc-cygwin/4.5.3/in

c++ - 不允许 clang 变量名中的 Unicode/特殊字符?

Thisquestionhasunicodetextthatmaynotdisplaycorrectlyinallbrowsers.clang现在(>3.3)在变量名中支持unicode字符http://llvm.org/releases/3.3/tools/clang/docs/ReleaseNotes.html#major-new-features.但是一些特殊字符仍然被禁止。intmain(){doubleα=2.;//alpha,ok!double∞=99999.;//infinity,error}给予:error:non-ASCIIcharactersarenotallowe

c++ - 设置 IndentWidth 在 clang 格式中不起作用

我的主目录中有.clang-format并设置indentwidth4如下。BasedOnStyle:LLVMStandard:Cpp11IndentWidth:4TabWidth:4UseTab:Never但是当我使用clang-format-style='~/.clang-format'a.cpp格式化我的代码时,缩进宽度变为2。例如://Seethisindentwidth2.Theoriginalfilehaswidth4,//butclang-formatchangesittowidth2.intmain(intargc,charconst*argv[]){Aa;a.bar(

c++ - clang 格式,数组初始化器

在我们的项目中,我们有时在一行中初始化数组,有时我们将它们初始化为block。那就是strings::UniCharconsts[]={'H','e','l','l','o'};对比strings::UniCharconsts[]={'H','e','l','l','o'};我希望clang-format能够区分这两种类型,而不是将第二种类型转换为第一种类型或在左大括号之后对齐元素。不是这样的:strings::UniCharconsts[]={'H','e','l','l','o'};有没有办法使用配置文件来实现? 最佳答案 在最

c++ - 在两个连续的 pragma omp for 的情况下隐式屏障 vs nowait

查看文档here,以下结构定义明确:#pragmaompparallel//Line1{#pragmaompfornowait//Line3for(i=0;i自从Herethenowaitclauseimpliesthatthreadscanstartonthesecondloopwhileotherthreadsarestillworkingonthefirst.Sincethetwoloopsusethesameschedulehere,aniterationthatusesa[i]canindeedrelyonitthatthatvaluehasbeencomputed.我很难理

c++ - 有没有办法强制使用 "this->"用于 clang-format/clang-tidy 中的类成员/方法?

我到处搜索,但我可能用错了术语。我还没有为此找到选项。我唯一发现的是这个未回答的问题(但是有点宽泛):CPPlint:Canyouenforceuseofthisforclassvariables?. 最佳答案 鉴于existingoptions,我不相信这在clang-format中是可能的,future也不会。主要原因是程序的工作方式。它不会将C++代码解析为AST,而是将文本标记化而不需要包含(定义它的成员和全局变量)而不是编译数据库(影响定义、包含路径……)它是甚至可以给它一段代码并重新格式化。从问题的性质来看,如果它可以存

C++ 程序不使用 Clang 和 visual Studio 2010 Express 编译

我正在尝试使用VisualC++2010Express编译本教程中所述的源代码。http://kevinaboos.wordpress.com/2013/07/23/clang-tutorial-part-ii-libtooling-example/完整的源代码在这里。https://github.com/kevinaboos/LibToolingExample我已使用此链接中提供的可执行文件来安装LLVM。由于格式问题,我无法发布完整的错误消息。但我会尽量提供尽可能多的信息。当我尝试构建解决方案时,出现以下错误:-argumentunusedduringcompilationwarn

c++ - clang 和 g++ 在处理 const 对象时的差异

这个问题在这里已经有了答案:Whydoesgccallowaconstobjectwithoutauser-declareddefaultconstructorbutnotclang?(1个回答)关闭8年前。考虑代码:structFoo{intx=10;};intmain(){constFoofoo;}它在g++下编译http://coliru.stacked-crooked.com/a/99bd8006e10b47ef,但是在clang++http://coliru.stacked-crooked.com/a/93f94f7d9625b579下会报错:error:defaultini

c++ - 在 Clang 中判断访问的 CXXRecordDecl 是类、结构还是 union

我使用Clang从C++源代码构建AST,并使用RecursiveASTVisitor遍历树。我想在记录的访问声明中决定它是类、结构还是union。我有一个覆盖函数VisitCXXRecordDecl(clang::CXXRecordDecl)。在这个函数中我可以checkanyinformationaboutCXXRecordDecl该类(class)提供的信息,但我不知道如何获取这些信息。谁能帮帮我? 最佳答案 只需使用isStruct,isClass,和isUn​​ion成员函数,或者调用getTagKind得到一个TagKi