Skip to content

Commit fe2172a

Browse files
Merge pull request #3271 from rastogishubham/79981037
Apply proper source location to fallthrough switch cases.
2 parents 1fc7432 + 563d9d1 commit fe2172a

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

clang/lib/CodeGen/CGStmt.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1518,6 +1518,12 @@ void CodeGenFunction::EmitCaseStmt(const CaseStmt &S,
15181518
NextCase = dyn_cast<CaseStmt>(CurCase->getSubStmt());
15191519
}
15201520

1521+
// Generate a stop point for debug info if the case statement is
1522+
// followed by a default statement. A fallthrough case before a
1523+
// default case gets its own branch target.
1524+
if (CurCase->getSubStmt()->getStmtClass() == Stmt::DefaultStmtClass)
1525+
EmitStopPoint(CurCase);
1526+
15211527
// Normal default recursion for non-cases.
15221528
EmitStmt(CurCase->getSubStmt());
15231529
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// RUN: %clang_cc1 -triple x86_64-apple-macosx11.0.0 -debug-info-kind=standalone -emit-llvm %s -o - | FileCheck %s
2+
// CHECK: ], !dbg !{{[0-9]+}}
3+
// CHECK-EMPTY:
4+
// CHECK-NEXT: {{.+}}
5+
// CHECK-NEXT: br {{.+}}, !dbg !{{[0-9+]}}
6+
// CHECK-EMPTY:
7+
// CHECK-NEXT: {{.+}}
8+
// CHECK-NEXT: br {{.+}}, !dbg ![[LOC:[0-9]+]]
9+
void test(int num) {
10+
switch (num) {
11+
case 0:
12+
break;
13+
case 10: // CHECK: ![[LOC]] = !DILocation(line: [[@LINE]], column:{{.+}}, scope: {{.+}})
14+
default:
15+
break;
16+
}
17+
}

0 commit comments

Comments
 (0)