Apply proper source location to fallthrough switch cases.
authorAdrian Prantl <aprantl@apple.com>
Fri, 17 Sep 2021 17:58:46 +0000 (10:58 -0700)
committerAdrian Prantl <aprantl@apple.com>
Fri, 17 Sep 2021 21:45:04 +0000 (14:45 -0700)
commit843390c58ae660fa356c534fdc8b19756f8d175c
tree3f46695ffb5d745e6d6a1cc327d28ff8c3961c4f
parent9ff848c5cd88947714f3d9bf03a3adbb84066736
Apply proper source location to fallthrough switch cases.

This fixes a bug in clang where, when clang sees a switch with a
fallthrough to a default like this:

static void funcA(void) {}
static void funcB(void) {}

int main(int argc, char **argv) {

switch (argc) {
    case 0:
        funcA();
        break;
    case 10:
    default:
        funcB();
        break;
}
}

It does not add a proper debug location for that switch case, such as
case 10: above.

Patch by Shubham Rastogi!

Differential Revision: https://reviews.llvm.org/D109940
clang/lib/CodeGen/CGStmt.cpp
clang/test/CodeGen/debug-info-switch-fallthrough.c [new file with mode: 0644]