简体   繁体   English

__clang_analyzer__的重要性

[英]importance of __clang_analyzer__

What is the importance of clang_analyzer as without using this I see analyzer shouting a leak on the below piece of code. clang_analyzer的重要性是什么,因为我没有使用它,我看到分析器在下面的代码中喊出泄漏。

#ifndef __clang_analyzer__
CGPathRef pathWithRoundRect(CGRect iRect, CGFloat iRadius) {
    CGMutablePathRef returnVal = CGPathCreateMutable();
    CGPathMoveToPoint();
    CGPathAddArcToPoint();
    CGPathAddArcToPoint();
    CGPathAddArcToPoint();
    CGPathAddArcToPoint();
    CGPathCloseSubpath(returnVal);
    return returnVal;
}
#endif

__clang_analyzer__ is a macro, defined when the program is compiled for the analyzer (see the Clang User's Manual ). __clang_analyzer__是一个宏,在为分析器编译程序时定义(参见Clang用户手册 )。

When it's defined, the code between #ifndef and #endif isn't being compiled, which means that the analyzer doesn't see it and can't tell you about the owned CGMutablePath that you're returning from a function whose name doesn't indicate it returns an owning reference. 当它被定义时, #ifndef#endif之间的代码没有被编译,这意味着分析器没有看到它,也无法告诉你从一个名称不是的函数返回的所拥有的CGMutablePath 。 t表示它返回一个拥有的引用。

You should consider adding create to the beginning of the function name. 您应该考虑将create添加到函数名的开头。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM