Commit Graph

10 Commits

Author SHA1 Message Date
Nick Lewycky cdf1108b61 As of r202325, CFGBlock predecessors may be NULL. Ignore such preds. Fixes a crasher, PR18983.
llvm-svn: 202340
2014-02-27 02:43:25 +00:00
Alexander Kornienko 1e05e86de5 Moved fallthrough regression test to switch-implicit-fallthrough.cpp.
llvm-svn: 178554
2013-04-02 17:55:01 +00:00
Alexander Kornienko c121b9b796 -Wimplicit-fallthrough: fixed two cases where "fallthrough annotation in unreachable code" was issued incorrectly.
Summary:
-Wimplicit-fallthrough: fixed two cases where "fallthrough annotation in unreachable code" was issued incorrectly:

1. In actual unreachable code, but not immediately on a fall-through execution
path "fallthrough annotation does not directly precede switch label" is better;
2. After default: in a switch with covered enum cases. Actually, these shouldn't
be treated as unreachable code for our purpose.

Reviewers: rsmith

Reviewed By: rsmith

CC: cfe-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D374

llvm-svn: 174575
2013-02-07 02:17:19 +00:00
Alexander Kornienko 527fa4f24f Fixed segmentation fault when a CFGBlock has NULL successor.
llvm-svn: 174182
2013-02-01 15:39:20 +00:00
Alexander Kornienko afed1ddb40 Don't warn on fall-through from unreachable code.
Summary:
A motivating example:
class ClassWithDtor {
public:
  ~ClassWithDtor() {}
};
void fallthrough3(int n) {
  switch (n) {
    case 2:
      do {
        ClassWithDtor temp;
        return;
      } while (0);  // This generates a chain of unreachable CFG blocks.
    case 3:
      break;
  }
}

Reviewers: rsmith, doug.gregor, alexfh

Reviewed By: alexfh

CC: cfe-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D330

llvm-svn: 173889
2013-01-30 03:49:44 +00:00
Alexander Kornienko 09f15f3edf Silence unintended fallthrough diagnostic on a case label preceded with a normal label.
Summary:
It's unlikely that a fallthrough is unintended in the following code:
switch (n) {
...
  label:
  case 1:
...
    goto label;
...
}

Reviewers: rsmith, doug.gregor

Reviewed By: doug.gregor

CC: cfe-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D329

llvm-svn: 173486
2013-01-25 20:44:56 +00:00
Alexander Kornienko 5548879324 Don't suggest to insert [[clang::fallthrough]] before empty cases. Fix for multiple case labels.
llvm-svn: 173458
2013-01-25 15:49:34 +00:00
Alexander Kornienko 9a34889efe Added test with sizeof conditions (relies on to-be-implemented functionality of CFG, discussion: http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20120507/057370.html)
llvm-svn: 158854
2012-06-20 21:12:23 +00:00
Alexander Kornienko 246e85ddb0 Don't offer '[[clang::fallthrough]];' fix-it when a fall-through occurs to a
switch label immediately followed by a 'break;'.

llvm-svn: 157508
2012-05-26 00:49:15 +00:00
Richard Smith 84837d5b5a Add -Wimplicit-fallthrough warning flag, which warns on fallthrough between
cases in switch statements. Also add a [[clang::fallthrough]] attribute, which
can be used to suppress the warning in the case of intentional fallthrough.

Patch by Alexander Kornienko!

The handling of C++11 attribute namespaces in this patch is temporary, and will
be replaced with a cleaner mechanism in a subsequent patch.

llvm-svn: 156086
2012-05-03 18:27:39 +00:00