]> granicus.if.org Git - clang/commitdiff
Distinguish two lexical blocks at the same level.
authorDevang Patel <dpatel@apple.com>
Tue, 16 Feb 2010 21:41:20 +0000 (21:41 +0000)
committerDevang Patel <dpatel@apple.com>
Tue, 16 Feb 2010 21:41:20 +0000 (21:41 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96397 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGDebugInfo.cpp
test/CodeGen/2010-02-16-DbgScopes.c [new file with mode: 0644]

index 5b9c6b055e0edd3ea910a9ba893632cf1da4cd85..3a27a37988569f3c4691598941b341bc5af10a61 100644 (file)
@@ -1351,10 +1351,13 @@ void CGDebugInfo::EmitStopPoint(llvm::Function *Fn, CGBuilderTy &Builder) {
 /// EmitRegionStart- Constructs the debug code for entering a declarative
 /// region - "llvm.dbg.region.start.".
 void CGDebugInfo::EmitRegionStart(llvm::Function *Fn, CGBuilderTy &Builder) {
+  SourceManager &SM = CGM.getContext().getSourceManager();
+  PresumedLoc PLoc = SM.getPresumedLoc(CurLoc);
   llvm::DIDescriptor D =
     DebugFactory.CreateLexicalBlock(RegionStack.empty() ? 
                                     llvm::DIDescriptor() : 
-                                    llvm::DIDescriptor(RegionStack.back()));
+                                    llvm::DIDescriptor(RegionStack.back()),
+                                    PLoc.getLine(), PLoc.getColumn());
   RegionStack.push_back(D.getNode());
 }
 
diff --git a/test/CodeGen/2010-02-16-DbgScopes.c b/test/CodeGen/2010-02-16-DbgScopes.c
new file mode 100644 (file)
index 0000000..b11f920
--- /dev/null
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -emit-llvm -g < %s | grep  lexical | count 5
+// Test to check number of lexical scope identified in debug info.
+
+extern int bar();
+extern void foobar();
+void foo(int s) {
+  unsigned loc = 0;
+  if (s) {
+    if (bar()) {
+      foobar();
+    }
+  } else {
+    loc = 1;
+    if (bar()) {
+      loc = 2;
+    }
+  }
+}