aboutsummaryrefslogtreecommitdiff
path: root/lib/Analysis
AgeCommit message (Collapse)Author
2012-10-12Conditionally use an integral cast for BodyFarm support for ↵Ted Kremenek
OSAtomicCompareAndSwap if the return type is not a boolean. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165774 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-11Switch over to BodyFarm implementation of OSAtomicCompareAndSwap andTed Kremenek
objc_atomicCompareAndSwap. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165743 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-05Thread-safety analysis: allow attributes on constructors to refer to 'this'.DeLesley Hutchins
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165339 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-02Add FP_CONTRACT support for clang.Lang Hames
Clang will now honor the FP_CONTRACT pragma and emit LLVM fmuladd intrinsics for expressions of the form A * B + C (when they occur in a single statement). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164989 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-28Avoid malloc thrashing in the uninitialized value analysis.Benjamin Kramer
- The size of the packed vector is often small, save mallocs using SmallBitVector. - Copying SmallBitVectors is also cheap, remove a level of indirection. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164827 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-24Add clarifying comment.Ted Kremenek
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164557 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-21Experiment in BodyFarm of structuring AST creation calls in a hierarchy,Ted Kremenek
so that they visually look like an AST dump. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164401 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-21Create helper method in BodyFarm for creating simple assignments.Ted Kremenek
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164400 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-21Add helper method in BodyFarm to create unary dereferences.Ted Kremenek
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164399 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-21Add helper method to BodyFarm for creating lvalue-to-rvalue conversions.Ted Kremenek
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164397 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-21Add helper method to BodyFarm for creatinging integral casts.Ted Kremenek
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164396 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-21Thread-safety analysis: better handling of unreachable blocks. Fixes a bugDeLesley Hutchins
where a call to function marked 'noreturn' is followed by unreachable implicit destructor calls. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164394 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-21Use helper method to create DeclRefExprs in BodyFarm, hopefully allevatingTed Kremenek
them being correctly constructed. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164392 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-21Add some structuring comments. No functionality change.Ted Kremenek
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164391 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-21Add faux-body support for dispatch_once().Ted Kremenek
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164348 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-21Implement faux-body-synthesis of well-known functions in the static analyzer ↵Ted Kremenek
when their implementations are unavailable. Start by simulating dispatch_sync(). This change is largely a bunch of plumbing around something very simple. We use AnalysisDeclContext to conjure up a fake function body (using the current ASTContext) when one does not exist. This is controlled under the analyzer-config option "faux-bodies", which is off by default. The plumbing in this patch is largely to pass the necessary machinery around. CallEvent needs the AnalysisDeclContextManager to get the function definition, as one may get conjured up lazily. BugReporter and PathDiagnosticLocation needed to be relaxed to handle invalid locations, as the conjured body has no real source locations. We do some primitive recovery in diagnostic generation to generate some reasonable locations (for arrows and events), but it can be improved. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164339 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-20Thread-safety analysis: fix bug where shared trylock was treatedDeLesley Hutchins
as exclusive. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164332 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-20Thread safety analysis: properly canonicalize calls to virtual methods withinDeLesley Hutchins
lock expressions. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164324 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-19Thread-safety analysis: Fix warning when EXCLUSIVE_LOCKS_REQUIREDDeLesley Hutchins
is placed on a function that has no path to the exit block. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164244 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-19Thread-safety analysis: fix ICE when EXCLUSIVE_LOCKS_REQUIRED orDeLesley Hutchins
LOCKS_EXCLUDED is used on a method with a name that is is not a simple identifier. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164242 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-13clang/lib/Analysis/ObjCNoReturn.cpp: Fix [-Wnewline-eof]NAKAMURA Takumi
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163775 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-13Format strings: offer a fixit for Darwin's %D/%U/%O to ISO %d/%u/%o.Jordan Rose
<rdar://problem/12061922> git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163772 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-13Format strings: %D, %U, and %O are valid on Darwin (same as %d, %u, %o).Jordan Rose
These will warn under -Wformat-non-iso, and will still be rejected outright on other platforms. <rdar://problem/12061922> git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163771 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-13Teach -Wuninitialized to recognize common "noreturn" idioms inTed Kremenek
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163760 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-13Refactor logic in ExprEngine for detecting 'noreturn' methodsTed Kremenek
in NSException to a helper object in libAnalysis that can also be used by Sema. Not sure if the predicate name 'isImplicitNoReturn' is the best one, but we can massage that later. No functionality change. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163759 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-12Teach -Wuninitialized to recognize __attribute__((analyzer_noreturn))Ted Kremenek
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>. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163681 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-11Thread-safety analysis: fix bug in expression matching code.DeLesley Hutchins
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163656 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-10Remove redundant semicolons which are null statements.Dmitri Gribenko
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163546 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-10Thread-safety analysis: differentiate between two forms of analysis; a preciseDeLesley Hutchins
analysis that may give false positives because it is confused by aliasing, and a less precise analysis that has fewer false positives, but may have false negatives. The more precise warnings are enabled by -Wthread-safety-precise. An additional note clarify the warnings in the precise case. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163537 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-08Format strings: suggest %lld instead of %qd and %Ld with -Wformat-non-iso.Jordan Rose
As a corollary to the previous commit, even when an extension is available, we can still offer a fixit to the standard modifier. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163453 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-08Format strings: %Ld isn't available on Darwin or Windows.Jordan Rose
This seems to be a GNU libc extension; we offer a fixit to %lld on these platforms. <rdar://problem/11518237> git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163452 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-07Ampersand goes with identifier.Chad Rosier
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163410 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-07Bring buildbots back. Fix scoping issue and coding style from r163397.Chad Rosier
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163403 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-07Thread-safety analysis: Add support for selectively turning off warningsDeLesley Hutchins
within part of a particular method. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163397 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-06Dont cast away const needlessly. Found by gcc48 -Wcast-qual.Roman Divacky
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163325 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-05[analyzer] Always include destructors in the analysis CFG.Jordan Rose
While destructors will continue to not be inlined (unless the analyzer config option 'c++-inlining' is set to 'destructors'), leaving them out of the CFG is an incomplete model of the behavior of an object, and can cause false positive warnings (like PR13751, now working). Destructors for temporaries are still not on by default, since (a) we haven't actually checked this code to be sure it's fully correct (in particular, we probably need to be very careful with regard to lifetime-extension when a temporary is bound to a reference, C++11 [class.temporary]p5), and (b) ExprEngine doesn't actually do anything when it sees a temporary destructor in the CFG -- not even invalidate the object region. To enable temporary destructors, set the 'cfg-temporary-dtors' analyzer config option to '1'. The old -cfg-add-implicit-dtors cc1 option, which controlled all implicit destructors, has been removed. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163264 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-05Thread-safety analysis: bugfix for case where a trylock occurs in anDeLesley Hutchins
expression involving temporaries. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163237 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-31Thread-safety analysis: fix handling of LOCK_RETURNED attribute so that theDeLesley Hutchins
latest definition of a function is always used when computing lock expressions. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163028 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-31Thread-safety analysis: fix handling of string constants in mutexDeLesley Hutchins
expressions, which should be ignored right now. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163026 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-24Teach CFG that 'if (x & 0)' and 'if (x * 0)' is an unfeasible branch.Ted Kremenek
Fixes <rdar://problem/11005770>. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@162545 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-23[analyzer] Support C++ default arguments if they are literal values.Jordan Rose
A CXXDefaultArgExpr wraps an Expr owned by a ParmVarDecl belonging to the called function. In general, ExprEngine and Environment ought to treat this like a ParenExpr or other transparent wrapper expression, with the inside expression evaluated first. However, if we call the same function twice, we'd produce a CFG that contains the same wrapped expression twice, and we're not set up to handle that. I've added a FIXME to the CFG builder to come back to that, but meanwhile we can at least handle expressions that don't need to be explicitly evaluated: literals. This probably handles many common uses of default parameters: true/false, null, etc. Part of PR13385 / <rdar://problem/12156507> git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@162453 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-22Fix an assortment of doxygen comment issues found by -Wdocumentation.Ted Kremenek
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@162412 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-22Rename 'currentX' to 'currX' throughout analyzer and libAnalysis.Ted Kremenek
Also rename 'getCurrentBlockCounter()' to 'blockCount()'. This ripples a bunch of code simplifications; mostly aesthetic, but makes the code a bit tighter. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@162349 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-14[analyzer] Teach live variable analyzes that super uses self pointer.Anna Zaks
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161822 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-10Thread-safety-analysis: adds existential quantification over lockDeLesley Hutchins
expressions. The syntax &MyClass::mutex is interpreted as a pattern that matches m->mutex for any object m of type MyClass. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161691 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-10Thread safety analysis: refactor to support more sophisticated handlingDeLesley Hutchins
of expressions, and better error messages. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161690 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-10Refactor thread safety analysis to use a different data structureDeLesley Hutchins
to track locksets. This is in preparation for further changes. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161680 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-10Add missing cctype includes.Joerg Sonnenberger
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161660 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-07Properly check length modfiers for %n in format strings.Hans Wennborg
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161408 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-07Remove ScanfArgType and bake that logic into ArgType.Hans Wennborg
This is useful for example for %n in printf, which expects a pointer to int with the same logic for checking as %d would have in scanf. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161407 91177308-0d34-0410-b5e6-96231b3b80d8