summaryrefslogtreecommitdiffstats
path: root/clang/test/Sema/uninit-variables.c
Commit message (Collapse)AuthorAgeFilesLines
* Only warn at self-initialization if some later use is always uninitialized.Matt Beaumont-Gay2011-10-191-1/+9
| | | | llvm-svn: 142538
* Tweak -Wuninitialized's handling of 'int x = x' to report that as the root ↵Ted Kremenek2011-10-131-4/+9
| | | | | | cause of an uninitialized variable IFF there are other uses of that uninitialized variable. Fixes <rdar://problem/9259237>. llvm-svn: 141881
* r141345 also fixed a -Wuninitialized bug where loop conditions were not ↵Ted Kremenek2011-10-071-0/+6
| | | | | | always flagged as being uninitialized. Addresses <rdar://problem/9432305>. llvm-svn: 141346
* Fix infinite loop in -Wuninitialized reported in PR 11069.Ted Kremenek2011-10-071-0/+14
| | | | llvm-svn: 141345
* Show either a location or a fixit note, not both, for uninitialized variable ↵David Blaikie2011-09-101-28/+28
| | | | | | warnings. llvm-svn: 139463
* -Wuninitialized: fix insidious bug resulting from interplay of blocks and ↵Ted Kremenek2011-09-021-0/+10
| | | | | | dead code. Fixes <rdar://problem/10060250>. llvm-svn: 139027
* Fix regression in -Wuninitialized involving VLAs. It turns out that we were ↵Ted Kremenek2011-08-231-0/+9
| | | | | | | | | | | modeling sizeof(VLAs) incorrectly in the CFG, and also the static analyzer. This patch regresses the analyzer a bit, but that needs to be followed up with a better solution. Fixes <rdar://problem/10008112>. llvm-svn: 138372
* Move duplicate uninitialized warning suppression into theChandler Carruth2011-07-221-4/+4
| | | | | | | | | | | | AnalysisBasedWarnings Sema layer and out of the Analysis library itself. This returns the uninitialized values analysis to a more pure form, allowing its original logic to correctly detect some categories of definitely uninitialized values. Fixes PR10358 (again). Thanks to Ted for reviewing and updating this patch after his rewrite of several portions of this analysis. llvm-svn: 135748
* Fix false negative in -Wuninitialized involving a () wrapping an ↵Ted Kremenek2011-07-191-2/+2
| | | | | | lvalue-to-rvalue conversion in a DeclStmt. llvm-svn: 135525
* Fix assertion failure in UninitializedValues.cpp where an lvalue to rvalue ↵Ted Kremenek2011-07-191-0/+5
| | | | | | conversion is wrapped in a parenthesis. llvm-svn: 135519
* Revert r135217, which wasn't the correct fix for PR10358. With thisChandler Carruth2011-07-161-4/+19
| | | | | | | | | | | patch, we actually move the state-machine for the value set backwards one step. This can pretty easily lead to infinite loops where we continually try to propagate a bit, succeed for one iteration, but then back up because we find an uninitialized use. A reduced test case from PR10379 is included. llvm-svn: 135359
* Fix false negative reported in PR 10358 by using 'Unknown' in ↵Ted Kremenek2011-07-141-4/+4
| | | | | | -Wuninitialized to avoid cascading warnings. Patch by Kaelyn Uhrain. llvm-svn: 135217
* Fix crash in -Wuninitialized when using switch statments whose condition is ↵Ted Kremenek2011-05-101-0/+13
| | | | | | a logical operation. llvm-svn: 131158
* Switch 'is possibly uninitialized' to 'may be uninitialized' based onChandler Carruth2011-04-081-12/+12
| | | | | | Chris's feedback. llvm-svn: 129127
* Now that the analyzer is distinguishing between uninitialized uses thatChandler Carruth2011-04-081-14/+14
| | | | | | | definitely have a path leading to them, and possibly have a path leading to them; reflect that distinction in the warning text emitted. llvm-svn: 129126
* Commit a bit of a hack to fully handle the situation where variables areChandler Carruth2011-04-051-2/+4
| | | | | | | | | | | | | | | | marked explicitly as uninitialized through direct self initialization: int x = x; With r128894 we prevented warnings about this code, and this patch teaches the analysis engine to continue analyzing subsequent uses of 'x'. This should wrap up PR9624. There is still an open question of whether we should suppress the maybe-uninitialized warnings resulting from variables initialized in this fashion. The definitely-uninitialized uses should always be warned. llvm-svn: 128932
* Fix PR9624 by explicitly disabling uninitialized warnings for direct self-init:Chandler Carruth2011-04-051-1/+1
| | | | | | | | | | | | | | | int x = x; GCC disables its warnings on this construct as a way of indicating that the programmer intentionally wants the variable to be uninitialized. Only the warning on the initializer is turned off in this iteration. This makes the code a lot more ugly, but starts commenting the surprising behavior here. This is a WIP, I want to refactor it substantially for clarity, and to determine whether subsequent warnings should be suppressed or not. llvm-svn: 128894
* Fix PR 9626 (duplicated self-init warnings under -Wuninitialized) with ↵Ted Kremenek2011-04-041-1/+1
| | | | | | | | | | | | | | numerous CFG and UninitializedValues analysis changes: 1) Change the CFG to include the DeclStmt for conditional variables, instead of using the condition itself as a faux DeclStmt. 2) Update ExprEngine (the static analyzer) to understand (1), so not to regress. 3) Update UninitializedValues.cpp to initialize all tracked variables to Uninitialized at the start of the function/method. 4) Only use the SelfReferenceChecker (SemaDecl.cpp) on global variables, leaving the dataflow analysis to handle other cases. The combination of (1) and (3) allows the dataflow-based -Wuninitialized to find self-init problems when the initializer contained control-flow. llvm-svn: 128858
* -Wuninitialized: use "self-init" warning when issue uninitialized values ↵Ted Kremenek2011-04-041-1/+1
| | | | | | warnings from the dataflow analysis that include within the initializer of a variable. llvm-svn: 128843
* -Wuninitialized: don't issue fixit for initializer if a variable declaration ↵Ted Kremenek2011-04-041-1/+1
| | | | | | already has an initializer. llvm-svn: 128838
* -Wuninitialized should not warn about variables captured by blocks as byref.Ted Kremenek2011-03-311-0/+9
| | | | | | | | | Note this can potentially be enhanced to detect if the __block variable is actually written by the block, or only when the block "escapes" or is actually used, but that requires more analysis than it is probably worth for this simple check. llvm-svn: 128681
* Rename -Wuninitialized-maybe to -Wconditional-uninitialized.Ted Kremenek2011-03-171-1/+1
| | | | llvm-svn: 127793
* Take 2: merge -Wuninitialized-experimental into -Wuninitialized. Only ↵Ted Kremenek2011-03-151-1/+1
| | | | | | *must-be-uninitialized* warnings are reported, with *maybe-uninitialized* under a separate flag. I await any fallout/comments/feedback, although hopefully this will produce no noise for users. llvm-svn: 127670
* Split warnings from -Wuninitialized-experimental into "must-be-initialized" ↵Ted Kremenek2011-03-151-1/+1
| | | | | | and "may-be-initialized" warnings, each controlled by different flags. llvm-svn: 127666
* Remove old UninitializedValues analysis.Ted Kremenek2011-03-151-0/+68
| | | | llvm-svn: 127656
* Move uninitialized variable checking back under ↵Ted Kremenek2011-02-071-1/+1
| | | | | | -Wuninitialized-experimental. It is clear from user feedback that this warning is not quite ready. llvm-svn: 125007
* Reenable -Wuninitialized warning for captured block variables.Ted Kremenek2011-02-031-2/+2
| | | | llvm-svn: 124782
* Based on user feedback, swap -Wuninitialized diagnostics to have the warning ↵Ted Kremenek2011-02-021-39/+39
| | | | | | refer to the bad use, and the note to the variable declaration. llvm-svn: 124758
* Enhance -Wuninitialized to better reason about || and &&, tracking dual ↵Ted Kremenek2011-02-011-0/+20
| | | | | | | | dataflow facts and properly merging them. Fixes PR 9076. llvm-svn: 124666
* Teach -Wuninitialized about indirect goto. Fixes PR 9071.Ted Kremenek2011-01-271-0/+11
| | | | llvm-svn: 124394
* Teach -Wuninitialized not to assert when analyzingTed Kremenek2011-01-271-0/+6
| | | | | | blocks that reference captured variables. llvm-svn: 124348
* Merge -Wuninitialized-experimental into -Wuninitialized.Ted Kremenek2011-01-261-1/+1
| | | | llvm-svn: 124279
* Tweak -Wuninitialized-experimental to not emitTed Kremenek2011-01-261-0/+11
| | | | | | | a warning for uses of an uninitialized variable when the use is a void cast, e.g. (void) x. llvm-svn: 124278
* Teach -Wuninitialized-experimental to also warnTed Kremenek2011-01-251-1/+21
| | | | | | about uninitialized variables captured by blocks. llvm-svn: 124213
* Teach -Wuninitialized-experimental about sizeof().Ted Kremenek2011-01-231-0/+12
| | | | llvm-svn: 124076
* Provide -Wuninitialized-experimental fixitsTed Kremenek2011-01-211-13/+23
| | | | | | | for floats, and also check if 'nil' is declared when suggesting it for initializing ObjC pointers. llvm-svn: 124004
* Add basic fixits for -Wuninitialized-experimentalTed Kremenek2011-01-211-1/+1
| | | | | | | to suggest initializations for pointer and ObjC pointer types. llvm-svn: 123995
* Enhance -Wuninitialized-experimental diagnosticsTed Kremenek2011-01-211-27/+27
| | | | | | | | to issue the warning at an uninitialized variable's declaration, but to issue notes at possible uninitialized uses (which could be multiple). llvm-svn: 123994
* Add rudimentary path-sensitivity to UnintializedValuesV2Ted Kremenek2011-01-201-1/+60
| | | | | | | | | | | | analysis for short-circuited operations. For branch written like "if (x && y)", we maintain two sets of dataflow values for the outgoing branches. This suppresses some common false positives for -Wuninitialized-experimental. This change introduces some assertion failures when running on the LLVM codebase. WIP. llvm-svn: 123923
* Teach UninitializedValuesV2 to implicitly reason about C++Ted Kremenek2011-01-181-0/+9
| | | | | | | | references by monitoring whether an access to a variable is solely to compute it's lvalue or to do an lvalue-to-rvalue conversion (i.e., a load). llvm-svn: 123777
* Correctly enable test/Sema/unit-variables.c,Ted Kremenek2011-01-181-1/+1
| | | | | | | thus identifying a minor logical flaw in UninitializedValuesV2.cpp. llvm-svn: 123734
* Teach UninitializedValuesV2 about "int x = x" andTed Kremenek2011-01-181-0/+16
| | | | | | also properly handle confluence of loops. llvm-svn: 123733
* Add initial prototype for implementation ofTed Kremenek2011-01-151-0/+88
-Wuninitialized based on CFG dataflow analysis. WIP. llvm-svn: 123512
OpenPOWER on IntegriCloud