Commit Graph

20605 Commits

Author SHA1 Message Date
David Chisnall 51ed0d112b Fix typo so we don't use the wrong function for ending ObjC++ catch blocks (GNU runtimes)
llvm-svn: 137052
2011-08-08 17:26:06 +00:00
Chad Rosier 261f9ce371 Improved efficiency by using iterator returned by erase, rather then restarting.
Thanks to David Blaikie for pointing this out.

llvm-svn: 137051
2011-08-08 17:17:15 +00:00
Craig Topper 61147ed270 Fix comment (test commit)
llvm-svn: 137039
2011-08-08 06:10:39 +00:00
John McCall 45e429524b Avoid fallthrough-branching to an inactive cleanup even if it's
otherwise required.

llvm-svn: 137029
2011-08-07 07:05:57 +00:00
Alexis Hunt 7d1492a99d Add a __has_feature macro for generalized initializers, turned off
because we don't support them yet.

llvm-svn: 137027
2011-08-07 00:34:32 +00:00
John McCall 5939b16135 Do l-value conversion, etc., on a switch condition expression in
ActOnStartOfSwitchStmt (i.e. before binding up a full-expression)
instead of ActOnFinishSwitchStmt.

Among other things, this means that property l-values are properly
converted inside the full-expression.

llvm-svn: 137014
2011-08-06 07:30:58 +00:00
Ted Kremenek 54d456758e [analyzer] Start sketching out a new BugReporterVisitor that inspects branches and other expressions to generate interesting path events in diagnostics.
llvm-svn: 137012
2011-08-06 06:54:45 +00:00
John McCall f82bdf6dd1 Be sure to destroy the normal entry block of a cleanup that we
aren't actually going to make a normal cleanup for.  Sometimes
we optimistically create branches to such blocks for fixups,
and then we resolve the fixup to somewhere within the cleanup's
scope, and then the cleanup is actually not reachable for some
reason.  The process of resolving the fixup leaves us with
switches whose default edge leads to the cleanup;  we can
replace that with unreachable, then (in many cases) turn
the switch into an unconditional branch.

Fixes PR10467.

llvm-svn: 137011
2011-08-06 06:53:52 +00:00
Benjamin Kramer 8c54367935 Only look at decls after the current one when checking if it's the last field in a record.
llvm-svn: 137009
2011-08-06 03:04:42 +00:00
Ted Kremenek 84a1ca5280 [analyzer] Simplify logic for ExprEngine::VisitUnaryExprOrTypeTraitExpr to avoid recursion to subexpression.
This exposed bugs in the live variables analysis, and a latent analyzer bug in the SymbolReaper.

llvm-svn: 137006
2011-08-06 00:30:00 +00:00
Ted Kremenek c91ca30b4c [analyzer] Change SymbolReaper to store region roots implied by the Environment, allowing it be queried when
determining if symbols derived from regions are still live.

llvm-svn: 137005
2011-08-06 00:29:57 +00:00
Anna Zaks 177ecfac21 KeychainAPI checker: Track SymbolMetadata instead of MemRegion in checker state so that we could clear the state on evalDeadSymbols; also track the return value.
llvm-svn: 137003
2011-08-05 23:52:45 +00:00
Ted Kremenek 1cd34b8fea Revert 136984 and 136927.
llvm-svn: 136998
2011-08-05 23:31:22 +00:00
Kaelyn Uhrain 2e7aa5ae1f Perform array bounds checking in more situations and properly handle special
case situations with the unary operators & and *. Also extend the array bounds
checking to work with pointer arithmetic; the pointer arithemtic checking can
be turned on using -Warray-bounds-pointer-arithmetic.

The changes to where CheckArrayAccess gets called is based on some trial &
error and a bunch of digging through source code and gdb backtraces in order
to have the check performed under as many situations as possible (such as for
variable initializers, arguments to function calls, and within conditional in
addition to the simpler cases of the operands to binary and unary operator)
while not being called--and triggering warnings--more than once for a given
ArraySubscriptExpr.

llvm-svn: 136997
2011-08-05 23:18:04 +00:00
Jonathan D. Turner f07f131c94 Add workaround for built va list (and other builtins) so that running ReadAST multiple times does not immediately throw an error.
llvm-svn: 136995
2011-08-05 23:07:10 +00:00
Chad Rosier e1a6a0e05c Add support for using anonymous bitfields (e.g., int : 0) to enforce alignment.
This fixes cases where the anonymous bitfield is followed by a bitfield member.
E.g.,
struct t4
{
 char foo;
 long : 0;
 char bar : 1;
};

rdar://9859156

llvm-svn: 136991
2011-08-05 22:38:04 +00:00
Jonathan D. Turner 0248f57d59 Wire up -import-module to run ReadAST for each module loaded.
llvm-svn: 136987
2011-08-05 22:17:03 +00:00
Roman Divacky 30097b7c41 Let attribute((cdecl)) and company override -mrtd default calling convention.
llvm-svn: 136971
2011-08-05 16:37:22 +00:00
Chandler Carruth 28389f0cdf Flesh out the -Warray-bounds detection of C89 tail-padded one-element
arrays. This now suppresses the warning only in the case of
a one-element array as the last field in a struct where the array size
is a literal '1' rather than any macro expansion or template parameter.

This doesn't distinguish between the language standard in use to allow
code which dates from C89 era to compile without the warning even in C99
and C++ builds. We could add a separate warning (under a different flag)
with fixit hints to switch to a flexible array, but its not clear that
this would be desirable. Much of the code using this idiom is striving
for maximum portability.

Tests were also fleshed out a bit, and the diagnostic itself tweaked to
be more pretty w.r.t. single elment arrays. This is more ugly than
I would like due to APInt's not being supported by the diagnostic
rendering engine.

A pseudo-patch for this was proposed by Nicola Gigante, but I reworked
it both for several correctness issues and for code style.

Sorry this was so long in coming.

llvm-svn: 136965
2011-08-05 09:10:50 +00:00
Chandler Carruth 126b155429 Finally getting around to re-working this to more accurately white-list
1-element character arrays which are serving as flexible arrays. This is
the initial step, which is to restrict the 1-element array whitelist to
arrays that are member declarations. I'll refine it from here based on
the proposed patch.

llvm-svn: 136964
2011-08-05 08:07:29 +00:00
Abramo Bagnara ff371acaa4 Fixed FieldDecl source range.
llvm-svn: 136963
2011-08-05 08:02:55 +00:00
Anna Zaks c52bed1814 KeychainAPI checker: Generate an error on double allocation. Pull out getAsPointeeMemoryRegion so that it could be reused.
llvm-svn: 136952
2011-08-05 00:37:00 +00:00
Matt Beaumont-Gay 3c48990a46 Extend memset/memcpy/memmove checking to include memcmp
llvm-svn: 136950
2011-08-05 00:22:34 +00:00
John McCall 91e82dd477 The continue label in an ARC for-in loop should not involve
releasing the collection.

llvm-svn: 136949
2011-08-05 00:14:38 +00:00
Kaelyn Uhrain 4283092a4b Have the typo correction in DiagnoseEmptyLookup properly handle template
functions when performing function overload resolution.

llvm-svn: 136948
2011-08-05 00:09:52 +00:00
Fariborz Jahanian 9e7dbd1cc6 objc rewriter: Fixes a rewriting of implicit casting of an integral
argument to bool. // rdar://9899834

llvm-svn: 136946
2011-08-04 23:58:03 +00:00
Chad Rosier f01a7ddcd6 More whitespace and naming fixup. No functionality change.
llvm-svn: 136944
2011-08-04 23:34:15 +00:00
Kaelyn Uhrain ea350180d2 Fix a small bug where DiagnoseEmptyLookup would no longer print any messages
when performing typo correction involving any overloaded template functions.

The added test cases, while currently demontrating sub-optimal behavior, will
not trigger any messages without the 1-line change to SemaExpr.cpp.

llvm-svn: 136943
2011-08-04 23:30:54 +00:00
Matt Beaumont-Gay a17cf6330f Specialize diag::warn_unused_call for the "warn_unused_result" attribute, so
it can be controlled with a distinct flag.

llvm-svn: 136941
2011-08-04 23:11:04 +00:00
Ted Kremenek 75842e4946 Fix assertion failure in -Wuninitialized involving no-op casts. Fixes PR 10577.
llvm-svn: 136939
2011-08-04 22:40:57 +00:00
Anna Zaks c686177555 KeychainAPI checker: Track additional pair of SecKeychain APIs. Also, keep exploring the transition on which a call to allocator function failed (to be able to find errors in examples like ErrorCodesFromDifferentAPISDoNotInterfere).
llvm-svn: 136930
2011-08-04 21:53:01 +00:00
Chad Rosier b43c21a1e2 Whitespace.
llvm-svn: 136929
2011-08-04 21:50:29 +00:00
Fariborz Jahanian 6a86844161 objective-c: diagnose protocol inconsistencies in following
situation. When a class explicitly or implicitly (through inheritance) 
"conformsTo" two protocols which conflict (have methods which conflict).
This is 2nd part of // rdar://6191214.

llvm-svn: 136927
2011-08-04 21:28:44 +00:00
Douglas Gregor 3f35bb2d15 Add a new libclang API to return a CXCompletionString for an arbitrary
cursor, from Connor Wakamo! Addresses <rdar://problem/9087798>.

llvm-svn: 136911
2011-08-04 20:04:59 +00:00
Chad Rosier 64b18eebc6 Fix style and remove obviously redundant code.
llvm-svn: 136907
2011-08-04 19:25:14 +00:00
Douglas Gregor fddf530c5d Clean up the debug dump for a Module, so the local->global maps are
clearly called out, and add the missing local -> global selector map
output.

llvm-svn: 136903
2011-08-04 19:00:50 +00:00
Douglas Gregor 2f555fc415 Introduce local -> global mapping for preprocessed entity IDs. This is
the last of the ID/offset/index mappings that I know
of. Unfortunately, the "gap" method of testing doesn't work here due
to the way the preprocessing record performs iteration. We'll do more
testing once multi-AST loading is possible.

llvm-svn: 136902
2011-08-04 18:56:47 +00:00
Douglas Gregor 7cb0d01dcd Remove the unset, unused return value of
ASTReader::ReadMacroRecord(). No functionality change.

llvm-svn: 136893
2011-08-04 18:09:14 +00:00
Chad Rosier a336c6f380 Additional comments and whitespace.
llvm-svn: 136892
2011-08-04 17:52:43 +00:00
Kaelyn Uhrain 7d9bc633d2 Match type names and give more info for out-of-line function definition errors.
Having a function declaration and definition with different types for a
parameter where the types have same (textual) name can occur when an unqualified
type name resolves to types in different namespaces in each location.

The error messages have been extended by adding notes that point to the first
parameter of the function definition that doesn't match the declaration, instead
of a generic "member declaration nearly matches". The generic message is still
used in cases where the mismatch is not in the paramenter list, such as
mismatched cv qualifiers on the member function itself.

llvm-svn: 136891
2011-08-04 17:40:00 +00:00
Anna Zaks 08be9b99e3 KeychainAPI checker: Refactor to make it easier to add more allocator/deallocator API pairs. Add the allocator function ID to the checker state. Better comments.
llvm-svn: 136889
2011-08-04 17:28:06 +00:00
Douglas Gregor 0d4b431e2c In the AST reader and writer, slide the preprocessed entity IDs by +1
so that we use ID zero as a sentinel for "no result". This matches the
convention set by all of the other global IDs.

llvm-svn: 136885
2011-08-04 17:06:18 +00:00
Douglas Gregor 78d0b57d88 Add some missing record names to the AST output. No functionality change, but llvm-bcanalyzer will be a little more informative now for AST files
llvm-svn: 136883
2011-08-04 16:39:39 +00:00
Douglas Gregor a863b4b4e3 Implement the local -> global remapping for macro definition IDs in
the detailed preprocessing record. Tested with the standard "gaps" method.

llvm-svn: 136882
2011-08-04 16:36:56 +00:00
Douglas Gregor 49b236a705 The AST reader was forgetting to parse ObjCInferRelatedReturnType
llvm-svn: 136879
2011-08-04 15:46:00 +00:00
Douglas Gregor db0b9f1264 Parsing of C++0x lambda expressions, from John Freeman with help from
David Blaikie!

llvm-svn: 136876
2011-08-04 15:30:47 +00:00
Chad Rosier 18903ee2d3 Add partial support for using anonymous bitfields (e.g., int : 0) to enforce
alignment.  This fixes cases where the anonymous bitfield is followed by a 
non-bitfield member.  E.g.,

struct t4
{
  int foo : 1;
  long : 0;
  char bar;
};

Part of rdar://9859156

llvm-svn: 136858
2011-08-04 01:21:14 +00:00
John McCall 9b24df470d Emit wide string literals with the appropriate alignment.
Patch by Craig Topper and Sundeep!

llvm-svn: 136856
2011-08-04 01:03:22 +00:00
Anna Zaks 4aa34a5325 KeychainAPI checker: refactor to use early exit.
llvm-svn: 136852
2011-08-04 00:31:38 +00:00
Anna Zaks 388c18ec7f KeychainAPI checker: Add basic diagnostics. Track MemoryRegion istead of SymbolicRef since the address might not be a symbolic value in some cases, for example in fooOnlyFree() test.
llvm-svn: 136851
2011-08-04 00:26:57 +00:00