This revision was automatically updated to reflect the committed changes.
Closed by commit rG843390c58ae6: Apply proper source location to fallthrough 
switch cases. (authored by aprantl).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D109940?vs=373263&id=373344#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109940

Files:
  clang/lib/CodeGen/CGStmt.cpp
  clang/test/CodeGen/debug-info-switch-fallthrough.c


Index: clang/test/CodeGen/debug-info-switch-fallthrough.c
===================================================================
--- /dev/null
+++ clang/test/CodeGen/debug-info-switch-fallthrough.c
@@ -0,0 +1,17 @@
+// RUN:  %clang_cc1 -triple x86_64-apple-macosx11.0.0 
-debug-info-kind=standalone -emit-llvm %s -o - | FileCheck %s
+// CHECK: ], !dbg !{{[0-9]+}}
+// CHECK-EMPTY:
+// CHECK-NEXT: {{.+}}
+// CHECK-NEXT: br {{.+}}, !dbg !{{[0-9+]}}
+// CHECK-EMPTY:
+// CHECK-NEXT: {{.+}}
+// CHECK-NEXT: br {{.+}}, !dbg ![[LOC:[0-9]+]]
+void test(int num) {
+  switch (num) {
+  case 0:
+    break;
+  case 10: // CHECK: ![[LOC]] = !DILocation(line: [[@LINE]], column:{{.+}}, 
scope: {{.+}})
+  default:
+    break;
+  }
+}
Index: clang/lib/CodeGen/CGStmt.cpp
===================================================================
--- clang/lib/CodeGen/CGStmt.cpp
+++ clang/lib/CodeGen/CGStmt.cpp
@@ -1521,6 +1521,12 @@
     NextCase = dyn_cast<CaseStmt>(CurCase->getSubStmt());
   }
 
+  // Generate a stop point for debug info if the case statement is
+  // followed by a default statement. A fallthrough case before a
+  // default case gets its own branch target.
+  if (CurCase->getSubStmt()->getStmtClass() == Stmt::DefaultStmtClass)
+    EmitStopPoint(CurCase);
+
   // Normal default recursion for non-cases.
   EmitStmt(CurCase->getSubStmt());
 }


Index: clang/test/CodeGen/debug-info-switch-fallthrough.c
===================================================================
--- /dev/null
+++ clang/test/CodeGen/debug-info-switch-fallthrough.c
@@ -0,0 +1,17 @@
+// RUN:  %clang_cc1 -triple x86_64-apple-macosx11.0.0 -debug-info-kind=standalone -emit-llvm %s -o - | FileCheck %s
+// CHECK: ], !dbg !{{[0-9]+}}
+// CHECK-EMPTY:
+// CHECK-NEXT: {{.+}}
+// CHECK-NEXT: br {{.+}}, !dbg !{{[0-9+]}}
+// CHECK-EMPTY:
+// CHECK-NEXT: {{.+}}
+// CHECK-NEXT: br {{.+}}, !dbg ![[LOC:[0-9]+]]
+void test(int num) {
+  switch (num) {
+  case 0:
+    break;
+  case 10: // CHECK: ![[LOC]] = !DILocation(line: [[@LINE]], column:{{.+}}, scope: {{.+}})
+  default:
+    break;
+  }
+}
Index: clang/lib/CodeGen/CGStmt.cpp
===================================================================
--- clang/lib/CodeGen/CGStmt.cpp
+++ clang/lib/CodeGen/CGStmt.cpp
@@ -1521,6 +1521,12 @@
     NextCase = dyn_cast<CaseStmt>(CurCase->getSubStmt());
   }
 
+  // Generate a stop point for debug info if the case statement is
+  // followed by a default statement. A fallthrough case before a
+  // default case gets its own branch target.
+  if (CurCase->getSubStmt()->getStmtClass() == Stmt::DefaultStmtClass)
+    EmitStopPoint(CurCase);
+
   // Normal default recursion for non-cases.
   EmitStmt(CurCase->getSubStmt());
 }
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to