Commit Graph

1687 Commits

Author SHA1 Message Date
Nico Weber 7c29980d20 Let -Warray-bounds handle casted array types without false positives.
Fixes PR10771.

llvm-svn: 139990
2011-09-17 22:59:41 +00:00
Francois Pichet 2f55019bf0 In Microsoft mode, warn if an indirect goto jump over a variable initialization.
Also add a test case for the non Microsoft case because such test didn't exist.

llvm-svn: 139971
2011-09-16 23:15:32 +00:00
Eli Friedman 0d3d70a074 Remove standard library includes from test; they explode on Windows.
llvm-svn: 139875
2011-09-15 23:24:35 +00:00
Caitlin Sadowski 2d910ba1e5 Thread safety: changing naming in error messages based on reviewer comments
llvm-svn: 139814
2011-09-15 18:13:32 +00:00
Caitlin Sadowski cfef95eec6 Thread safety: test cases originally from gcc annotalysis branch. We are
relicensing them under the license for llvm.

llvm-svn: 139812
2011-09-15 18:07:32 +00:00
Caitlin Sadowski 6525fb25cb Thread safety: completeing the implementation of shared/exclusive locks required attributes
llvm-svn: 139804
2011-09-15 17:43:08 +00:00
Caitlin Sadowski af9b7c5f8b Thread safety: refactoring various out of scope warnings to use the same inteface. This eliminates a lot of unnecessary duplicated code.
llvm-svn: 139801
2011-09-15 17:25:19 +00:00
Caitlin Sadowski e50d8c3415 Thread safety: reverting to use separate warning for requirement to hold any lock
llvm-svn: 139723
2011-09-14 20:09:09 +00:00
Caitlin Sadowski 787c2a1b09 Thread safety: adding test cases for unparseable lock expressions and expanding the handling of these expressions
llvm-svn: 139720
2011-09-14 20:00:24 +00:00
Kaelyn Uhrain 7fbe2f78d7 Plug an abstraction leak and fix a crasher in DiagnoseInvalidRedeclaration
llvm-svn: 139718
2011-09-14 19:37:32 +00:00
Kaelyn Uhrain 858fb61d22 Split the two invalid uses of the unqualified Foobar at line 3 to two lines
so that it is clearer which use triggered which error.

llvm-svn: 139653
2011-09-13 22:31:32 +00:00
Francois Pichet 051f5e5cba In Microsoft mode, downgrade "goto into protected scope" from error to warning if we are jumping over a variable initialization via a goto.
This fixes a few errors when parsing MFC code with clang.

llvm-svn: 139595
2011-09-13 10:26:51 +00:00
Chandler Carruth ad74725ab5 Enhance the CFG construction to detect no-return destructors for
temporary objects and local variables. When detected, these split the
block, marking the new one as having only the exit block as a successor.
This prevents a large number of false positives in warnings sensitive to
no-return constructs such as -Wreturn-type, and fixes the remainder of
PR10063 along with several variations of this bug that had not been
reported. The test cases are extended across the board to cover these
patterns.

This also checks in a stress test for these types of CFGs. The stress
test declares some 32k variables, a mixture of no-return and normal
destructors. Previously, this resulted in roughly 2500 CFG blocks, but
didn't model any of the no-return destructors. With this patch, it
results in over 33k blocks, many of them now unreachable.

The nice thing about how the analyzer is set up? This causes *no*
regression in performance of building the CFG. It actually in some cases
makes it faster, as best I can benchmark. The analysis for -Wreturn-type
(and any other that cares about no-return code paths) is technically
slower now as it has to look at many more candidate blocks, but it
computes the correct answer. I have more test cases to follow, I think
they all work now. Also I have further work that should dramatically
simplify analyses in the presence of no-return.

llvm-svn: 139586
2011-09-13 06:09:01 +00:00
David Blaikie f1e2924b6b Correctly referring to the null pointer as 'null' not the macro 'NULL' in the boolean conversion diagnostic message.
llvm-svn: 139465
2011-09-10 05:47:59 +00:00
David Blaikie e5f9a9e603 Show either a location or a fixit note, not both, for uninitialized variable warnings.
llvm-svn: 139463
2011-09-10 05:35:08 +00:00
Chandler Carruth a626d645d5 Extend the Stmt AST to make it easier to look through label, default,
and case statements. Use this to make the logic in the CFG builder more
robust at finding the actual statements within a compound statement,
even when there are many layers of labels obscuring it.

Also extend the test cases for a large chunk of PR10063. Still more work
to do here though.

llvm-svn: 139437
2011-09-10 00:02:34 +00:00
Caitlin Sadowski ff2f3f8105 Thread safety: This patch deals with previously unhandled cases when building lock expressions. We now resolve this expressions, avoid crashing when encountering cast expressions, and have a diagnostic for unresolved lock expressions
llvm-svn: 139370
2011-09-09 16:21:55 +00:00
Caitlin Sadowski a2fd6e0473 Thread safety: refactoring test cases
llvm-svn: 139368
2011-09-09 16:07:55 +00:00
Matt Beaumont-Gay 042ce8e9d8 Extend -Wliteral-conversion to catch "int i = -1.234"
llvm-svn: 139326
2011-09-08 22:30:47 +00:00
Caitlin Sadowski ee5db8b5c4 Thread Safety: In C++0x Mutexes are the objects that control access to shared variables, while Locks are the objects that acquire and release Mutexes. We switch to this new terminology.
llvm-svn: 139321
2011-09-08 21:52:50 +00:00
Caitlin Sadowski 2d3f70ac1c Thread Safety: adding basic no thread safety analysis option
llvm-svn: 139310
2011-09-08 18:35:21 +00:00
Caitlin Sadowski 69b367af17 Thread safety: Adding basic support for locks required and excluded attributes
llvm-svn: 139308
2011-09-08 18:27:31 +00:00
Caitlin Sadowski 46b057681a Thread safety: shared vs. exclusive locks
llvm-svn: 139307
2011-09-08 18:19:38 +00:00
Caitlin Sadowski bc1f11162a Thread safety: small formatting change in test comments
llvm-svn: 139306
2011-09-08 18:07:26 +00:00
Caitlin Sadowski 990d571226 Thread safety: added support for function scopes in attribute arguments.
This patch was written by DeLesley Hutchins.

llvm-svn: 139302
2011-09-08 17:42:31 +00:00
Caitlin Sadowski 9385dd7415 Thread Safety: Patch to implement delayed parsing of attributes within a
class scope.

This patch was also written by DeLesley Hutchins.

llvm-svn: 139301
2011-09-08 17:42:22 +00:00
Douglas Gregor 5ca153f112 When parsing a function-try-block that does not have a
ctor-initializer, remember to call the Sema action to generate default
ctor-initializers. What a delightful little miscompile. Fixes PR10578
/ <rdar://problem/9877267>.

llvm-svn: 139253
2011-09-07 20:36:12 +00:00
Kaelyn Uhrain 5a43b461fc Fix Sema::CorrectTypo to ignore found but unresolved symbols
llvm-svn: 139252
2011-09-07 20:25:59 +00:00
Richard Trieu aa5e256c20 Change the self-reference visitor (which gives the warning for self-reference oninitalization warning of -Wuninitialized) to exclude member variables that can decay into pointers. This will cause it to no longer warn on this code:
struct foo { char a[100], *e; } bar = { .e = bar.a };

llvm-svn: 139213
2011-09-07 00:58:53 +00:00
Ted Kremenek 99c0966fc4 Place 'equality comparison with extraneous parentheses...' into a subgroup of -Wparentheses called -Wparentheses-equality.
llvm-svn: 139180
2011-09-06 20:58:32 +00:00
Richard Smith a8a5c402bb Advertise support for cxx_range_for as an extension in C++98 mode. Patch by Jean-Daniel Dupas!
Also provide a modicum of test coverage for ranged for in C++98.

llvm-svn: 139149
2011-09-06 18:03:41 +00:00
Richard Smith a528507418 Implement the suggested resolution of WG21 N3307 issue 19: When determining whether a class is an aggregate in C++0x, treat all functions which are neither deleted nor defaulted as user-provided, not just special member functions. The wording of the standard only defines the term "user-provided" for special member functions, but the intent seems to be that any function can be user-provided.
llvm-svn: 139111
2011-09-05 02:13:09 +00:00
Richard Smith 58c7433709 PR10458: Finesse behaviour of C++0x features when in pre-0x mode. Accept for-range and auto with an ExtWarn, and produce a -Wc++0x-compat warning in C++98 mode when auto is used as a storage class.
llvm-svn: 139102
2011-09-04 19:54:14 +00:00
Chandler Carruth d551d4e1da Teach -Wdangling-field to warn about temporaries bound to references as
well.

Also, clean up the flow of the code a bit, and factor things more
nicely.

Finally, add the test case that was missing from my previous
commit (sorry), with new tests added to cover temporaries and other fun
cases.

llvm-svn: 139077
2011-09-03 02:21:57 +00:00
Richard Trieu a04ad1a1b9 Extend the self-reference warning to catch when a constructor references itself upon initialization, such as using itself within its own copy constructor.
struct S {};
S s(s);

llvm-svn: 138969
2011-09-01 21:44:13 +00:00
Chandler Carruth c841b6e598 Improve the diagnostic text for -Wmissing-noreturn to include the name
of the function in question when applicable (that is, not for blocks).
Patch by Joerg Sonnenberger with some stylistic tweaks by me.

When discussing this weth Joerg, streaming the decl directly into the
diagnostic didn't work because we have a pointer-to-const, and the
overload doesn't accept such. In order to make my style tweaks to the
patch, I first changed the overload to accept a pointer-to-const, and
then changed the diagnostic printing layer to also use
a pointer-to-const, cleaning up a gross line of code along the way.

llvm-svn: 138854
2011-08-31 09:01:53 +00:00
Douglas Gregor 86325ad2b5 Allow C99 hexfloats in C++0x mode. This change resolves the standards
collision between C99 hexfloats and C++0x user-defined literals by
giving C99 hexfloats precedence. Also, warning about user-defined
literals that conflict with hexfloats and those that have names that
are reserved by the implementation. Fixes <rdar://problem/9940194>.

llvm-svn: 138839
2011-08-30 22:40:35 +00:00
Sebastian Redl 22653bac1a Declare and define implicit move constructor and assignment operator.
This makes the code duplication of implicit special member handling even worse,
but the cleanup will have to come later. For now, this works.
Follow-up with tests for explicit defaulting and enabling the __has_feature
flag to come.

llvm-svn: 138821
2011-08-30 19:58:05 +00:00
Caitlin Sadowski dd5fd87a6d Thread safety: added basic handling for pt_guarded_by/var and guarded_by/var annotations. We identify situations where we are accessing (reading or writing) guarded variables, and report an error if the appropriate locks are not held.
llvm-svn: 138774
2011-08-29 22:27:51 +00:00
Caitlin Sadowski 293d24a5ba Thread safety: various minor bugfixes, with test cases
This patch is by DeLesley Hutchins.

llvm-svn: 138738
2011-08-29 17:12:27 +00:00
Eli Friedman 79b2d3a4d4 Make sure we don't crash printing builtin candidates for overloads of deleted operators. Fixes PR10757.
llvm-svn: 138645
2011-08-26 19:46:22 +00:00
Caitlin Sadowski afbbd8e5ad Thread-safety analysis: adding in a basic lockset tracking system. This
system flags an error when unlocking a lock which was not held, locking
the same lock twice, having a different lockset on each iteration of a
loop, or going out of scope while still holding a lock. In order to
successfully use the lockset, this patch also makes sure that attribute
arguments are attached correctly for later parsing.

This patch was also worked on by DeLesley Hutchins.

Note: This patch has been reviewed by Chandler Carruth and Jeffrey
Yasskin. Feel free to provide post-commit review comments for a
subsequent patch.

llvm-svn: 138350
2011-08-23 18:46:34 +00:00
Matt Beaumont-Gay 56381b8502 Fix an incorrect note.
For the test case added to function-redecl.cpp, we were previously complaining
about a mismatch in the parameter types, since the definition used the
typedef'd type.

llvm-svn: 138318
2011-08-23 01:35:51 +00:00
Chandler Carruth 41c6dcc734 Fix a crash-on-valid that has been here for a very long time:
const int &x = x;

This crashed by inifinetly recursing within the lvalue evaluation
routine. I've added a (somewhat) braindead way of preventing this
recursion. If folks have better suggestions for how to avoid it I'm all
ears.

That said, we have some work to do. This doesn't trigger a single
warning for uninitialized, self-initialized or otherwise completely
wrong code. In some senses, the crash was almost better.

llvm-svn: 138239
2011-08-22 17:24:56 +00:00
Matt Beaumont-Gay 335e653fe6 Improve the correctness and accuracy of the message for -Wdynamic-class-memaccess
llvm-svn: 138074
2011-08-19 20:40:18 +00:00
Kaelyn Uhrain 40aa7c91b6 Don't accept a typo correction if the corrected identifier is the same as the
uncorrected identifier. Fixes a problem pointed out by Eli.

llvm-svn: 137987
2011-08-18 21:57:36 +00:00
Kaelyn Uhrain fd81a350e2 Rework DiagnoseInvalidRedeclaration to add the ability to correct typos when
diagnosing invalid function redeclarations.

llvm-svn: 137966
2011-08-18 18:19:12 +00:00
Francois Pichet 17ed020569 Add support for MSVC __unaligned attribute. Necessary to parse MSVC headers in 64-bit mode (ie: when _M_IA64 or _M_AMD64 is defined)
more info: http://msdn.microsoft.com/en-us/library/ms177389.aspx

llvm-svn: 137935
2011-08-18 09:59:55 +00:00
Chandler Carruth 2b949c2b4b Remove the last FIXMEs on -Wunused-comparison since it got moved to
entirely use the existing -Wunused-value infrastructure. This also fixes
a few missed cases for -Wunused in general.

llvm-svn: 137916
2011-08-18 02:04:29 +00:00
Francois Pichet 4c7269474e Downgrade "err_init_list_variable_narrowing" into a warning in Microsoft mode even if c++0x is enabled. This necessary to parse MSVC code in C++0x mode.
llvm-svn: 137904
2011-08-18 00:04:08 +00:00