Граф коммитов

2402 Коммитов

Автор SHA1 Сообщение Дата
Benjamin Kramer a93d0f2806 Include pruning and general cleanup.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169095 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-01 17:12:56 +00:00
Benjamin Kramer 2fa67efeaf Pull the Attr iteration parts out of Attr.h, so including DeclBase.h doesn't pull in all the generated Attr code.
Required to pull some functions out of line, but this shouldn't have a perf impact.
No functionality change.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169092 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-01 15:09:41 +00:00
Ted Kremenek eba76a4379 Further reduce "-fsyntax-only -Wuninitialized" time on sqlite3.c by another 2.5% using intelligent pruning of blocks during the final reporting pass.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@168257 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-17 07:18:30 +00:00
Ted Kremenek c1602581f7 Switch -Wuninitialized to use a reverse-post order traversal as
an initial baseline for enqueued blocks, but use a simple DFS stack
for propagating changes quickly up back edges.

This provides a 3.5% reduction in -fsyntax-only time on sqlite3.c.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@168241 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-17 02:00:00 +00:00
Ted Kremenek 8f81acfa95 Fix bad CFG construction bug when handling C++ 'try' statements.
This code assigned the last created CFGBlock* to the variable 'Block',
which is a scratch variable which is null'ed out after a block is
completed.  By assigning the last created block to 'Block', we start
editing a completed block, inserting CFGStmts that should be in
another block.  This was the case with 'try'.  The test case that
showed this had a while loop inside a 'try', and the logic before
the while loop was being included as part of the "condition block"
for the loop.  This showed up as a bogus dead store, but could
have lots of implications.

Turns out this bug was replicated a few times within CFG.cpp, so
I went and fixed up those as well.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167788 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-13 00:12:13 +00:00
Anna Zaks fadcd5d5bb [analyzer] add LocationContext::inTopFrame() helper.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167351 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-03 02:54:16 +00:00
Ted Kremenek 507d106c75 Fix potential null deference in CFG printer.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165836 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-12 22:56:31 +00:00
Ted Kremenek 857f5681f5 Remove dead store.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165835 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-12 22:56:26 +00:00
Ted Kremenek 5dbd990d79 Conditionally use an integral cast for BodyFarm support for 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-12 00:18:19 +00:00
Ted Kremenek 48fa136150 Switch over to BodyFarm implementation of OSAtomicCompareAndSwap and
objc_atomicCompareAndSwap.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165743 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-11 20:58:18 +00:00
DeLesley Hutchins ef2388b10c Thread-safety analysis: allow attributes on constructors to refer to 'this'.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165339 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-05 22:38:19 +00:00
Lang Hames be9af12888 Add FP_CONTRACT support for clang.
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-10-02 04:45:10 +00:00
Benjamin Kramer da3d76b4cf Avoid malloc thrashing in the uninitialized value analysis.
- 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-28 16:44:29 +00:00
Ted Kremenek 81d18bf944 Add clarifying comment.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164557 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-24 21:17:14 +00:00
Ted Kremenek fcf8eba0c7 Experiment in BodyFarm of structuring AST creation calls in a hierarchy,
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-21 18:33:56 +00:00
Ted Kremenek b80e5bb7c7 Create helper method in BodyFarm for creating simple assignments.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164400 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-21 18:33:54 +00:00
Ted Kremenek 0b5c5e487b Add helper method in BodyFarm to create unary dereferences.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164399 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-21 18:33:52 +00:00
Ted Kremenek 9ba05cd2e2 Add helper method to BodyFarm for creating lvalue-to-rvalue conversions.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164397 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-21 18:13:27 +00:00
Ted Kremenek a6d62a10a6 Add helper method to BodyFarm for creatinging integral casts.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164396 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-21 18:13:23 +00:00
DeLesley Hutchins d2f3882991 Thread-safety analysis: better handling of unreachable blocks. Fixes a bug
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-21 17:57:00 +00:00
Ted Kremenek 016c33d7bb Use helper method to create DeclRefExprs in BodyFarm, hopefully allevating
them being correctly constructed.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164392 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-21 17:54:35 +00:00
Ted Kremenek 0a4c0988c2 Add some structuring comments. No functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164391 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-21 17:54:32 +00:00
Ted Kremenek cc85d217d3 Add faux-body support for dispatch_once().
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164348 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-21 00:52:24 +00:00
Ted Kremenek a43df95396 Implement faux-body-synthesis of well-known functions in the static analyzer 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-21 00:09:11 +00:00
DeLesley Hutchins 60ff198a22 Thread-safety analysis: fix bug where shared trylock was treated
as exclusive.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164332 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-20 23:14:43 +00:00
DeLesley Hutchins 186af2de86 Thread safety analysis: properly canonicalize calls to virtual methods within
lock expressions.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164324 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-20 22:18:02 +00:00
DeLesley Hutchins 2a237e03c4 Thread-safety analysis: Fix warning when EXCLUSIVE_LOCKS_REQUIRED
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-19 19:49:40 +00:00
DeLesley Hutchins 5b280f2835 Thread-safety analysis: fix ICE when EXCLUSIVE_LOCKS_REQUIRED or
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-19 19:18:29 +00:00
NAKAMURA Takumi e5b89ed6b5 clang/lib/Analysis/ObjCNoReturn.cpp: Fix [-Wnewline-eof]
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163775 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-13 05:53:17 +00:00
Jordan Rose 670941c28c Format strings: offer a fixit for Darwin's %D/%U/%O to ISO %d/%u/%o.
<rdar://problem/12061922>

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163772 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-13 02:11:15 +00:00
Jordan Rose 275b6f52c7 Format strings: %D, %U, and %O are valid on Darwin (same as %d, %u, %o).
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-13 02:11:03 +00:00
Ted Kremenek 25c1d57fc9 Teach -Wuninitialized to recognize common "noreturn" idioms in
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-13 00:21:35 +00:00
Ted Kremenek 4ef19205b6 Refactor logic in ExprEngine for detecting 'noreturn' methods
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-13 00:21:31 +00:00
Ted Kremenek 44ca53f34d Teach -Wuninitialized to recognize __attribute__((analyzer_noreturn))
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-12 05:53:43 +00:00
DeLesley Hutchins f9ee0bacd2 Thread-safety analysis: fix bug in expression matching code.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163656 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-11 23:04:49 +00:00
Dmitri Gribenko 1ad23d6200 Remove redundant semicolons which are null statements.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163546 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-10 21:20:09 +00:00
DeLesley Hutchins 3f0ec52097 Thread-safety analysis: differentiate between two forms of analysis; a precise
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-10 19:58:23 +00:00
Jordan Rose 8be066e673 Format strings: suggest %lld instead of %qd and %Ld with -Wformat-non-iso.
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-08 04:00:12 +00:00
Jordan Rose bbb6bb4952 Format strings: %Ld isn't available on Darwin or Windows.
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-08 04:00:03 +00:00
Chad Rosier 589190b322 Ampersand goes with identifier.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163410 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-07 19:49:55 +00:00
Chad Rosier 2de4770ec0 Bring buildbots back. Fix scoping issue and coding style from r163397.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163403 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-07 18:44:15 +00:00
DeLesley Hutchins 0b4db3e08a Thread-safety analysis: Add support for selectively turning off warnings
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-07 17:34:53 +00:00
Roman Divacky 31ba613537 Dont cast away const needlessly. Found by gcc48 -Wcast-qual.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163325 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-06 15:59:27 +00:00
Jordan Rose 5a1ffe98b0 [analyzer] Always include destructors in the analysis CFG.
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-05 22:55:23 +00:00
DeLesley Hutchins fd0f11ccd5 Thread-safety analysis: bugfix for case where a trylock occurs in an
expression involving temporaries.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163237 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-05 20:01:16 +00:00
DeLesley Hutchins 5408153e91 Thread-safety analysis: fix handling of LOCK_RETURNED attribute so that the
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-31 22:09:53 +00:00
DeLesley Hutchins 4e4c15765d Thread-safety analysis: fix handling of string constants in mutex
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-31 21:57:32 +00:00
Ted Kremenek 3d1125b27e Teach CFG that 'if (x & 0)' and 'if (x * 0)' is an unfeasible branch.
Fixes <rdar://problem/11005770>.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@162545 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-24 07:42:09 +00:00
Jordan Rose b66529d047 [analyzer] Support C++ default arguments if they are literal values.
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-23 18:10:53 +00:00
Ted Kremenek ad0fe03b89 Fix an assortment of doxygen comment issues found by -Wdocumentation.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@162412 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-22 23:50:41 +00:00