summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/AnalysisBasedWarnings.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Revert various template unreachability code I committed accidentally.David Blaikie2012-01-241-4/+5
| | | | | | r148774, r148775, r148776, r148777 llvm-svn: 148780
* Simple hack to do unreachable code analysis on template patterns.David Blaikie2012-01-241-5/+4
| | | | llvm-svn: 148774
* Make clang's AST model sizeof and typeof with potentially-evaluated operands ↵Eli Friedman2012-01-211-2/+6
| | | | | | correctly, similar to what we already do with typeid. llvm-svn: 148610
* Improve 0-argument -Wvexing-parse diagnostic by adding notes with fix-its:Richard Smith2012-01-121-33/+6
| | | | | | | | | | | | | | | | | | | | | | | - If the declarator is at the start of a line, and the previous line contained another declarator and ended with a comma, then that comma was probably a typo for a semicolon: int n = 0, m = 1, l = 2, // k = 5; myImportantFunctionCall(); // oops! - If removing the parentheses would correctly initialize the object, then produce a note suggesting that fix. - Otherwise, if there is a simple initializer we can suggest which performs value-initialization, then provide a note suggesting a correction to that initializer. Sema::Declarator now tracks the location of the comma prior to the declarator in the declaration, if there is one, to facilitate providing the note. The code to determine an appropriate initializer from the -Wuninitialized warning has been factored out to allow use in both that and -Wvexing-parse. llvm-svn: 148072
* Unweaken vtables as per ↵David Blaikie2011-12-201-0/+2
| | | | | | http://llvm.org/docs/CodingStandards.html#ll_virtual_anch llvm-svn: 146959
* This patch extends thread safety analysis with support for the ↵DeLesley Hutchins2011-12-081-2/+2
| | | | | | scoped_lockable attribute. llvm-svn: 146174
* Further tweak -Wurneachable-code and templates by allowing the warning to run onTed Kremenek2011-12-011-14/+6
| | | | | | | | | explicit template specializations (which represent actual functions somebody wrote). Along the way, refactor some other code which similarly cares about whether or not they are looking at a template instantiation. llvm-svn: 145547
* Don't run -Wunreachable-code on template instantiations. Different ↵Ted Kremenek2011-11-301-2/+8
| | | | | | instantiations may produce different unreachable code results, and it is very difficult for us to prove that ALL instantiations of a template have specific unreachable code. If we come up with a better solution, then we can revisit this, but this approach will at least greatly reduce the noise of this warning for code that makes use of templates. llvm-svn: 145520
* Rename AnalysisContext to AnalysisDeclContext. Not only is this name more ↵Ted Kremenek2011-10-241-4/+4
| | | | | | accurate, but it frees up the name AnalysisContext for other uses. llvm-svn: 142782
* [analyzer] Remove LocationContext creation methods from AnalysisManager, and ↵Ted Kremenek2011-10-231-1/+1
| | | | | | | | change clients to use AnalysisContext instead. WIP to remove/reduce ExprEngine's usage of AnalysisManager. llvm-svn: 142739
* Thread safety analysis refactoring: invalid lock expressions.DeLesley Hutchins2011-10-211-2/+9
| | | | llvm-svn: 142666
* Only warn at self-initialization if some later use is always uninitialized.Matt Beaumont-Gay2011-10-191-2/+13
| | | | llvm-svn: 142538
* Tweak -Wuninitialized's handling of 'int x = x' to report that as the root ↵Ted Kremenek2011-10-131-24/+46
| | | | | | cause of an uninitialized variable IFF there are other uses of that uninitialized variable. Fixes <rdar://problem/9259237>. llvm-svn: 141881
* Don't suggest 'noreturn' for function template instantiations, becauseDouglas Gregor2011-10-101-1/+17
| | | | | | | it might be wrong for other instantiations of the same function template. Fixes PR10801. llvm-svn: 141559
* Rename Diagnostic to DiagnosticsEngine as per issue 5397David Blaikie2011-09-251-12/+12
| | | | llvm-svn: 140478
* Thread safety: refactoring various out of scope warnings to use the same ↵Caitlin Sadowski2011-09-151-12/+15
| | | | | | inteface. This eliminates a lot of unnecessary duplicated code. llvm-svn: 139801
* Thread safety: reverting to use separate warning for requirement to hold any ↵Caitlin Sadowski2011-09-141-4/+9
| | | | | | lock llvm-svn: 139723
* Thread safety: Initializing var before exhaustive switch statement to deal ↵Caitlin Sadowski2011-09-131-1/+1
| | | | | | with extraneous warning produced by gcc but not clang llvm-svn: 139611
* Switch -Wreturn-type to completely rely on the CFG model of no-return.Chandler Carruth2011-09-131-47/+18
| | | | | | | This deletes a bunch of crufty code, and allows more logic sharing between the analyzer and the warnings. llvm-svn: 139594
* Show either a location or a fixit note, not both, for uninitialized variable ↵David Blaikie2011-09-101-52/+51
| | | | | | warnings. llvm-svn: 139463
* Fix a diagnostics crasher with -Wmissing-noreturn in Objective-CDouglas Gregor2011-09-101-1/+4
| | | | | | | methods, and improve the diagnostic slightly along the way. Fixes <rdar://problem/10098695>. llvm-svn: 139446
* Thread safety: This patch deals with previously unhandled cases when ↵Caitlin Sadowski2011-09-091-0/+4
| | | | | | building lock expressions. We now resolve this expressions, avoid crashing when encountering cast expressions, and have a diagnostic for unresolved lock expressions llvm-svn: 139370
* Thread Safety: Moving the analysis to a new fileCaitlin Sadowski2011-09-091-799/+1
| | | | llvm-svn: 139369
* Thread safety: refactoring test casesCaitlin Sadowski2011-09-091-14/+3
| | | | llvm-svn: 139368
* Thread safety: refactoring to use an error handlerCaitlin Sadowski2011-09-091-134/+251
| | | | llvm-svn: 139367
* Thread safety: small edit to unused variation on warning left in by accident ↵Caitlin Sadowski2011-09-081-2/+1
| | | | | | from earlier commit llvm-svn: 139331
* Thread Safety: In C++0x Mutexes are the objects that control access to ↵Caitlin Sadowski2011-09-081-90/+80
| | | | | | shared variables, while Locks are the objects that acquire and release Mutexes. We switch to this new terminology. llvm-svn: 139321
* Thread Safety: adding basic no thread safety analysis optionCaitlin Sadowski2011-09-081-0/+2
| | | | llvm-svn: 139310
* Thread safety: Adding basic support for locks required and excluded attributesCaitlin Sadowski2011-09-081-2/+51
| | | | llvm-svn: 139308
* Thread safety: shared vs. exclusive locksCaitlin Sadowski2011-09-081-64/+152
| | | | llvm-svn: 139307
* Thread Safety: Patch to implement delayed parsing of attributes within aCaitlin Sadowski2011-09-081-0/+2
| | | | | | | | class scope. This patch was also written by DeLesley Hutchins. llvm-svn: 139301
* Improve the diagnostic text for -Wmissing-noreturn to include the nameChandler Carruth2011-08-311-3/+8
| | | | | | | | | | | | | | of the function in question when applicable (that is, not for blocks). Patch by Joerg Sonnenberger with some stylistic tweaks by me. When discussing this weth Joerg, streaming the decl directly into the diagnostic didn't work because we have a pointer-to-const, and the overload doesn't accept such. In order to make my style tweaks to the patch, I first changed the overload to accept a pointer-to-const, and then changed the diagnostic printing layer to also use a pointer-to-const, cleaning up a gross line of code along the way. llvm-svn: 138854
* Thread safety: added basic handling for pt_guarded_by/var and guarded_by/var ↵Caitlin Sadowski2011-08-291-4/+120
| | | | | | annotations. We identify situations where we are accessing (reading or writing) guarded variables, and report an error if the appropriate locks are not held. llvm-svn: 138774
* Thread safety: various minor bugfixes, with test casesCaitlin Sadowski2011-08-291-13/+34
| | | | | | This patch is by DeLesley Hutchins. llvm-svn: 138738
* In C++0x mode, suggest nullptr as the initializer for an uninitializedDouglas Gregor2011-08-271-1/+3
| | | | | | pointer variable. Patch by David Blaikie! llvm-svn: 138687
* Thread safety: Fix a few typos in last commit -- use LockID instead of Lock ↵Caitlin Sadowski2011-08-241-14/+14
| | | | | | in comments and start a couple methods with a lowercase letter llvm-svn: 138460
* Start reworking -Wunreachable-code. The original analysis had serious flaws ↵Ted Kremenek2011-08-231-9/+15
| | | | | | | | | | with how it handled SCC's of dead code, or simply having false negatives by overly suppressing warnings. WIP. llvm-svn: 138410
* Constify the result of CFGStmt::getStmt().Ted Kremenek2011-08-231-6/+6
| | | | llvm-svn: 138408
* Thread-safety analysis: adding in a basic lockset tracking system. ThisCaitlin Sadowski2011-08-231-0/+561
| | | | | | | | | | | | | | | | system flags an error when unlocking a lock which was not held, locking the same lock twice, having a different lockset on each iteration of a loop, or going out of scope while still holding a lock. In order to successfully use the lockset, this patch also makes sure that attribute arguments are attached correctly for later parsing. This patch was also worked on by DeLesley Hutchins. Note: This patch has been reviewed by Chandler Carruth and Jeffrey Yasskin. Feel free to provide post-commit review comments for a subsequent patch. llvm-svn: 138350
* remove unneeded llvm:: namespace qualifiers on some core types now that ↵Chris Lattner2011-07-231-4/+4
| | | | | | | | LLVM.h imports them into the clang namespace. llvm-svn: 135852
* Move duplicate uninitialized warning suppression into theChandler Carruth2011-07-221-7/+5
| | | | | | | | | | | | 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
* Simplify passing of CFGBuildOptions around for AnalysisContext. No ↵Ted Kremenek2011-07-211-10/+16
| | | | | | functionality change. llvm-svn: 135666
* Reduce -Wuninitialized time by 22% (on sqlite) by removing the recursive AST ↵Ted Kremenek2011-07-191-0/+14
| | | | | | | | | | | | | | | crawl. This is accomplished by forcing the needed expressions for -Wuninitialized to always be CFGElements in the CFG. This allows us to remove a fair amount of the code for -Wuninitialized. Some fallout: - AnalysisBasedWarnings.cpp now specifically toggles the CFGBuilder to create a CFG that is suitable for -Wuninitialized. This is a layering violation, since the logic for -Wuninitialized is in libAnalysis. This can be fixed with the proper refactoring. - Some of the source locations for -Wunreachable-code warnings have shifted. While not ideal, this is okay because that analysis already needs some serious reworking. llvm-svn: 135480
* Zero this struct in a way that neither depends on the size of the struct nor ↵Benjamin Kramer2011-07-161-0/+1
| | | | | | triggers warnings from GCC. llvm-svn: 135351
* Remove a gcc warning.Fariborz Jahanian2011-07-161-1/+1
| | | | llvm-svn: 135348
* Initialize all the AnalysisBasedWarnings statistics to zero.Benjamin Kramer2011-07-081-1/+7
| | | | | | Found by valgrind. llvm-svn: 134733
* Based on comments from Chris, switch to using CFG::getNumBlockIDs()Chandler Carruth2011-07-061-3/+2
| | | | | | | | | | | | | rather than a computed std::distance(). At some point I had convinced myself that these two were different; but as far as I can tell on re-exampination they aren't, and the number of block IDs is actually just a count of the blocks in the CFG. While this removes the primary motivation for guarding all of this with CollectStats, I have a patch coming up that will almost certainly make it important again. llvm-svn: 134552
* Build up statistics about the work done for analysis based warnings.Chandler Carruth2011-07-061-2/+66
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Special detail is added for uninitialized variable analysis as this has serious performance problems than need to be tracked. Computing some of this data is expensive, for example walking the CFG to determine its size. To avoid doing that unless the stats data is going to be used, we thread a bit into the Sema object to track whether detailed stats should be collected or not. This bit is used to avoid computations whereever the computations are likely to be more expensive than checking the state of the flag. Thus, counters are in some cases unconditionally updated, but the more expensive (and less frequent) aggregation steps are skipped. With this patch, we're able to see that for 'gcc.c': *** Analysis Based Warnings Stats: 232 functions analyzed (0 w/o CFGs). 7151 CFG blocks built. 30 average CFG blocks per function. 1167 max CFG blocks per function. 163 functions analyzed for uninitialiazed variables 640 variables analyzed. 3 average variables per function. 94 max variables per function. 96409 block visits. 591 average block visits per function. 61546 max block visits per function. And for the reduced testcase in PR10183: *** Analysis Based Warnings Stats: 98 functions analyzed (0 w/o CFGs). 8526 CFG blocks built. 87 average CFG blocks per function. 7277 max CFG blocks per function. 68 functions analyzed for uninitialiazed variables 1359 variables analyzed. 19 average variables per function. 1196 max variables per function. 2540494 block visits. 37360 average block visits per function. 2536495 max block visits per function. That last number is the somewhat scary one that indicates the problem in PR10183. llvm-svn: 134494
* When producing -Wuninitialized Fix-Its for pointers, prefer " = NULL"Douglas Gregor2011-07-021-1/+9
| | | | | | over "= 0". Fixes <rdar://problem/9714386>. llvm-svn: 134302
* Teach CFG building how to deal with CXXMemberCallExprs and BoundMemberTy,John McCall2011-05-111-1/+6
| | | | | | | then teach -Wreturn-type to handle the same. Net effect: we now correctly handle noreturn attributes on member calls in the CFG. llvm-svn: 131178
OpenPOWER on IntegriCloud