xcode – 命令行工具的静态分析器问题

xcode – 命令行工具的静态分析器问题,第1张

概述我们通过使用TeamCity /命令行工具自动化我们当前项目的构建.为了确保尽可能多地捕获潜在的问题,我们已经将项目设置为对每个构建使用静态分析器. 几个第三方课程被分析仪标记,所以我们排除了可疑类,标记为: -w -Xanalyzer -analyzer-disable-checker 一切都按照预期的方式编译在Xcode中(用4.6.3和5.0.1测试). 但是,当在TeamCity服务器上编 我们通过使用TeamCity /命令行工具自动化我们当前项目的构建.为了确保尽可能多地捕获潜在的问题,我们已经将项目设置为对每个构建使用静态分析器.
几个第三方课程被分析仪标记,所以我们排除了可疑类,标记为:
-w -Xanalyzer -analyzer-disable-checker

一切都按照预期的方式编译在Xcode中(用4.6.3和5.0.1测试).

但是,当在TeamCity服务器上编译时,我们会收到每个排除的第三方文件的以下错误:

__PIC__ level differs in PCH file vs. current fileerror: __PIC__ level differs in PCH file vs. current file2 errors generated.

如果我们删除了-Xanalyzer -analyzer-disable-checker标签(但是在这种情况下,我们得到了分析器的警告),错误消失了.

如果我们使用AppCode进行编译,则会发生同样的错误,这使得我认为这与AppCode和使用它们来编译构建的TeamCity服务器的命令行工具无关.

TeamCity服务器使用Xcode 4的命令行工具,我已经尝试过AppCode和Xcode 4和5.

当使用Xcode 5的命令行工具尝试使用AppCode时,错误略有不同(每个排除的类再次出现一个):

error reading 'pic'no analyzer checkers are associated with '-mrelocation-model'

所以,问题是:有没有人有任何想法如何摆脱这个错误,当使用命令行工具(如果命令行工具在这里确实有错误)抑制特定类的分析器警告?

解决方法 我刚刚遇到这个问题,并认为它是一个与Clang的错误.我想我找到了一个解决方法.

尝试替换这个

-w -Xanalyzer -analyzer-disable-checker

用这个可笑的长线(继续向右滚动看全部):

-w -Xanalyzer -analyzer-disable-checker -Xanalyzer Alpha -Xanalyzer -analyzer-disable-checker -Xanalyzer core -Xanalyzer -analyzer-disable-checker -Xanalyzer cplusplus -Xanalyzer -analyzer-disable-checker -Xanalyzer deadcode -Xanalyzer -analyzer-disable-checker -Xanalyzer deBUG -Xanalyzer -analyzer-disable-checker -Xanalyzer llvm -Xanalyzer -analyzer-disable-checker -Xanalyzer osx -Xanalyzer -analyzer-disable-checker -Xanalyzer security -Xanalyzer -analyzer-disable-checker -Xanalyzer unix -Xanalyzer -analyzer-disable-checker -Xanalyzer insecureAPI

好的,所以这是我怎么做到的.看起来Clang具有“静态分析器检查器”的层次结构,您可以单独或通过组禁用它们.

作为一个例子,DeadStore检查器是“deadcode.DeadStores”,所以你可以禁用它:

-Xanalyzer -analyzer-disable-checker -Xanalyzer deadcode.DeadStores

或者,您可以通过仅指定“deadcode”来禁用所有与死码相关的检查器:

-Xanalyzer -analyzer-disable-checker -Xanalyzer deadcode

您可以使用此命令获取所有检查程序的列表:

clang -cc1 -analyzer-checker-help

它目前输出以下内容:

OVERVIEW: Clang Static Analyzer Checkers ListUSAGE: -analyzer-checker <CHECKER or PACKAGE,...>CHECKERS:  Alpha.core.BoolAssignment       Warn about assigning non-{0,1} values to Boolean variables  Alpha.core.CastSize             Check when casting a malloc'ed type T,whether the size is a multiple of the size of T  Alpha.core.CastToStruct         Check for cast from non-struct pointer to struct pointer  Alpha.core.FixedAddr            Check for assignment of a fixed address to a pointer  Alpha.core.Pointerarithm        Check for pointer arithmetic on locations other than array elements  Alpha.core.PointerSub           Check for pointer subtractions on two pointers pointing to different memory chunks  Alpha.core.SizeofPtr            Warn about unintended use of sizeof() on pointer Expressions  Alpha.cplusplus.NewDeleteLeaks  Check for memory leaks. Traces memory managed by new/delete.  Alpha.cplusplus.VirtualCall     Check virtual function calls during construction or destruction  Alpha.deadcode.IDempotentoperations                                  Warn about IDempotent operations  Alpha.deadcode.UnreachableCode  Check unreachable code  Alpha.osx.cocoa.Dealloc         Warn about Objective-C classes that lack a correct implementation of -dealloc  Alpha.osx.cocoa.DirectIvarassignment                                  Check for direct assignments to instance variables  Alpha.osx.cocoa.DirectIvarassignmentForAnnotatedFunctions                                  Check for direct assignments to instance variables in the methods annotated with objc_no_direct_instance_variable_assignment  Alpha.osx.cocoa.InstanceVariableInvalIDation                                  Check that the invalIDatable instance variables are invalIDated in the methods annotated with objc_instance_variable_invalIDator  Alpha.osx.cocoa.MissingInvalIDationMethod                                  Check that the invalIDation methods are present in classes that contain invalIDatable instance variables  Alpha.osx.cocoa.MissingSuperCall                                  Warn about Objective-C methods that lack a necessary call to super  Alpha.security.ArrayBound       Warn about buffer overflows (older checker)  Alpha.security.ArrayBoundV2     Warn about buffer overflows (newer checker)  Alpha.security.MallocOverflow   Check for overflows in the arguments to malloc()  Alpha.security.ReturnPtrRange   Check for an out-of-bound pointer being returned to callers  Alpha.security.taint.TaintPropagation                                  Generate taint information used by other checkers  Alpha.unix.Chroot               Check improper use of chroot  Alpha.unix.MallocWithAnnotations                                  Check for memory leaks,double free,and use-after-free problems. Traces memory managed by malloc()/free(). Assumes that all user-defined functions which might free a pointer are annotated.  Alpha.unix.PthreadLock          Simple lock -> unlock checker  Alpha.unix.SimpleStream         Check for misuses of stream APIs  Alpha.unix.Stream               Check stream handling functions  Alpha.unix.cstring.BufferOverlap                                  Checks for overlap in two buffer arguments  Alpha.unix.cstring.NotNullTerminated                                  Check for arguments which are not null-terminating strings  Alpha.unix.cstring.OutOfBounds  Check for out-of-bounds access in string functions  core.CallAndMessage             Check for logical errors for function calls and Objective-C message Expressions (e.g.,uninitialized arguments,null function pointers)  core.divIDeZero                 Check for division by zero  core.DynamicTypePropagation     Generate dynamic type information  core.NonNullParamChecker        Check for null pointers passed as arguments to a function whose arguments are references or marked with the 'nonnull' attribute  core.NullDereference            Check for dereferences of null pointers  core.StackAddressEscape         Check that addresses to stack memory do not escape the function  core.Un@R_502_5552@dBinaryOperatorResult                                  Check for un@R_502_5552@d results of binary operators  core.VLASize                    Check for declarations of VLA of un@R_502_5552@d or zero size  core.builtin.BuiltinFunctions   Evaluate compiler builtin functions (e.g.,alloca())  core.builtin.noreturnFunctions  Evaluate "panic" functions that are kNown to not return to the caller  core.uninitialized.ArraySubscript                                  Check for uninitialized values used as array subscripts  core.uninitialized.Assign       Check for assigning uninitialized values  core.uninitialized.Branch       Check for uninitialized values used as branch conditions  core.uninitialized.CapturedBlockVariable                                  Check for blocks that capture uninitialized values  core.uninitialized.UndefReturn  Check for uninitialized values being returned to the caller  cplusplus.NewDelete             Check for double-free and use-after-free problems. Traces memory managed by new/delete.  deadcode.DeadStores             Check for values stored to variables that are never read afterwards  deBUG.ConfigDumper              Dump config table  deBUG.DumpCFG                   display Control-Flow Graphs  deBUG.DumpCallGraph             display Call Graph  deBUG.DumpCalls                 Print calls as they are traversed by the engine  deBUG.DumpDominators            Print the dominance tree for a given CFG  deBUG.DumpliveVars              Print results of live variable analysis  deBUG.DumpTraversal             Print branch conditions as they are traversed by the engine  deBUG.Exprinspection            Check the analyzer's understanding of Expressions  deBUG.Stats                     Emit warnings with analyzer statistics  deBUG.TaintTest                 Mark tainted symbols as such.  deBUG.VIEwCFG                   VIEw Control-Flow Graphs using GraphViz  deBUG.VIEwCallGraph             VIEw Call Graph using GraphViz  llvm.Conventions                Check code for LLVM codebase conventions  osx.API                         Check for proper uses of varIoUs Apple APIs  osx.SecKeychainAPI              Check for proper uses of Secure Keychain APIs  osx.cocoa.AtSync                Check for nil pointers used as mutexes for @synchronized  osx.cocoa.ClassRelease          Check for sending 'retain','release',or 'autorelease' directly to a Class  osx.cocoa.IncompatibleMethodTypes                                  Warn about Objective-C method signatures with type incompatibilitIEs  osx.cocoa.Loops                 Improved modeling of loops using Cocoa collection types  osx.cocoa.NSautoreleasePool     Warn for suboptimal uses of NSautoreleasePool in Objective-C GC mode  osx.cocoa.NSError               Check usage of NSError** parameters  osx.cocoa.NilArg                Check for prohibited nil arguments to ObjC method calls  osx.cocoa.NonNilReturnValue     Model the APIs that are guaranteed to return a non-nil value  osx.cocoa.RetainCount           Check for leaks and improper reference count management  osx.cocoa.SelfInit              Check that 'self' is properly initialized insIDe an initializer method  osx.cocoa.Unusedivars           Warn about private ivars that are never used  osx.cocoa.VariadicmethodTypes   Check for passing non-Objective-C types to variadic collection initialization methods that expect only Objective-C types  osx.coreFoundation.CFError      Check usage of CFErrorRef* parameters  osx.coreFoundation.CFNumber     Check for proper uses of CFNumberCreate  osx.coreFoundation.CFRetainRelease                                  Check for null arguments to CFRetain/CFRelease/CFMakeCollectable  osx.coreFoundation.containers.OutOfBounds                                  Checks for index out-of-bounds when using 'CFArray' API  osx.coreFoundation.containers.PointerSizedValues                                  Warns if 'CFArray','CFDictionary','CFSet' are created with non-pointer-size values  security.floatLoopCounter       Warn on using a floating point value as a loop counter (CERT: FLP30-C,FLP30-CPP)  security.insecureAPI.UncheckedReturn                                  Warn on uses of functions whose return values must be always checked  security.insecureAPI.getpw      Warn on uses of the 'getpw' function  security.insecureAPI.gets       Warn on uses of the 'gets' function  security.insecureAPI.mkstemp    Warn when 'mkstemp' is passed fewer than 6 X's in the format string  security.insecureAPI.mktemp     Warn on uses of the 'mktemp' function  security.insecureAPI.rand       Warn on uses of the 'rand','random',and related functions  security.insecureAPI.strcpy     Warn on uses of the 'strcpy' and 'strcat' functions  security.insecureAPI.vfork      Warn on uses of the 'vfork' function  unix.API                        Check calls to varIoUs UNIX/Posix functions  unix.Malloc                     Check for memory leaks,and use-after-free problems. Traces memory managed by malloc()/free().  unix.MallocSizeof               Check for dubIoUs malloc arguments involving sizeof  unix.MismatchedDeallocator      Check for mismatched deallocators.  unix.cstring.BadSizeArg         Check the size argument passed into C string functions for common erroneous patterns  unix.cstring.NullArg            Check for null pointers being passed as arguments to C string functions

我上面提供的长命令行禁用了所有9个顶级跳棋:
Alpha,core,cplusplus,deadcode,deBUG,llvm,osx,security和unix PLUS“insecureAPI”基于以下意见,因为它似乎禁用安全性也不会禁用security.insecureAPI.

希望这相当于不运行分析仪.

有关更多信息,请参阅此处的Checker开发者手册:http://clang-analyzer.llvm.org/checker_dev_manual.html

总结

以上是内存溢出为你收集整理的xcode – 命令行工具的静态分析器问题全部内容,希望文章能够帮你解决xcode – 命令行工具的静态分析器问题所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1098137.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-28
下一篇 2022-05-28

发表评论

登录后才能评论

评论列表(0条)

保存