草庐IT

clang_complete

全部标签

c++ - 有没有办法用 clang 在 VisitCallExpr 方法中获取 CallExpr* 的调用者?

方法getDirectCallee()可以得到调用表达式的被调用者(称为方法/函数),但是有没有办法得到调用者(调用它的方法/函数)VisitCallExpr()方法中的CallExpr*?有没有其他方法可以知道一个调用表达式的调用者? 最佳答案 处理这个问题的更好方法是使用AST匹配器。您基本上可以在AST匹配器中查找所有callExpr节点并绑定(bind)它们,同时绑定(bind)相应的调用方(CXXRecordDecl)节点以及不同的字符串。例如:CallBackFunccallBackFunc;Matchers.addMa

c++ - 我怎样才能告诉 clang-format 遵循这个约定?

我想要这个:if(!enabled){return;}转向这个:if(!enabled){return;}(换句话说,我想在一行中使用简短的if语句,但在它们周围保留{})目前我正在使用以下配置:AllowShortIfStatementsOnASingleLine:trueAllowShortLoopsOnASingleLine:trueAllowShortCaseLabelsOnASingleLine:trueAllowShortFunctionsOnASingleLine:trueAllowShortBlocksOnASingleLine:trueBreakBeforeBrace

c++ - 函数模板修改用顶级 const 声明的参数 : clang bug?

下面的代码可以在ArchLinux上的clang3.8.1-1上正确编译。这是clang错误吗?gcc对此发出正确的警告/错误。templatestructBugReproducer{usingsize_type=typenameT::size_type;intbug1(size_typecount);intbug2(size_typecount)const;staticintbug3(size_typecount);};templateintBugReproducer::bug1(size_typeconstcount){//thisisabug.mustbenotallowedco

c++ - 为什么 std::boolalpha 在使用 clang 时忽略字段宽度?

以下代码使用g++7编译器和Appleclang++给出了不同的结果。当使用std::boolalpha时,我是否在bool输出的对齐中遇到了clang中的错误,或者我是否犯了错误?#include#include#include#includetemplatevoidprint_item(std::stringname,T&item){std::ostringstreamss;ss区别在于://outputfromg++version7.2i=34(blabla)s=Hello!(blabla)d=2(blabla)b=true(blabla)//outputfromApplecla

c++ - 具有未使用的引用参数的 constexpr 函数——gcc vs clang

考虑以下代码:templatevoidf(T){}templateconstexprintk(T&){return0;}intmain(){constexprautoi=1;f([&i]{f(0);});}clang++(trunk)编译它。g++(trunk)失败并出现以下错误::Inlambdafunction::11:19:error:nomatchingfunctionforcallto'f((*&i))>(int)'11|f(0);|^:1:35:note:candidate:'templatevoidf(T)'1|templatevoidf(T){}|^:1:35:note

c++ - clang 3.5 constexpr 不一致 - 使用 double 而不是 int 时出错

回答后usingboostmathconstantsinconstexpr并建议OP对constexpr变量使用boost的模板化函数而不是非模板化常量来平息clang错误,我决定尝试看看什么条件会重现clang中的错误。让我们尝试复制boost的宏扩展到的内容:namespacedouble_constants{staticconstdoublename=25;}staticconstexprdoubleSEC3=double_constants::name;这会产生以下错误(按照Coliru进行)clang++-std=c++1y-O2-Wall-pedantic-pthreadm

c++ - Clang -Wweak-vtables 和纯抽象类

关于之前关于此主题的问题:这是对我最近提出的问题的跟进:clang:noout-of-linevirtualmethoddefinitions(pureabstractC++class)并且被标记为这个问题的重复项:Whatisthemeaningofclang's-Wweak-vtables?.我认为这并没有回答我的问题,所以在这里我将重点放在令我困惑且尚未得到解答的事情上。我的场景:我正在尝试使用Clang-3.5编译以下简单的C++代码:测试.h:classA{public:A();virtual~A()=0;};测试.cc#include"test.h"A::A(){;}A::

c++ - 这段编译良好的荒谬代码是 Clang 和 GCC 中的错误吗?

这个问题在这里已经有了答案:Injectedclassnamecompilerdiscrepancy(3个答案)关闭6年前。我今天在研究模板,看看能否让编译器从其内部类之一推断出外部类的类型。我没有找到我的解决方案(我怀疑这是不可能的),但是在尝试修复错误时我遇到了非常奇怪的行为,我将其简化为以下代码片段。structA{structB{};templatestructEverythingIsFine{usingOuter=T;usingInner=typenameT::B::B::B::B::B::B;};usingItWillBeOkay=EverythingIsFine;//Pr

c++ - clang 无法在模板实例化时生成默认的移动构造函数

下面的代码(我无法制作更短的MVCE)unit.h:#includetemplatestructfoo{std::vectordata;foo(foo&&)=default;//noassemblygeneratedfoo(std::vector&&v):data(std::move(v)){}};externtemplatestructfoo;//indicatestemplateinstantiationelsewhereunit.cc:#include"unit.h"templatestructfoo;//forcestemplateintantiationma​​in.cc:#

c++ - clang 中 regex_constants 的错误实现?

如standard中所述:match_prev_avail:--first是一个有效的迭代器位置。设置后,会导致match_not_bol和match_not_bow被忽略但我运行以下代码并得到:#include#includeusingnamespacestd;intmain(){regexre0("^bcd");stringstr="abcd";std::string::iteratorstart=str.begin()+1;cout输出:010match_prev_avail似乎被match_not_bol覆盖了。 最佳答案