summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaCXX/uninitialized.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Modify the uninitialized field visitor to detect uninitialized use across theRichard Trieu2013-09-201-2/+109
| | | | | | | | | | | | | | | | | | fields in the class. This allows a better checking of member intiailizers and in class initializers in regards to initialization ordering. For instance, this code will now produce warnings: class A { int x; int y; A() : x(y) {} // y is initialized after x, warn here A(int): y(x) {} // default initialization of leaves x uninitialized, warn here }; Several test cases were updated with -Wno-uninitialized to silence this warning. llvm-svn: 191068
* Refactor the uninitialized field visitor. Also moved the calls to the visitorRichard Trieu2013-09-131-0/+38
| | | | | | | later in the code so that the expressions will have addition processing first. This catches a few additional cases of uninitialized uses of class fields. llvm-svn: 190657
* PR15906: The body of a lambda is not an evaluated subexpression; don't visit ↵Richard Smith2013-05-031-0/+12
| | | | | | it when visiting such subexpressions. llvm-svn: 181046
* Handle CXXOperatorCallExpr when checking self referrnce during initialization ofRichard Trieu2013-03-261-0/+15
| | | | | | class types. llvm-svn: 177987
* Reapply r172878 with test case.Ted Kremenek2013-01-191-16/+16
| | | | llvm-svn: 172888
* -Wuninitialized: warn about uninitialized values resulting from ?: that ↵Ted Kremenek2013-01-191-4/+4
| | | | | | evaluate to lvalues (in C++). llvm-svn: 172875
* Change how the SelfReferenceChecker handles MemberExpr. Instead of treatingRichard Trieu2012-10-031-0/+63
| | | | | | | each one separately, process a stack of MemberExpr's as a single unit so that static calls and member access will not be warned on. llvm-svn: 165074
* Cleaning up the self initialization checker.Richard Trieu2012-10-011-0/+10
| | | | | | | | | | | -Allow Sema to do more processing on the initial Expr before checking it. -Remove the special conditions in HandleExpr() -Move the code so that only one call site is needed. -Removed the function from Sema and only call it locally. -Warn on potentially evaluated reference variables, not just casts to r-values. -Update tests. llvm-svn: 164951
* Make warnings about uninitialized fields include the field name.Hans Wennborg2012-09-211-25/+25
| | | | | | | | | | | This makes the wording more informative, and consistent with the other warnings about uninitialized variables. Also, me and David who reviewed this couldn't figure out why we would need to do a lookup to get the name of the variable; so just print the name directly. llvm-svn: 164366
* Warn about self references in in-class initializers.Hans Wennborg2012-09-181-1/+27
| | | | | | | | | | | | | | This makes Clang warn about self references in in-class initializers, for example: struct S { int a = a + 42; }; This basically just moves UninitializedFieldVisitor up a bit in SemaDeclCXX.cpp, and adds a call to it from ActOnCXXInClassMemberInitializer. llvm-svn: 164131
* Better wording for reference self-initialization warning.Hans Wennborg2012-08-201-3/+3
| | | | llvm-svn: 162198
* Warn about self-initialization of references.Hans Wennborg2012-08-171-0/+19
| | | | | | | Initializing a reference with itself, e.g. "int &a = a;" seems like a very bad idea. llvm-svn: 162093
* Check local static variables for self reference on initialization.Richard Trieu2012-08-141-0/+62
| | | | llvm-svn: 161909
* For global record types, the self reference checker was called twice, resultingRichard Trieu2012-08-061-0/+23
| | | | | | | in duplicate -Wuninitialized warnings. Change so that only the check in TryConstructorInitialization() will be used and a single warning be emitted. llvm-svn: 161345
* Refine CFG so that '&&' and '||' don't lead to extra confluence points when ↵Ted Kremenek2012-07-141-1/+1
| | | | | | | | | | | | | | | | | | used in a branch, but instead push the terminator for the branch down into the basic blocks of the subexpressions of '&&' and '||' respectively. This eliminates some artifical control-flow from the CFG and results in a more compact CFG. Note that this patch only alters the branches 'while', 'if' and 'for'. This was complex enough for one patch. The remaining branches (e.g., do...while) can be handled in a separate patch, but they weren't immediately tackled because they were less important. It is possible that this patch introduces some subtle bugs, particularly w.r.t. to destructor placement. I've tried to audit these changes, but it is also known that the destructor logic needs some refinement in the area of '||' and '&&' regardless (i.e., their are known bugs). llvm-svn: 160218
* Use a proper visitor to recursively check for uninitialized use in constructors.Richard Trieu2012-06-141-3/+83
| | | | llvm-svn: 158477
* Removing the lambda extension warning concerning single return statements, ↵Aaron Ballman2012-06-041-1/+1
| | | | | | as it no longer applies. llvm-svn: 157943
* Pull some cases of initialization with self-reference warnings out ofRichard Trieu2012-05-091-3/+42
| | | | | | -Wconditional-uninitialized into -Wuninitialized. llvm-svn: 156512
* Update the SelfReferenceChecker. Refactored some of the visitor methods.Richard Trieu2012-05-091-1/+8
| | | | | | | Added support for conditional operators and tightened the exclusion of the unary operator from all operators to only the address of operator. llvm-svn: 156450
* Add -Wuninitialized test for C++11 lambdas.Ted Kremenek2012-04-121-1/+6
| | | | llvm-svn: 154608
* Fix broken CFG when an initializer is a statement expression that starts ↵Ted Kremenek2012-03-221-0/+15
| | | | | | with a while loop (PR 12325). llvm-svn: 153242
* Fix -Wuninitialized to catch the case of a class being initialized with a callRichard Trieu2012-03-081-0/+2
| | | | | | to its own member function. llvm-svn: 152276
* Improvements to the uninitialized variable warning: Check if the constructorRafael Espindola2012-01-061-0/+1
| | | | | | | call is elidable or if the constructor is trivial instead of checking if it is user declared. llvm-svn: 147652
* Teach the CFG builder how to properly destroy temporaries whoDouglas Gregor2011-11-151-0/+27
| | | | | | | | lifetimes have been extended via reference binding. The type of the reference and the type of the temporary are not necessarily the same, which could cause a crash. Fixes <rdar://problem/10398199>. llvm-svn: 144646
* Change the self-reference visitor (which gives the warning for ↵Richard Trieu2011-09-071-0/+2
| | | | | | | | self-reference oninitalization warning of -Wuninitialized) to exclude member variables that can decay into pointers. This will cause it to no longer warn on this code: struct foo { char a[100], *e; } bar = { .e = bar.a }; llvm-svn: 139213
* Extend the self-reference warning to catch when a constructor references ↵Richard Trieu2011-09-011-0/+72
| | | | | | | | | itself upon initialization, such as using itself within its own copy constructor. struct S {}; S s(s); llvm-svn: 138969
* 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
* Add tests for the uninitialized checks added in r128376. Also clean upChandler Carruth2011-03-271-11/+42
| | | | | | | | | | | | | | | and flesh out the existing uninitialized testing for field initializers. The tests come from Richard's original patch, but I've cleaned them up a bit and ordered them more naturally. Also, I added a test for the most simple base case: int x = x; And it turns out we miss this one! =[ That and another bad FIXME on the field initializer checking are left in the test. llvm-svn: 128394
* Add test case for <rdar://problem/8610363> (a bogus report of using an ↵Ted Kremenek2010-10-301-0/+14
uninitialized field). This was already fixed, but this serves for detecting regressions. llvm-svn: 117754
OpenPOWER on IntegriCloud