aboutsummaryrefslogtreecommitdiff
path: root/lib/Checker
AgeCommit message (Collapse)Author
2010-07-07Cleanup on CStringChecker and its associated tests. Also check for null ↵Jordy Rose
arguments...which are allowed if the access length is 0! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@107759 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-07Change explicit handling of impossible condition to call llvm_unreachable in ↵Tom Care
IdempotentOperationChecker::PreVisitBinaryOperator. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@107748 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-07Silence an annoying GCC warning about use of an uninitialized variable. EvenChandler Carruth
making the other switch case unreachable, or sinking the 'continue' into it doesn't silence this. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@107745 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-07Use 'llvm_unreachable' to mark impossible code paths so that GCC doesn'tChandler Carruth
consider them for warnings. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@107741 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-06Fix casts in RegionStore to not always assume that bindings are only to ↵Ted Kremenek
SubRegions. Fixes assertion failure reported in PR 7572. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@107738 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-06Implement dumpToStream() for NonStaticGlobalSpaceRegion and ↵Ted Kremenek
StaticGlobalSpaceRegion. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@107731 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-06Add comment noting VLASizeChecker's duty in defining a VLA's extent.Jordy Rose
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@107728 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-06Add a new path-sensitive checker for functions in <string.h>, for both ↵Jordy Rose
null-terminated strings and memory blocks. Currently only checks memcpy(), memmove(), and bcopy(), but this is intended to be expanded soon. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@107722 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-06Sort CMake file.Ted Kremenek
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@107709 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-06Added a path-sensitive idempotent operation checker ↵Tom Care
(-analyzer-idempotent-operation). Finds idempotent and/or tautological operations in a path sensitive context, flagging operations that have no effect or a predictable effect. Example: { int a = 1; int b = 5; int c = b / a; // a is 1 on all paths } - New IdempotentOperationChecker class - Moved recursive Stmt functions in r107675 to IdempotentOperationChecker - Minor refactoring of SVal to allow checking for any integer - Added command line option for check - Added basic test cases git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@107706 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-06Add an assertion.Zhongxing Xu
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@107645 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-06Remove the now-unused GRState::isEqual method. Instead of asking if an ↵Jordy Rose
expression equals a certain value, use SValuator::EvalEQ and GRState::Assume to see if it can, must, or must not equal that value. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@107638 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-06Improve NULL-checking for CFRetain/CFRelease. We now remember that the ↵Jordy Rose
argument was non-NULL, and we report where the null assumption came from (like AttrNonNullChecker already did). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@107633 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-05Support sizeof for VLA expressions (sizeof(someVLA)). sizeof(int[n]) still ↵Jordy Rose
unimplemented. A VLA region's sizeof value matches its extent. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@107611 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-05Track extents for VLAs.Jordy Rose
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@107603 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-04Add a new symbol type, SymbolExtent, to represent the extents of memory ↵Jordy Rose
regions that may not be known at compile-time (such as those created by malloc). This replaces the old setExtent/getExtent API on Store, which used the GRState's GDM to store SVals. Also adds a getKnownValue() method to SValuator, which gets the integer value of an SVal if it is known to only have one possible value. There are more places in the code that could be using this, but in general we want to be dealing entirely in SVals, so its usefulness is limited. The only visible functionality change is that extents are now honored for any DeclRegion, such as fields and Objective-C ivars, rather than just variables. This shows up in bounds-checking and cast-size-checking. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@107577 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-01Fix PR 7475 by enhancing the static analyzer to also invalidate bindings for ↵Ted Kremenek
non-static global variables when calling a function/method whose impact on global variables we cannot accurately estimate. This change introduces two new MemSpaceRegions that divide up the memory space of globals, and causes RegionStore and BasicStore to consult a binding to the NonStaticGlobalsMemSpaceRegion when lazily determining the value of a global. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@107423 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-01Add an ivar to SymbolReaper for the current statement, and then stop passing ↵Jordy Rose
the current statement around everywhere. Preparation for symbolic extents. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@107422 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-01ExplodedGraph never uses ASTContext, remove it.Zhongxing Xu
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@107388 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-30Correctly implement the CheckerVisit optimization introduced in r106884, but ↵Ted Kremenek
this time actually used the cached checker list when calling back to Checker visit methods. This reduces the analysis time for sqlite3.c by 8%. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@107259 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-30Pointers casted as integers still count as locations to SimpleSValuator, so ↵Jordy Rose
don't crash if we do a funny thing like ((int)ptr)&1. Fixes PR7527. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@107236 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-29Tweaker Checker::VisitEndAnalysis to have 'hasWorkRemaining' alsoTed Kremenek
be true if some paths were aborted because they exceeded the maximum loop unrolling count. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@107209 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-28llvm::errs() is non-buffered, so it doesn't need to be flushed.Dan Gohman
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@107012 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-28Pointer comparisons (and pointer-pointer subtraction). Basically filling in ↵Jordy Rose
SimpleSValuator::EvalBinOpLL(). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106992 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-27Implicitly compare symbolic expressions to zero when they're being used as ↵Jordy Rose
constraints. Part of PR7491. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106972 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-26Allow '__extension__' to be analyzed in a lvalue context.Ted Kremenek
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106964 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-25Relax assertion since non-pod C++ classes are not aggregates, but still can ↵Ted Kremenek
appear in this context. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106919 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-25When a constant size array is casted to another type, its length should be ↵Jordy Rose
scaled as well. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106911 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-25Add "checker caching" to GRExprEngine::CheckerVisit to progressively buildTed Kremenek
a winowed list of checkers that actually do something for a given StmtClass. As the number of checkers grows, this may potentially significantly reduce the number of checkers called at any one time. My own measurements show that for the ~20 registered Checker objects, only ~5 of them respond at any one time to a give statement. While this isn't a net performance win right now (there is a minor slowdown on sqlite.3) this improvement does greatly improve debugging when stepping through the checkers used to evaluate a given statement. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106884 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-25Fix -analyze-display-progress (once again), this time with an additional ↵Ted Kremenek
regression test. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106883 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-25Change RegionStoreManager::Retrieve to infer the type of a symbolic region ↵Tom Care
from the context when it is not already available. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106868 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-24Return null pointer instead of 'false' (fixes clang warning).Ted Kremenek
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106755 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-24Add check for illegal whence argument of fseek.Zhongxing Xu
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106742 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-24Should return stateNotNull.Zhongxing Xu
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106741 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-24Let StreamChecker::CheckNullStream() return a GRState after successful check.Zhongxing Xu
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106738 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-23Add 'VisitEndAnalysis' callback to Checker class. This callback is called ↵Ted Kremenek
by GRExprEngine when the worklist algorithm has terminated. This allows some checkers to do a post-analysis phase after all paths have been analyzed. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106689 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-23add comments.Zhongxing Xu
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106617 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-23add comments.Zhongxing Xu
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106616 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-22Correctly construct an ElementRegion for alloca() + pointer arithmetic. ↵Ted Kremenek
Fixes analyzer crash reported in PR 7450. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106609 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-22Type Type::isRealFloatingType() that vectors are not floating-pointDouglas Gregor
types, updating callers of both isFloatingType() and isRealFloatingType() accordingly. Caught at least one issue where we allowed one to declare a vector of vectors (!), along with cleaning up the standard-conversion logic for C++. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106595 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-22Don't assert on C++ casts that are currently not handled by the static analyzer.Ted Kremenek
Instead, halt the analysis of the current path, which is what we do in GRExprEngine::ProcessStmt for all other C++ constructs not currently handled by the analyzer. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106561 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-22Add a bunch of stream APIs to SteamChecker.Zhongxing Xu
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106530 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-21When folding additive operations, convert the values to the same type. When ↵Jordy Rose
assuming relationships, convert the integers to the same type as the symbol, at least for now. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106458 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-21If a nonnull argument evaluates to UnknownVal, don't warn (and don't crash).Jordy Rose
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106456 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-20Add braces to avoid an ambiguous else, fixing a GCC warning.Benjamin Kramer
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106403 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-20Adds analyzer support for idempotent and tautological binary operations such ↵Jordy Rose
as "a*0" and "a+0". This is not very powerful, but does make the analyzer look a little smarter than it actually is. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106402 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-20Casting to void* or any other pointer-to-sizeless type (e.g. function ↵Jordy Rose
pointers) causes a divide-by-zero error. Simple fix: check if the pointee type size is 0 and bail out early if it is. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106401 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-18Fold additive constants, and support comparsions of the form $sym+const1 <> ↵Jordy Rose
const2 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106339 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-18introduce a new CharSourceRange class, and enhance the diagnostics routinesChris Lattner
to use them instead of SourceRange. CharSourceRange is just a SourceRange plus a bool that indicates whether the range has the end character resolved or whether the end location is the start of the end token. While most of the compiler wants to think of ranges that have ends that are the start of the end token, the printf diagnostic stuff wants to highlight ranges within tokens. This is transparent to the diagnostic stuff. To start taking advantage of the new capabilities, you can do something like this: Diag(..) << CharSourceRange::getCharRange(Begin,End) git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106338 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-18Add null stream check for more APIs.Zhongxing Xu
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106274 91177308-0d34-0410-b5e6-96231b3b80d8