Commit Graph

18 Commits

Author SHA1 Message Date
Richard Smith 2fcb73984a Fix a couple of bugs where jump diagnostics would not notice that a variable
has an initializer.

llvm-svn: 183092
2013-06-03 01:05:37 +00:00
Argyrios Kyrtzidis e6e422b1ee When a statement is dropped from the AST because it was invalid, make sure
we don't do the scope checks otherwise we are going to hit assertion checks
since a label may not have been actually added.

llvm-svn: 175281
2013-02-15 18:34:13 +00:00
Eli Friedman 1e95d4bb1e Correctly reject gotos in function-level try blocks. PR14225.
llvm-svn: 167184
2012-10-31 23:55:28 +00:00
Rafael Espindola 44938a738a Fix invalid jump scopes again. This time without trying to find out if an
incomplete type has a destructor or not.

llvm-svn: 166895
2012-10-28 02:44:03 +00:00
Rafael Espindola bd2c99b77c Revert 166876 while I debug a bootstrap problem.
llvm-svn: 166878
2012-10-27 16:49:47 +00:00
Rafael Espindola 2ea126e73e Reapply 166855 with an early exit on null QualTypes.
llvm-svn: 166876
2012-10-27 14:56:08 +00:00
Rafael Espindola 8c0739d332 Revert r166855. I can reproduce the bootstrap failure and have a testcase
to reduce.

llvm-svn: 166863
2012-10-27 03:06:02 +00:00
Rafael Espindola c5f9943a60 Fix cases where we were not producing an error when a computed goto could
jump over destructor calls.
Fixes pr13812.

llvm-svn: 166855
2012-10-27 01:17:42 +00:00
Rafael Espindola ef1707c013 Fix namespace nesting and remove windows line endings.
llvm-svn: 163620
2012-09-11 14:17:47 +00:00
Richard Trieu 553b2b2e5d Modify how the -verify flag works. Currently, the verification string and
diagnostic message are compared.  If either is a substring of the other, then
no error is given.  This gives rise to an unexpected case:

  // expect-error{{candidate function has different number of parameters}}

will match the following error messages from Clang:

  candidate function has different number of parameters (expected 1 but has 2)
  candidate function has different number of parameters

It will also match these other error messages:

  candidate function
  function has different number of parameters
  number of parameters

This patch will change so that the verification string must be a substring of
the diagnostic message before accepting.  Also, all the failing tests from this
change have been corrected.  Some stats from this cleanup:

87 - removed extra spaces around verification strings
70 - wording updates to diagnostics
40 - extra leading or trailing characters (typos, unmatched parens or quotes)
35 - diagnostic level was included (error:, warning:, or note:)
18 - flag name put in the warning (-Wprotocol)

llvm-svn: 146619
2011-12-15 00:38:15 +00:00
Richard Smith 9ca5c42582 Update all tests other than Driver/std.cpp to use -std=c++11 rather than
-std=c++0x. Patch by Ahmed Charles!

llvm-svn: 141900
2011-10-13 22:29:44 +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
Argyrios Kyrtzidis 1fa8b4b204 Make DiagnosticErrorTrap keep a count of the errors that occurred so multiple
DiagnosticErrorTraps can be composed (e.g. a trap inside another trap).

Fixes http://llvm.org/PR10462 & rdar://9852007.

llvm-svn: 136447
2011-07-29 01:25:44 +00:00
Chandler Carruth 56773db7d4 I concur with DPG here. This does indeed apply in 0x mode. Added test
cases that demonstrates exactly why this does indeed apply in 0x mode.

If isPOD is currently broken in 0x mode, we should fix that directly
rather than papering over it here.

llvm-svn: 130007
2011-04-22 19:01:39 +00:00
John McCall 9de9160d55 Implement an indirect-goto optimization for goto *&&lbl and respect this
in the scope checker.  With that done, turn an indirect goto into a
protected scope into a hard error;  otherwise IR generation has to start
worrying about declarations not dominating their scopes, as exemplified
in PR8473.

If this really affects anyone, I can probably adjust this to only hard-error
on possible indirect gotos into VLA scopes rather than arbitrary scopes.
But we'll see how people cope with the aggressive change on the marginal
feature.

llvm-svn: 117539
2010-10-28 08:53:48 +00:00
John McCall 4a33fa95c0 Labels (and case statement) don't create independent scope parents for the
purposes of the jump checker.  Also extend Ted's iteration fix to labels.

Fixes PR7789.

llvm-svn: 110082
2010-08-02 23:33:14 +00:00
John McCall d4e1b767f3 Don't consider all local variables in C++ to mandate scope-checking, just
those with initializers.

llvm-svn: 109964
2010-08-01 01:24:59 +00:00
John McCall cf819ab383 When checking scopes for indirect goto, be more permissive (but still safe)
about the permitted scopes.  Specifically:
  1) Permit labels and gotos to appear after a prologue of variable initializations.
  2) Permit indirect gotos to jump out of scopes that don't require cleanup.
  3) Diagnose possible attempts to indirect-jump out of scopes that do require
     cleanup.
This requires a substantial reinvention of the algorithm for checking indirect
goto.  The current algorithm is Omega(M*N), with M = the number of unique
scopes being jumped from and N = the number of unique scopes being jumped to,
with an additional factor that is probably (worst-case) linear in the depth
of scopes.  Thus the entire thing is likely cubic given some truly bizarre
ill-formed code;  on well-formed code the additional factor collapses to
an amortized constant (when amortized over the entire function) and so
the algorithm is quadratic.  Even this requires every label to appear in
its own scope, which would be very unusual for indirect-goto code (and
extremely unlikely for well-formed code);  it is far more likely that
all labels will be in the same scope and so the algorithm becomes linear.
For such a marginal feature, I am fairly happy with this result.

(this is using JumpDiagnostic's definition of scope, where successive
variables in a block appear in their own scope)

llvm-svn: 103536
2010-05-12 00:58:13 +00:00