aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Analysis/UninitializedValues.cpp
AgeCommit message (Collapse)AuthorFilesLines
2016-10-29NFC small formatPiotr Padlewski1-1/+2
llvm-svn: 285496
2015-10-20Roll-back r250822.Angel Garcia Gomez1-2/+2
Summary: It breaks the build for the ASTMatchers Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D13893 llvm-svn: 250827
2015-10-20Apply modernize-use-default to clang.Angel Garcia Gomez1-2/+2
Summary: Replace empty bodies of default constructors and destructors with '= default'. Reviewers: bkramer, klimek Subscribers: klimek, alexfh, cfe-commits Differential Revision: http://reviews.llvm.org/D13890 llvm-svn: 250822
2015-06-22Revert r240270 ("Fixed/added namespace ending comments using clang-tidy").Alexander Kornienko1-5/+5
llvm-svn: 240353
2015-06-22Fixed/added namespace ending comments using clang-tidy. NFCAlexander Kornienko1-5/+5
The patch is generated using this command: $ tools/extra/clang-tidy/tool/run-clang-tidy.py -fix \ -checks=-*,llvm-namespace-comment -header-filter='llvm/.*|clang/.*' \ work/llvm/tools/clang To reduce churn, not touching namespaces spanning less than 10 lines. llvm-svn: 240270
2015-04-27PR23334: Perform semantic checking of lambda capture initialization in the ↵Richard Smith1-1/+1
right context. Previously we'd try to perform checks on the captures from the middle of parsing the lambda's body, at the point where we detected that a variable needed to be captured. This was wrong in a number of subtle ways. In PR23334, we couldn't correctly handle the list of potential odr-uses resulting from the capture, and our attempt to recover from that resulted in a use-after-free. We now defer building the initialization expression until we leave the lambda body and return to the enclosing context, where the initialization does the right thing. This patch only covers lambda-expressions, but we should apply the same change to blocks and captured statements too. llvm-svn: 235921
2015-04-11Use 'override/final' instead of 'virtual' for overridden methodsAlexander Kornienko1-1/+1
Summary: The patch is generated using clang-tidy misc-use-override check. This command was used: tools/clang/tools/extra/clang-tidy/tool/run-clang-tidy.py \ -checks='-*,misc-use-override' -header-filter='llvm|clang' -j=32 -fix Reviewers: dblaikie Reviewed By: dblaikie Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D8926 llvm-svn: 234678
2015-03-03Make -Wuninitialized warn on pointer-to-member and comma operators.Manuel Klimek1-11/+44
`isTrackedVar` has been updated to also track records. `DeclRefExpr`s appearing on the left side of a comma operator are ignored, while those appearing on the right side are classified as `Use`. Patch by Enrico Pertoso. llvm-svn: 231068
2014-11-27When checking for uninitialized values, do not confuse "std::move" with everyRichard Trieu1-1/+2
other function named "move". llvm-svn: 222863
2014-09-23Reverting r214064 and r215650 while investigating a pesky performance regressionArtyom Skrobov1-2/+62
llvm-svn: 218296
2014-08-27More -Wuninitialized updatesRichard Trieu1-3/+18
Fix r216438 to catch more complicated self-initialized in std::move. For instance, "Foo f = std::move(cond ? OtherFoo : (UNUSED_VALUE, f));" Make sure that BinaryConditionalOperator, ConditionalOperator, BinaryOperator with comma operator, and OpaqueValueExpr perform the correct usage forwarding across the three uninitialized value checkers. llvm-svn: 216627
2014-08-26Passing a variable to std::move now counts as a use for -WuninitializedRichard Trieu1-0/+10
llvm-svn: 216438
2014-08-14Use the proper post-order traversal in LiveVariables analysis,Artyom Skrobov1-1/+1
to recover the performance after r214064. Also sorts out the naming for PostOrderCFGView, ReversePostOrderCFGView, BackwardDataflowWorklist and ForwardDataflowWorklist, to match the accepted terminology. Also unifies BackwardDataflowWorklist and ForwardDataflowWorklist to share the "worklist for prioritization, post-order traversal for fallback" logic, and to avoid repetitive sorting. Also cleans up comments in the affected area. llvm-svn: 215650
2014-07-28Factoring DataflowWorklist out of LiveVariables and UninitializedValues analysesArtyom Skrobov1-62/+2
llvm-svn: 214064
2014-06-11PR19996: don't crash if -Wuninitialized sees a c++1y lambda init-capture.Richard Smith1-1/+1
llvm-svn: 210615
2014-05-20[C++11] Use 'nullptr'. Analysis edition.Craig Topper1-5/+5
llvm-svn: 209191
2014-03-14[C++11] Replacing BlockDecl iterators capture_begin() and capture_end() with ↵Aaron Ballman1-4/+3
iterator_range captures(). Updating all of the usages of the iterators with range-based for loops. llvm-svn: 203958
2014-03-14[C++11] Replacing DeclStmt iterators decl_begin() and decl_end() with ↵Aaron Ballman1-6/+4
iterator_range decls(). Updating all of the usages of the iterators with range-based for loops. llvm-svn: 203947
2014-03-14[C++11] Add 'override' keyword to virtual methods that override their base ↵Craig Topper1-3/+3
class. llvm-svn: 203893
2014-02-27Rework CFG edges to encode potentially unreachable edges, instead of just ↵Ted Kremenek1-0/+5
making them NULL. This is to support some analyses, like -Wunreachable-code, that will need to recover the original unprunned CFG edges in order to suppress issues that aren't really bugs in practice. There are two important changes here: - AdjacentBlock replaces CFGBlock* for CFG successors/predecessors. This has the size of 2 pointers, instead of 1. This is unlikely to have a significant memory impact on Sema since a single CFG usually exists at one time, but could impact the memory usage of the static analyzer. This could possibly be optimized down to a single pointer with some cleverness. - Predecessors can now contain null predecessors, which means some analyses doing a reverse traversal will need to take into account. This already exists for successors, which contain successor slots for specific branch kinds (e.g., 'if') that expect a fixed number of successors, even if a branch is not reachable. llvm-svn: 202325
2013-09-12PR16054: Slight strengthening for -Wsometimes-uninitialized: if we use aRichard Smith1-1/+17
variable uninitialized every time we reach its (reachable) declaration, or every time we call the surrounding function, promote the warning from -Wmaybe-uninitialized to -Wsometimes-uninitialized. This is still slightly weaker than desired: we should, in general, warn if a use is uninitialized the first time it is evaluated. llvm-svn: 190623
2013-08-23Use pop_back_val() instead of both back() and pop_back().Robert Wilhelm1-6/+4
No functionality change intended. llvm-svn: 189112
2013-05-15Remove unused, awkward CFGStmtVisitor and subclasses.Jordan Rose1-1/+1
This class is a StmtVisitor that distinguishes between block-level and non-block-level statements in a CFG. However, it does so using a hard-coded idea of which statements might be block-level, which probably isn't accurate anymore. The only implementer of the CFGStmtVisitor hierarchy was the analyzer's DeadStoresChecker, and the analyzer creates a linearized CFG anyway (every non-trivial statement is a block-level statement). This also allows us to remove the block-expr map ("BlkExprMap"), which mapped statements to positions in the CFG. Apart from having a helper type that really should have just been Optional<unsigned>, it was only being used to ask /if/ a particular expression was block-level, for traversal purposes in CFGStmtVisitor. llvm-svn: 181945
2013-02-23Remove the CFGElement "Invalid" state.David Blaikie1-3/+2
Use Optional<CFG*> where invalid states were needed previously. In the one case where that's not possible (beginAutomaticObjDtorsInsert) just use a dummy CFGAutomaticObjDtor. Thanks for the help from Jordan Rose & discussion/feedback from Ted Kremenek and Doug Gregor. Post commit code review feedback on r175796 by Ted Kremenek. llvm-svn: 175938
2013-02-21Replace CFGElement llvm::cast support to be well-defined.David Blaikie1-2/+2
See r175462 for another example/more details. llvm-svn: 175796
2013-02-21Use None rather than Optional<T>() where possible.David Blaikie1-1/+1
llvm-svn: 175705
2013-02-20Include llvm::Optional in clang/Basic/LLVM.hDavid Blaikie1-5/+5
Post-commit CR feedback from Jordan Rose regarding r175594. llvm-svn: 175679
2013-01-19-Wuninitialized: warn about uninitialized values resulting from ?: that ↵Ted Kremenek1-0/+10
evaluate to lvalues (in C++). llvm-svn: 172875
2013-01-12Remove useless 'llvm::' qualifier from names like StringRef and others that areDmitri Gribenko1-2/+2
brought into 'clang' namespace by clang/Basic/LLVM.h llvm-svn: 172323
2013-01-11Test commit.Enea Zaffanella1-1/+1
llvm-svn: 172195
2012-12-01Pull the Attr iteration parts out of Attr.h, so including DeclBase.h doesn't ↵Benjamin Kramer1-9/+10
pull in all the generated Attr code. Required to pull some functions out of line, but this shouldn't have a perf impact. No functionality change. llvm-svn: 169092
2012-11-17Further reduce "-fsyntax-only -Wuninitialized" time on sqlite3.c by another ↵Ted Kremenek1-12/+52
2.5% using intelligent pruning of blocks during the final reporting pass. llvm-svn: 168257
2012-11-17Switch -Wuninitialized to use a reverse-post order traversal asTed Kremenek1-15/+33
an initial baseline for enqueued blocks, but use a simple DFS stack for propagating changes quickly up back edges. This provides a 3.5% reduction in -fsyntax-only time on sqlite3.c. llvm-svn: 168241
2012-09-28Avoid malloc thrashing in the uninitialized value analysis.Benjamin Kramer1-11/+5
- The size of the packed vector is often small, save mallocs using SmallBitVector. - Copying SmallBitVectors is also cheap, remove a level of indirection. llvm-svn: 164827
2012-09-13Teach -Wuninitialized to recognize common "noreturn" idioms inTed Kremenek1-4/+16
Objective-C related to NSException. Fixes <rdar://problem/12287498> I debated whether or not this logic should be sunk into the CFG itself. It's not clear if we should, as different analyses may wish to have different policies. We can re-evaluate this in the future. llvm-svn: 163760
2012-09-12Teach -Wuninitialized to recognize __attribute__((analyzer_noreturn))Ted Kremenek1-8/+20
for halting the propagation of uninitialized value tracking along a path. Unlike __attribute__((noreturn)), this attribute (which is used by clients of the static analyzer) can be used to annotate functions that essentially never return, but in rare cares may be allowed to return for (special) debugging purposes. This attribute has been shown in reducing false positives in the static analyzer by pruning false postives, and is equally applicable here. Handling this attribute in the CFG itself is another option, but this is not something all clients (e.g., possibly -Wunreachable-code) would want to see. Addresses <rdar://problem/12281583>. llvm-svn: 163681
2012-07-19Simplify UninitializedValues.cpp by removing logic to handle the previous ↵Ted Kremenek1-142/+25
(imprecise) representation of '&&' and '||' in the CFG. This is no longer needed, and greatly simplifies the code. llvm-svn: 160494
2012-07-17Uninitialized variables: two little changes:Richard Smith1-1/+3
* Treat compound assignment as a use, at Jordy's request. * Always add compound assignments into the CFG, so we can correctly diagnose the use in 'return x += 1;' llvm-svn: 160334
2012-07-17-Wuninitialized: Split the classification of DeclRefExprs as initialization orRichard Smith1-228/+223
use out of TransferFunctions, and compute it in advance rather than on-the-fly. This allows us to handle compound assignments with DeclRefExprs on the RHS correctly, and also makes it trivial to treat const& function parameters as not initializing the argument. The patch also makes both of those changes. llvm-svn: 160330
2012-07-13PR13360: When deciding the earliest point which inevitably leads to anRichard Smith1-14/+19
uninitialized variable use, walk back over branches where we've reached all the non-null successors, not just cases where we've reached all successors. llvm-svn: 160206
2012-07-02-Wuninitialized: assume that an __attribute__((returns_twice)) function mightRichard Smith1-0/+18
initialize any variable. This is extremely conservative, but is sufficient for now. llvm-svn: 159620
2012-06-16-Wuninitialized bugfix: when entering the scope of a variable with noRichard Smith1-0/+12
initializer, it is uninitialized, even if we may be coming from somewhere where it was initialized. llvm-svn: 158611
2012-06-06Revert Decl's iterators back to pointer value_type rather than reference ↵David Blaikie1-1/+1
value_type In addition, I've made the pointer and reference typedef 'void' rather than T* just so they can't get misused. I would've omitted them entirely but std::distance likes them to be there even if it doesn't use them. This rolls back r155808 and r155869. Review by Doug Gregor incorporating feedback from Chandler Carruth. llvm-svn: 158104
2012-05-25Split a chunk of -Wconditional-uninitialized warnings out into a separate flag,Richard Smith1-6/+134
-Wsometimes-uninitialized. This detects cases where an explicitly-written branch inevitably leads to an uninitialized variable use (so either the branch is dead code or there is an uninitialized use bug). This chunk of warnings tentatively lives within -Wuninitialized, in order to give it more visibility to existing Clang users. llvm-svn: 157458
2012-05-24Some cleanups around the uninitialized variables warning, and a FIXME. No ↵Richard Smith1-22/+18
functional change. llvm-svn: 157440
2012-04-30Remove the ref/value inconsistency in filter_decl_iterator.David Blaikie1-1/+1
filter_decl_iterator had a weird mismatch where both op* and op-> returned T* making it difficult to generalize this filtering behavior into a reusable library of any kind. This change errs on the side of value, making op-> return T* and op* return T&. (reviewed by Richard Smith) llvm-svn: 155808
2012-04-30PR11926 + duplicates: Fix crash in -Wuninitialized when using a compiler likeRichard Smith1-1/+2
g++4.7, which reuses stack space allocated for temporaries. CFGElement::getAs returns a suitably-cast version of 'this'. Patch by Markus Trippelsdorf! No test: this code has the same observable behavior as the old code when built with most compilers, and the tests were already failing when built with a compiler for which this produced a broken binary. llvm-svn: 155803
2012-03-01Move llvm/ADT/SaveAndRestore.h -> llvm/Support/SaveAndRestore.h.Argyrios Kyrtzidis1-1/+1
Needs llvm update. llvm-svn: 151829
2012-02-27Move "clang/Analysis/Support/SaveAndRestore.h" to "llvm/ADT/SaveAndRestore.h"Argyrios Kyrtzidis1-1/+1
to make it more widely available. Depends on llvm commit r151564 llvm-svn: 151566
2011-10-24Rename AnalysisContext to AnalysisDeclContext. Not only is this name more ↵Ted Kremenek1-4/+4
accurate, but it frees up the name AnalysisContext for other uses. llvm-svn: 142782