clang-static-analyzer

Is it possible to suppress Xcode 4 static analyzer warnings?

拜拜、爱过 提交于 2019-11-27 17:49:59
The Xcode 4 static analyzer reports in my code some false positives. Is there any way to suppress them? I found a solution: false positives (like the Apple singleton design pattern) can be avoided with: #ifndef __clang_analyzer__ // Code not to be analyzed #endif Analyzer will not analyze the code between those preprocessor directives. Take a look at this page which shows how to use several #defines to annotate objective-c methods and parameters to help the static analyzer (clang) do the right thing http://clang-analyzer.llvm.org/annotations.html From that page: The Clang frontend supports

Deep copy of dictionaries gives Analyze error in Xcode 4.2

馋奶兔 提交于 2019-11-26 20:57:13
I have the following method in a NSDictionary category, to do a deep copy, which works fine. I just upgraded from Xcode 4.1 to 4.2, and the Analyze function gives two analyzer warnings for this code, as indicated: - (id)deepCopy; { id dict = [[NSMutableDictionary alloc] init]; id copy; for (id key in self) { id object = [self objectForKey:key]; if ([object respondsToSelector:@selector(deepCopy)]) copy = [object deepCopy]; else copy = [object copy]; [dict setObject:copy forKey:key]; // Both -deepCopy and -copy retain the object, and so does -setObject:forKey:, so need to -release: [copy release

Is it possible to suppress Xcode 4 static analyzer warnings?

家住魔仙堡 提交于 2019-11-26 19:14:53
问题 The Xcode 4 static analyzer reports in my code some false positives. Is there any way to suppress them? 回答1: I found a solution: false positives (like the Apple singleton design pattern) can be avoided with: #ifndef __clang_analyzer__ // Code not to be analyzed #endif Analyzer will not analyze the code between those preprocessor directives. 回答2: Take a look at this page which shows how to use several #defines to annotate objective-c methods and parameters to help the static analyzer (clang)

Deep copy of dictionaries gives Analyze error in Xcode 4.2

让人想犯罪 __ 提交于 2019-11-26 07:47:46
问题 I have the following method in a NSDictionary category, to do a deep copy, which works fine. I just upgraded from Xcode 4.1 to 4.2, and the Analyze function gives two analyzer warnings for this code, as indicated: - (id)deepCopy; { id dict = [[NSMutableDictionary alloc] init]; id copy; for (id key in self) { id object = [self objectForKey:key]; if ([object respondsToSelector:@selector(deepCopy)]) copy = [object deepCopy]; else copy = [object copy]; [dict setObject:copy forKey:key]; // Both