aboutsummaryrefslogtreecommitdiff
path: root/lib/Analysis
AgeCommit message (Collapse)Author
2011-05-13Refactoring of constant expression evaluatorPeter Collingbourne
This introduces a generic base class for the expression evaluator classes, which handles a few common expression types which were previously handled separately in each class. Also, the expression evaluator now uses ConstStmtVisitor. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@131281 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-11Teach CFG building how to deal with CXXMemberCallExprs and BoundMemberTy,John McCall
then teach -Wreturn-type to handle the same. Net effect: we now correctly handle noreturn attributes on member calls in the CFG. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@131178 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-10Fix crash in -Wuninitialized when using switch statments whose condition is ↵Ted Kremenek
a logical operation. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@131158 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-10Elide __label__ declarations from the CFG. This resolves a crash in ↵Ted Kremenek
CFGRecStmtDeclVisitor (crash in static analyzer). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@131141 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-28Silence more -Wnon-pod-memset given its current implementation. I may beChandler Carruth
able to revert these based on a patch I'm working on, but no reason for people to be spammed with warnings in the interim. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@130394 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-27Remove unused method CFGBlock::hasBinaryBranchTerminator().Ted Kremenek
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@130336 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-27Don't print fixits for format specifiers in cases where the fixit does not ↵Eli Friedman
actually fix the warning. PR8781. I'm not sure what the preferred way to write a test for whether a fixit is emitted. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@130335 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-25When generating printf fixits, preserve the original formating for unsigned ↵Ted Kremenek
integers (e.g., 'x', 'o'). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@130164 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-18Fix PR9741. The implicit declarations created for range-based for loops ↵Richard Smith
weren't being added to the DeclContext (nor were they being marked as implicit). Also, the declarations were being emitted in the wrong order when building the CFG. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@129700 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-15fix a bunch of comment typos found by codespell. Patch byChris Lattner
Luis Felipe Strano Moraes! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@129559 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-14When we transform a C++ exception declaration (e.g., for templateDouglas Gregor
instantiation), be sure to add the transformed declaration into the current DeclContext. Also, remove the -Wuninitialized hack that works around this bug. Fixes <rdar://problem/9200676>. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@129544 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-14Add support for C++0x's range-based for loops, as specified by the C++11 ↵Richard Smith
draft standard (N3291). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@129541 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-14Return the correct lastly populated block from ↵Ted Kremenek
CFGBuilder::VisitUnaryExprOrTypeTraitExpr(). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@129499 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-13Teach -Wuninitialized about C++'s typeid expression, including both theChandler Carruth
evaluated and unevaluated contexts. Add some testing of sizeof and typeid. Both of the typeid tests added here were triggering warnings previously. Now the one false positive is suppressed without suppressing the warning on actually buggy code. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@129431 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-07Teach -Wuninitialized to not warn about variables declared in C++ catch ↵Ted Kremenek
statements. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@129102 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-05Commit a bit of a hack to fully handle the situation where variables areChandler Carruth
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@128932 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-04Fix PR 9626 (duplicated self-init warnings under -Wuninitialized) with ↵Ted Kremenek
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@128858 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-04-Wuninitialized: don't warn about uninitialized variables in unreachable code.Ted Kremenek
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@128840 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-02Make -Wheader-hygiene not complain about USING_NAMESPACE_THROUGH_MACRO in a ↵Nico Weber
non-header file. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@128780 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-31-Wuninitialized should not warn about variables captured by blocks as byref.Ted Kremenek
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@128681 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-29Add workaround for Sema issue found in <rdar://problem/9188004>, which leads ↵Ted Kremenek
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@128443 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-26Make helpers static.Benjamin Kramer
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@128339 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-23Fix CFG-construction bug when run from ↵Ted Kremenek
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>. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@128170 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-19Rename class 'CFGReachabilityAnalysis' to 'CFGReverseBlockReachabilityAnalysis'.Ted Kremenek
This rename serves two purposes: - It reflects the actual functionality of this analysis. - We will have more than one reachability analysis. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127930 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-17Extend -Wuninitialized to support vector types.Ted Kremenek
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127794 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-16Teach CFGBuilder that the 'default' branch of a switch statement is dead if ↵Ted Kremenek
all enum values in a switch conditioned are handled. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127727 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-15Appease GCC. I'm surprised Clang accepted this.Ted Kremenek
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127672 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-15Split warnings from -Wuninitialized-experimental into "must-be-initialized" ↵Ted Kremenek
and "may-be-initialized" warnings, each controlled by different flags. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127669 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-15Split warnings from -Wuninitialized-experimental into "must-be-initialized" ↵Ted Kremenek
and "may-be-initialized" warnings, each controlled by different flags. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127666 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-15UninitializedValues: introduce ValueVector:reference class to forward to ↵Ted Kremenek
llvm::BitVector. No real functionality change, but this is a stepping stone to moving to tri-state logic. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127665 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-15UninitializedValues: wrap BitVector references in a new class ValueVector. ↵Ted Kremenek
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127664 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-15Substitue term "BitVector" with "ValueVector" to prep for further revisions. ↵Ted Kremenek
No functionality change. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127663 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-15Rename UninitializedValuesV2 to UninitializedValues.Ted Kremenek
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127657 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-15Remove old UninitializedValues analysis.Ted Kremenek
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127656 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-13Instead of storing an ASTContext* in FunctionProtoTypes with computed ↵Sebastian Redl
noexcept specifiers, unique FunctionProtoTypes with a ContextualFoldingSet, as suggested by John McCall. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127568 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-13Fix CFG assertion failure reported in PR 9467. This was due to recent ↵Ted Kremenek
changes in optimizing CFGs for switch statements. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127563 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-12Propagate the new exception information to FunctionProtoType.Sebastian Redl
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127537 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-11Add support for the OpenCL vec_step operator, by generalising andPeter Collingbourne
extending the existing support for sizeof and alignof. Original patch by Guy Benyei. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127475 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-10When doing reachability analysis for warnings issued under ↵Ted Kremenek
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127396 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-10Require AddStmtChoice::alwaysAdd() to take a CFGBuilder& and Stmt*. Prep ↵Ted Kremenek
for functionality changes. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127387 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-10Remove unused 'AddStmtChoice' argument to CFGBuilder::appendStmt().Ted Kremenek
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127386 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-10Rework interaction between AnalysisContext and CFG::BuildOptions to keep a ↵Ted Kremenek
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127385 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-07Fix null dereference in CFGBlock::FilterEdge that was reported in PR 9412.Ted Kremenek
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127176 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-04Correctly handle nested switch statements in CFGBuilder when on switch ↵Ted Kremenek
statement has a condition that evaluates to a constant. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126977 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-03Teach CFGImplicitDtor::getDestructorDecl() about arrays of objects with ↵Ted Kremenek
destructors. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126910 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-03Teach CFGImplicitDtor::getDestructorDecl() about reference types.Ted Kremenek
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126909 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-03Let's go with John and Ted's preferred fix.Matt Beaumont-Gay
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126907 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-02Keep GCC from complaining about falling off the end of the function.Matt Beaumont-Gay
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126897 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-02Introduce CFGImplicitDtor::isNoReturn() to query whether a destructor ↵Ted Kremenek
actually returns. Use this for -Wreturn-type to prune false positives reported in PR 6884. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126875 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-02Move some of the logic about classifying Objective-C methods intoJohn McCall
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126817 91177308-0d34-0410-b5e6-96231b3b80d8