[PATCH] D111568: [clang] Omit most AttributedStatements from the CFG

Nico Weber via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 12 05:53:35 PDT 2021


thakis marked an inline comment as done.
thakis added inline comments.


================
Comment at: clang/lib/Analysis/CFG.cpp:2407
+  return hasSpecificAttr<FallThroughAttr>(A->getAttrs()) &&
+         isa<NullStmt>(A->getSubStmt());
+}
----------------
hans wrote:
> Can fallthrough statements ever have children? If not, should it be an assert instead of a check here?
Good question. Attr.td says:

```
  // The attribute only applies to a NullStmt, but we have special fix-it
  // behavior if applied to a case label.
  let Subjects = SubjectList<[NullStmt, SwitchCase], ErrorDiag,
                             "empty statements">;
```

Which I suppose triggers for this:

```
  switch (argc) {
    [[fallthrough]] case 4:
      break;
  }
```

```
foo.cc:6:7: error: 'fallthrough' attribute is only allowed on empty statements
    [[fallthrough]] case 4:
      ^             ~~~~
foo.cc:6:20: note: did you forget ';'?
    [[fallthrough]] case 4:
```

But that doesn't seem to make it into the AST, according to -dump-ast. So I suppose it could be an assert as well. Want me to change this?




CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D111568/new/

https://reviews.llvm.org/D111568



More information about the cfe-commits mailing list