[clang] Emit debug info with original source location for tokens from macros … (PR #163190)

via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 15 11:08:42 PDT 2025


================
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 %s -debug-info-kind=standalone -emit-llvm -o - | FileCheck %s
+
+#define GLOBAL(num) global##num
+#define DECL_GLOBAL(x) int x
+#define SAME_ORDER(x, y) x; y
+#define SWAP_ORDER(x,y) y; x
+
+// CHECK: DIGlobalVariable(name: "global",{{.*}} line: [[@LINE+4]]
+// CHECK: DIGlobalVariable({{.*}}line: [[@LINE+6]],{{.*}} type: [[TYPEID:![0-9]+]]
+SAME_ORDER(
+  int
+    GLOBAL  // <- global
+      () = 42,
+  const char* s() {
+    return "1234567890";
+  }
+)
+// CHECK: DIGlobalVariable(name: "global3",{{.*}} line: [[@LINE+6]]
+// CHECK: DIGlobalVariable(name: "global2",{{.*}} line: [[@LINE+2]]
----------------
SergejSalnikov wrote:

The order in which variables are defined is important. As you can see the global3 precedes global2 despite decreasing line number. 

https://github.com/llvm/llvm-project/pull/163190


More information about the cfe-commits mailing list