summaryrefslogtreecommitdiffstats
path: root/clang/lib/StaticAnalyzer
Commit message (Collapse)AuthorAgeFilesLines
...
* [analyzer] Improve localizability checks for iOS / OS X.Devin Coughlin2015-09-232-97/+707
| | | | | | | | | | | | | | | | | | | | Various improvements to the localization checker: * Adjusted copy to be consistent with diagnostic text in other Apple API checkers. * Added in ~150 UIKit / AppKit methods that require localized strings in UnlocalizedStringsChecker. * UnlocalizedStringChecker now checks for UI methods up the class hierarchy and UI methods that conform for a certain Objective-C protocol. * Added in alpha version of PluralMisuseChecker and some regression tests. False positives are still not ideal. (This is the second attempt, with the memory issues on Linux resolved.) A patch by Kulpreet Chilana! Differential Revision: http://reviews.llvm.org/D12417 llvm-svn: 248432
* Revert "[analyzer] Improve localizability checks for iOS / OS X."Devin Coughlin2015-09-232-707/+97
| | | | | | This reverts commit r248350. The pluralization checks are failing on some bots. llvm-svn: 248351
* [analyzer] Improve localizability checks for iOS / OS X.Devin Coughlin2015-09-222-97/+707
| | | | | | | | | | | | | | | | | | Various improvements to the localization checker: * Adjusted copy to be consistent with diagnostic text in other Apple API checkers. * Added in ~150 UIKit / AppKit methods that require localized strings in UnlocalizedStringsChecker. * UnlocalizedStringChecker now checks for UI methods up the class hierarchy and UI methods that conform for a certain Objective-C protocol. * Added in alpha version of PluralMisuseChecker and some regression tests. False positives are still not ideal. A patch by Kulpreet Chilana! Differential Revision: http://reviews.llvm.org/D12417 llvm-svn: 248350
* [analyzer] Make realloc(ptr, 0) handling equivalent to malloc(0).Devin Coughlin2015-09-221-13/+25
| | | | | | | | | | | | | | | | | | Currently realloc(ptr, 0) is treated as free() which seems to be not correct. C standard (N1570) establishes equivalent behavior for malloc(0) and realloc(ptr, 0): "7.22.3 Memory management functions calloc, malloc, realloc: If the size of the space requested is zero, the behavior is implementation-defined: either a null pointer is returned, or the behavior is as if the size were some nonzero value, except that the returned pointer shall not be used to access an object." The patch equalizes the processing of malloc(0) and realloc(ptr,0). The patch also enables unix.Malloc checker to detect references to zero-allocated memory returned by realloc(ptr,0) ("Use of zero-allocated memory" warning). A patch by Антон Ярцев! Differential Revision: http://reviews.llvm.org/D9040 llvm-svn: 248336
* [analyzer] Create one state for a range switch case instead of multiple.Devin Coughlin2015-09-224-75/+248
| | | | | | | | | | | | | This fixes PR16833, in which the analyzer was using large amounts of memory for switch statements with large case ranges. rdar://problem/14685772 A patch by Aleksei Sidorin! Differential Revision: http://reviews.llvm.org/D5102 llvm-svn: 248318
* Analyzer: Teach analyzer how to handle TypeTraitExprIsmail Pazarbasi2015-09-223-2/+8
| | | | | | | | | | | | | | | | | | | | Summary: `TypeTraitExpr`s are not supported by the ExprEngine today. Analyzer creates a sink, and aborts the block. Therefore, certain bugs that involve type traits intrinsics cannot be detected (see PR24710). This patch creates boolean `SVal`s for `TypeTraitExpr`s, which are evaluated by the compiler. Test within the patch is a summary of PR24710. Reviewers: zaks.anna, dcoughlin, krememek Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D12482 llvm-svn: 248314
* [Static Analyzer] Fixed a false positive case in DynamicTypeChecker when ↵Gabor Horvath2015-09-181-0/+11
| | | | | | dealing with forward declarations. llvm-svn: 248065
* Analyzer: Fix a crasher in UbigraphVizIsmail Pazarbasi2015-09-181-2/+3
| | | | | | | | | | | | | | | Summary: Name `Out` refers to the parameter. It is moved into the member `Out` in ctor-init. Dereferencing null pointer will crash clang, if user passes '-analyzer-viz-egraph-ubigraph' argument. Reviewers: zaks.anna, krememek Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D12119 llvm-svn: 248050
* [Static Analyzer] General type checker based on dynamic type information.Gabor Horvath2015-09-184-52/+207
| | | | | | Differential Revision: http://reviews.llvm.org/D12973 llvm-svn: 248041
* [analyzer] A fix for substraction of an integer from a pointer.Gabor Horvath2015-09-181-1/+2
| | | | | | | | Patch by Artem Dergachev! Differential Revision: http://reviews.llvm.org/D12725 llvm-svn: 248021
* [Static Analyzer] Use generics related information to infer dynamic types.Gabor Horvath2015-09-181-13/+31
| | | | | | Differential Revision: http://reviews.llvm.org/D12916 llvm-svn: 248002
* [Static Analyzer] Generics Checker: When an ObjC method returns a ↵Gabor Horvath2015-09-161-76/+136
| | | | | | | | specialized object, track it properly. Differential Revision: http://reviews.llvm.org/D12889 llvm-svn: 247861
* [analyzer] Add generateErrorNode() APIs to CheckerContext.Devin Coughlin2015-09-1643-102/+126
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The analyzer trims unnecessary nodes from the exploded graph before reporting path diagnostics. However, in some cases it can trim all nodes (including the error node), leading to an assertion failure (see https://llvm.org/bugs/show_bug.cgi?id=24184). This commit addresses the issue by adding two new APIs to CheckerContext to explicitly create error nodes. Unless the client provides a custom tag, these APIs tag the node with the checker's tag -- preventing it from being trimmed. The generateErrorNode() method creates a sink error node, while generateNonFatalErrorNode() creates an error node for a path that should continue being explored. The intent is that one of these two methods should be used whenever a checker creates an error node. This commit updates the checkers to use these APIs. These APIs (unlike addTransition() and generateSink()) do not take an explicit Pred node. This is because there are not any error nodes in the checkers that were created with an explicit different than the default (the CheckerContext's Pred node). It also changes generateSink() to require state and pred nodes (previously these were optional) to reduce confusion. Additionally, there were several cases where checkers did check whether a generated node could be null; we now explicitly check for null in these places. This commit also includes a test case written by Ying Yi as part of http://reviews.llvm.org/D12163 (that patch originally addressed this issue but was reverted because it introduced false positive regressions). Differential Revision: http://reviews.llvm.org/D12780 llvm-svn: 247859
* Silencing a -Wreturn-type warning; NFC.Aaron Ballman2015-09-151-0/+1
| | | | llvm-svn: 247693
* [analyzer] Restore behavior change introduced by r247657.Devin Coughlin2015-09-151-4/+6
| | | | | | | | r247657 fixed warnings about unused variables when compiling without asserts but changed behavior. This commit restores the old behavior but still suppresses the warnings. llvm-svn: 247660
* ExprEngineObjC.cpp: Fix warnings. [-Wunused-variable]NAKAMURA Takumi2015-09-151-4/+4
| | | | llvm-svn: 247657
* [analyzer] Skip Pre/Post handlers for ObjC calls when receiver is nil.Devin Coughlin2015-09-154-47/+129
| | | | | | | | | | | | | | | | | | | | | | | | | In Objective-C, method calls with nil receivers are essentially no-ops. They do not fault (although the returned value may be garbage depending on the declared return type and architecture). Programmers are aware of this behavior and will complain about a false alarm when the analyzer diagnoses API violations for method calls when the receiver is known to be nil. Rather than require each individual checker to be aware of this behavior and suppress a warning when the receiver is nil, this commit changes ExprEngineObjC so that VisitObjCMessage skips calling checker pre/post handlers when the receiver is definitely nil. Instead, it adds a new event, ObjCMessageNil, that is only called in that case. The CallAndMessageChecker explicitly cares about this case, so I've changed it to add a callback for ObjCMessageNil and moved the logic in PreObjCMessage that handles nil receivers to the new callback. rdar://problem/18092611 Differential Revision: http://reviews.llvm.org/D12123 llvm-svn: 247653
* [Static Analyzer] Nullability checker optimization.Gabor Horvath2015-09-141-1/+6
| | | | | | Differential Revision: http://reviews.llvm.org/D12848 llvm-svn: 247612
* [Static Analyzer] Relaxing a caching out related assert.Gabor Horvath2015-09-141-1/+4
| | | | | | Differential Revision: http://reviews.llvm.org/D12818 llvm-svn: 247598
* [Static Analyzer] Moving nullability checkers out of alpha.Gabor Horvath2015-09-141-2/+2
| | | | llvm-svn: 247595
* [Static Analyzer] Moving nullability checkers to a top level package.Gabor Horvath2015-09-142-12/+29
| | | | | | Differential Revision: http://reviews.llvm.org/D12852 llvm-svn: 247590
* [Static Analyzer] Remove a redundant file.Gabor Horvath2015-09-131-623/+0
| | | | llvm-svn: 247533
* [Static Analyzer] Merge the Objective-C Generics Checker into Dynamic Type ↵Gabor Horvath2015-09-133-20/+635
| | | | | | | | Propagation checker. Differential Revision: http://reviews.llvm.org/D12381 llvm-svn: 247532
* [Static Analyzer] Properly cash the configuration option for lambda support. Gabor Horvath2015-09-111-1/+3
| | | | llvm-svn: 247476
* [analyzer] Add -analyzer-config option for function size the inliner ↵Devin Coughlin2015-09-112-1/+9
| | | | | | | | | | | | | | | | | | | considers as large Add an option (-analyzer-config min-blocks-for-inline-large=14) to control the function size the inliner considers as large, in relation to "max-times-inline-large". The option defaults to the original hard coded behaviour, which I believe should be adjustable with the other inlining settings. The analyzer-config test has been modified so that the analyzer will reach the getMinBlocksForInlineLarge() method and store the result in the ConfigTable, to ensure it is dumped by the debug checker. A patch by Sean Eveson! Differential Revision: http://reviews.llvm.org/D12406 llvm-svn: 247463
* [Static Analyzer] Fixed a typo in a diagnostic message.Gabor Horvath2015-09-111-1/+1
| | | | llvm-svn: 247444
* [Static Analyzer] Properly clean up the dynamic type information for dead ↵Gabor Horvath2015-09-115-43/+80
| | | | | | | | regions. Differential Revision: http://reviews.llvm.org/D12767 llvm-svn: 247430
* [Static Analyzer] Lambda support.Gabor Horvath2015-09-114-5/+92
| | | | | | Differential Revision: http://reviews.llvm.org/D12652 llvm-svn: 247426
* [Static Analyzer] Minor cleanups for the nullability checker.Gabor Horvath2015-09-111-46/+40
| | | | | | Differential Revision: http://reviews.llvm.org/D12619 llvm-svn: 247423
* [Static Analyzer] Objective-C Generics Checker improvements.Gabor Horvath2015-09-082-150/+204
| | | | | | Differential Revision: http://reviews.llvm.org/D12701 llvm-svn: 247071
* [analyzer] Apply whitespace cleanups by Honggyu Kim.Ted Kremenek2015-09-0878-823/+823
| | | | llvm-svn: 246978
* [Static Analyzer] Remove sinks from nullability checks.Gabor Horvath2015-09-031-26/+146
| | | | | | Differential Revision: http://reviews.llvm.org/D12445 llvm-svn: 246818
* add __builtin_unpredictable and convert to metadataSanjay Patel2015-09-021-2/+3
| | | | | | | | | | | | | | | | | | | | | | | This patch depends on r246688 (D12341). The goal is to make LLVM generate different code for these functions for a target that has cheap branches (see PR23827 for more details): int foo(); int normal(int x, int y, int z) { if (x != 0 && y != 0) return foo(); return 1; } int crazy(int x, int y) { if (__builtin_unpredictable(x != 0 && y != 0)) return foo(); return 1; } Differential Revision: http://reviews.llvm.org/D12458 llvm-svn: 246699
* Revert r246345 until an assertion is fixed.Gabor Horvath2015-08-312-166/+9
| | | | llvm-svn: 246479
* [analyzer] When memcpy'ing into a fixed-size array, do not invalidate entire ↵Devin Coughlin2015-08-282-9/+166
| | | | | | | | | | | | | | | | | | region. Change the analyzer's modeling of memcpy to be more precise when copying into fixed-size array fields. With this change, instead of invalidating the entire containing region the analyzer now invalidates only offsets for the array itself when it can show that the memcpy stays within the bounds of the array. This addresses false positive memory leak warnings of the kind reported by krzysztof in https://llvm.org/bugs/show_bug.cgi?id=22954 A patch by Pierre Gousseau! Differential Revision: http://reviews.llvm.org/D11832 llvm-svn: 246345
* [Static Analyzer] Make NonNullParamChecker emit implicit null dereference ↵Gabor Horvath2015-08-273-21/+34
| | | | | | | | events. Differential Revision: http://reviews.llvm.org/D11433 llvm-svn: 246182
* [Static Analyzer] Checks to catch nullability related issues.Gabor Horvath2015-08-263-0/+864
| | | | | | Differential Revision: http://reviews.llvm.org/D11468 llvm-svn: 246105
* Add missing newline.Ted Kremenek2015-08-261-1/+1
| | | | llvm-svn: 246003
* [Static Analyzer] Fixed a typo in a diagnostic message.Gabor Horvath2015-08-251-1/+1
| | | | llvm-svn: 245949
* [OPENMP 4.0] Initial support for array sections.Alexey Bataev2015-08-253-1/+12
| | | | | | | | Adds parsing/sema analysis/serialization/deserialization for array sections in OpenMP constructs (introduced in OpenMP 4.0). Currently it is allowed to use array sections only in OpenMP clauses that accepts list of expressions. Differential Revision: http://reviews.llvm.org/D10732 llvm-svn: 245937
* [Static Analyzer] Add checker to catch lightweight generics related type ↵Gabor Horvath2015-08-213-0/+574
| | | | | | | | errors in Objective-C. Differential Revision: http://reviews.llvm.org/D11427 llvm-svn: 245646
* Do not crash when static analysis encounters a FunctionDecl that has a ↵Aaron Ballman2015-08-201-2/+2
| | | | | | delayed template parse of its body. llvm-svn: 245616
* clangStaticAnalyzerCheckers: Update libdesp.NAKAMURA Takumi2015-08-151-0/+1
| | | | llvm-svn: 245145
* [analyzer] Add checkers for OS X / iOS localizability issuesAnna Zaks2015-08-143-0/+604
| | | | | | | | | | | | | | | Add checkers that detect code-level localizability issues for OS X / iOS: - A path sensitive checker that warns about uses of non-localized NSStrings passed to UI methods expecting localized strings. - A syntax checker that warns against not including a comment in NSLocalizedString macros. A patch by Kulpreet Chilana! (This is the second attempt with the compilation issue on Windows and the random test failures resolved.) llvm-svn: 245093
* Wdeprecated: Make the SecKeychainBugVisitor copyable (for the clone support ↵David Blaikie2015-08-131-1/+0
| | | | | | | | | in the CRTP base) my removing the user-declared dtor The implicit dtor is just as good, and avoid suppressing implicit copy/move ops. llvm-svn: 244981
* Wdeprecated: BugReporterVisitors are copied for cloning ↵David Blaikie2015-08-131-3/+2
| | | | | | | | | | (BugReporterVisitorImpl), make sure such copies are safe Make the copy/move ctors defaulted in the base class and make the derived classes final to avoid any intermediate hierarchy slicing if these types were further derived. llvm-svn: 244979
* Wdeprecated: CollectReachableSymbolsCallback are move constructed/returned ↵David Blaikie2015-08-136-7/+5
| | | | | | | | | | | | | | by value, so make sure they're copy/moveable (return by value is in ExprEngine::processPointerEscapedOnBind and any other call to the scanReachableSymbols function template used there) Protect the special members in the base class to avoid slicing, and make derived classes final so these special members don't accidentally become public on an intermediate base which would open up the possibility of slicing again. llvm-svn: 244975
* Wdeprecated: RegionBindingsRef are copy constructed, make sure that's safe ↵David Blaikie2015-08-131-21/+15
| | | | | | | | | | | | by removing the unnecessary user-declared copy assignment operator The user-defined copy assignment looks like it was working around the presence of a reference member (that probably doesn't change in the copy assignment cases present in the program). Rather than continuing this - just change the reference to a pointer and let all the special members be defined implicitly. llvm-svn: 244974
* Wdeprecated: PathPieces are copied, make them safely implicitly copyable by ↵David Blaikie2015-08-131-2/+0
| | | | | | removing the unnecessary user declared dtor. llvm-svn: 244973
* Remove and forbid raw_svector_ostream::flush() calls.Yaron Keren2015-08-132-2/+0
| | | | | | | | | | After r244870 flush() will only compare two null pointers and return, doing nothing but wasting run time. The call is not required any more as the stream and its SmallString are always in sync. Thanks to David Blaikie for reviewing. llvm-svn: 244928
OpenPOWER on IntegriCloud