vsk added inline comments.

================
Comment at: lib/CodeGen/CGExpr.cpp:72
+  // Set debug location in order to preserve the scope
+  Alloca->setDebugLoc(Builder.getCurrentDebugLocation());
   if (AllocaAddr)
----------------
I think we need to be a bit more careful here. The current debug location 
stored in the builder may not be an artificial 0-location. This may cause 
non-linear single-stepping behavior. Consider this example:

```
void foo() {
  bar();
  if (...) {
    int var = ...; //< Clang emits an alloca for "var".
  }
...
```

The current debug location at the line "int var = ..." would be at line 4. But 
the alloca is emitted in the entry block of the function. In the debugger, this 
may result in strange single-stepping behavior when stepping into foo(). You 
could step to line 4, then line 2, then line 3, then line 4 again.

I think we can avoid that by setting an artificial location on allocas.


================
Comment at: lib/CodeGen/CGExpr.cpp:105
   return new llvm::AllocaInst(Ty, CGM.getDataLayout().getAllocaAddrSpace(),
                               ArraySize, Name, AllocaInsertPt);
 }
----------------
Why not apply the location here to cover more cases?


================
Comment at: test/CodeGen/debug-info-preserve-scope.c:11
+
+// CHECK: [[B:%.*]] = alloca i32 {{.*}} !dbg ![[artificialDbgLoc:[0-9]+]]
+// CHECK: store i32 {{.*}} !dbg ![[artificialDbgLoc]]
----------------
Why is "B" captured?


Repository:
  rC Clang

https://reviews.llvm.org/D47097



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to