summaryrefslogtreecommitdiffstats
path: root/clang/lib/Analysis
Commit message (Collapse)AuthorAgeFilesLines
...
* Commit a bit of a hack to fully handle the situation where variables areChandler Carruth2011-04-051-4/+16
| | | | | | | | | | | | | | | | 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 PR 9626 (duplicated self-init warnings under -Wuninitialized) with ↵Ted Kremenek2011-04-042-8/+23
| | | | | | | | | | | | | | 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: don't warn about uninitialized variables in unreachable code.Ted Kremenek2011-04-042-4/+17
| | | | llvm-svn: 128840
* Make -Wheader-hygiene not complain about USING_NAMESPACE_THROUGH_MACRO in a ↵Nico Weber2011-04-021-1/+1
| | | | | | non-header file. llvm-svn: 128780
* -Wuninitialized should not warn about variables captured by blocks as byref.Ted Kremenek2011-03-311-6/+11
| | | | | | | | | 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
* Add workaround for Sema issue found in <rdar://problem/9188004>, which leads ↵Ted Kremenek2011-03-291-3/+13
| | | | | | | | | to an assertion failure in the uninitialized variables analysis. The problem is that Sema isn't properly registering a variable in a DeclContext (which -Wuninitialized relies on), but my expertise on the template instantiation logic isn't good enough to fix this problem for real. This patch worksaround the problem in -Wuninitialized, but we should fix it for real later. llvm-svn: 128443
* Make helpers static.Benjamin Kramer2011-03-261-2/+2
| | | | llvm-svn: 128339
* Fix CFG-construction bug when run from ↵Ted Kremenek2011-03-231-9/+23
| | | | | | | | AnalysisBasedWarnings::IssueWarnings() where block-level expressions that need to be recorded in the Stmt*->CFGBlock* map were not always done so. Fixes <rdar://problem/9171946>. llvm-svn: 128170
* Rename class 'CFGReachabilityAnalysis' to 'CFGReverseBlockReachabilityAnalysis'.Ted Kremenek2011-03-192-5/+5
| | | | | | | | | This rename serves two purposes: - It reflects the actual functionality of this analysis. - We will have more than one reachability analysis. llvm-svn: 127930
* Extend -Wuninitialized to support vector types.Ted Kremenek2011-03-171-3/+6
| | | | llvm-svn: 127794
* Teach CFGBuilder that the 'default' branch of a switch statement is dead if ↵Ted Kremenek2011-03-161-2/+4
| | | | | | all enum values in a switch conditioned are handled. llvm-svn: 127727
* Appease GCC. I'm surprised Clang accepted this.Ted Kremenek2011-03-151-10/+6
| | | | llvm-svn: 127672
* Split warnings from -Wuninitialized-experimental into "must-be-initialized" ↵Ted Kremenek2011-03-151-0/+3
| | | | | | and "may-be-initialized" warnings, each controlled by different flags. llvm-svn: 127669
* Split warnings from -Wuninitialized-experimental into "must-be-initialized" ↵Ted Kremenek2011-03-151-20/+44
| | | | | | and "may-be-initialized" warnings, each controlled by different flags. llvm-svn: 127666
* UninitializedValues: introduce ValueVector:reference class to forward to ↵Ted Kremenek2011-03-151-9/+26
| | | | | | llvm::BitVector. No real functionality change, but this is a stepping stone to moving to tri-state logic. llvm-svn: 127665
* UninitializedValues: wrap BitVector references in a new class ValueVector. ↵Ted Kremenek2011-03-151-5/+17
| | | | | | No functionality change. This defines the minimum interface that ValueVector needs to support when we no longer base it strictly on a direct interpretation of BitVector. llvm-svn: 127664
* Substitue term "BitVector" with "ValueVector" to prep for further revisions. ↵Ted Kremenek2011-03-151-44/+45
| | | | | | No functionality change. llvm-svn: 127663
* Rename UninitializedValuesV2 to UninitializedValues.Ted Kremenek2011-03-152-3/+3
| | | | llvm-svn: 127657
* Remove old UninitializedValues analysis.Ted Kremenek2011-03-152-318/+0
| | | | llvm-svn: 127656
* Instead of storing an ASTContext* in FunctionProtoTypes with computed ↵Sebastian Redl2011-03-131-3/+3
| | | | | | noexcept specifiers, unique FunctionProtoTypes with a ContextualFoldingSet, as suggested by John McCall. llvm-svn: 127568
* Fix CFG assertion failure reported in PR 9467. This was due to recent ↵Ted Kremenek2011-03-131-8/+11
| | | | | | changes in optimizing CFGs for switch statements. llvm-svn: 127563
* Propagate the new exception information to FunctionProtoType.Sebastian Redl2011-03-121-1/+1
| | | | | | | | Change the interface to expose the new information and deal with the enormous fallout. Introduce the new ExceptionSpecificationType value EST_DynamicNone to more easily deal with empty throw specifications. Update the tests for noexcept and fix the various bugs uncovered, such as lack of tentative parsing support. llvm-svn: 127537
* Add support for the OpenCL vec_step operator, by generalising andPeter Collingbourne2011-03-112-8/+11
| | | | | | | extending the existing support for sizeof and alignof. Original patch by Guy Benyei. llvm-svn: 127475
* When doing reachability analysis for warnings issued under ↵Ted Kremenek2011-03-102-4/+52
| | | | | | | | | DiagRuntimeBehavior, don't construct a ParentMap or CFGStmtMap. Instead, create a small set of Stmt* -> CFGBlock* mappings during CFG construction for only the statements we care about relating to the diagnostics we want to check for reachability. llvm-svn: 127396
* Require AddStmtChoice::alwaysAdd() to take a CFGBuilder& and Stmt*. Prep ↵Ted Kremenek2011-03-101-15/+22
| | | | | | for functionality changes. llvm-svn: 127387
* Remove unused 'AddStmtChoice' argument to CFGBuilder::appendStmt().Ted Kremenek2011-03-101-25/+24
| | | | llvm-svn: 127386
* Rework interaction between AnalysisContext and CFG::BuildOptions to keep a ↵Ted Kremenek2011-03-102-65/+61
| | | | | | | | | | | | BuildOptions object around instead of keeping a copy of the flags. Moreover, change AnalysisContext to use an OwningPtr for created analysis objects instead of directly managing them. Finally, add a 'forcedBlkExprs' entry to CFG::BuildOptions that will be used by the CFGBuilder to force specific expressions to be block-level expressions. llvm-svn: 127385
* Fix null dereference in CFGBlock::FilterEdge that was reported in PR 9412.Ted Kremenek2011-03-071-5/+5
| | | | llvm-svn: 127176
* Correctly handle nested switch statements in CFGBuilder when on switch ↵Ted Kremenek2011-03-041-11/+12
| | | | | | statement has a condition that evaluates to a constant. llvm-svn: 126977
* Teach CFGImplicitDtor::getDestructorDecl() about arrays of objects with ↵Ted Kremenek2011-03-031-3/+7
| | | | | | destructors. llvm-svn: 126910
* Teach CFGImplicitDtor::getDestructorDecl() about reference types.Ted Kremenek2011-03-031-2/+3
| | | | llvm-svn: 126909
* Let's go with John and Ted's preferred fix.Matt Beaumont-Gay2011-03-031-1/+2
| | | | llvm-svn: 126907
* Keep GCC from complaining about falling off the end of the function.Matt Beaumont-Gay2011-03-021-0/+1
| | | | llvm-svn: 126897
* Introduce CFGImplicitDtor::isNoReturn() to query whether a destructor ↵Ted Kremenek2011-03-021-1/+34
| | | | | | actually returns. Use this for -Wreturn-type to prune false positives reported in PR 6884. llvm-svn: 126875
* Move some of the logic about classifying Objective-C methods intoJohn McCall2011-03-021-74/+18
| | | | | | | | conventional categories into Basic and AST. Update the self-init checker to use this logic; CFRefCountChecker is complicated enough that I didn't want to touch it. llvm-svn: 126817
* Teach CFGBuilder to prune trivially unreachable case statements.Ted Kremenek2011-03-011-38/+106
| | | | llvm-svn: 126797
* In preparation for fixing PR 6884, rework CFGElement to have getAs<> return ↵Ted Kremenek2011-03-014-55/+79
| | | | | | | | | pointers instead of fresh CFGElements. - Also, consoldiate getDtorKind() and getKind() into one "kind". - Add empty getDestructorDecl() method to CFGImplicitDtor. llvm-svn: 126738
* Get rid of the areExceptionsEnabled() getter from LangOptions.Anders Carlsson2011-02-281-1/+1
| | | | llvm-svn: 126598
* Fix tiny error in CFG construction for BinaryConditionalOperators, making ↵Ted Kremenek2011-02-241-12/+14
| | | | | | | | | sure the branch always has two successors. Also teach Environment::getSVal() about OpaqueValueExprs. This fixes a crash reported in PR9287, and also fixes a false positive involving the value of such ternary expressions not properly getting propagated. llvm-svn: 126362
* Teach CFGBuilder about null pointer constants in conditionals, and how they ↵Ted Kremenek2011-02-231-3/+11
| | | | | | can be used to prune branches. Fixes false null pointer dereference warning in PR 8183. llvm-svn: 126305
* Migrate CFGReachabilityAnalysis out of the IdempotentOperationsChecker and ↵Ted Kremenek2011-02-233-0/+90
| | | | | | into its own analysis file. llvm-svn: 126289
* Have IdempotentOperationsChecker pull its CFGStmtMap from AnalysisContext.Ted Kremenek2011-02-231-0/+15
| | | | llvm-svn: 126288
* Fix a CFGBuilder bug exposed on convoluted control-flow in the Linux kernel.Ted Kremenek2011-02-211-5/+8
| | | | llvm-svn: 126149
* Add a LangOptions::areExceptionsEnabled and start using it.Anders Carlsson2011-02-201-1/+1
| | | | llvm-svn: 126062
* Fix a -Wuninitialized warning; it's actually a false positive,John McCall2011-02-191-2/+10
| | | | | | | | | but it's not reasonable for the diagnostic to figure that out. Pointed out by Benjamin Kramer. Also clarify the logic here. llvm-svn: 126017
* Change the representation of GNU ?: expressions to use a different expressionJohn McCall2011-02-173-49/+54
| | | | | | | | | | | | | | | | | | | | | | class and to bind the shared value using OpaqueValueExpr. This fixes an unnoticed problem with deserialization of these expressions where the deserialized form would lose the vital pointer-equality trait; or rather, it fixes it because this patch also does the right thing for deserializing OVEs. Change OVEs to not be a "temporary object" in the sense that copy elision is permitted. This new representation is not totally unawkward to work with, but I think that's really part and parcel with the semantics we're modelling here. In particular, it's much easier to fix things like the copy elision bug and to make the CFG look right. I've tried to update the analyzer to deal with this in at least some obvious cases, and I think we get a much better CFG out, but the printing of OpaqueValueExprs probably needs some work. llvm-svn: 125744
* Step #1/N of implementing support for __label__: split labels intoChris Lattner2011-02-171-12/+13
| | | | | | | | | | | | | | | | | | | LabelDecl and LabelStmt. There is a 1-1 correspondence between the two, but this simplifies a bunch of code by itself. This is because labels are the only place where we previously had references to random other statements, causing grief for AST serialization and other stuff. This does cause one regression (attr(unused) doesn't silence unused label warnings) which I'll address next. This does fix some minor bugs: 1. "The only valid attribute " diagnostic was capitalized. 2. Various diagnostics printed as ''labelname'' instead of 'labelname' 3. This reduces duplication of label checking between functions and blocks. Review appreciated, particularly for the cindex and template bits. llvm-svn: 125733
* Fix memory leak in CFGBuilder resulting from tracking scope information ↵Ted Kremenek2011-02-151-7/+10
| | | | | | using SmallVectors. llvm-svn: 125550
* Give some convenient idiomatic accessors to Stmt::child_range andJohn McCall2011-02-134-10/+7
| | | | | | | Stmt::const_child_range, then make a bunch of places use them instead of the individual iterator accessors. llvm-svn: 125450
* Don't report dead stores on unreachable code paths. Fixes ↵Ted Kremenek2011-02-112-4/+10
| | | | | | <rdar://problem/8405222>. llvm-svn: 125415
OpenPOWER on IntegriCloud