Merge ArtificialLocation into ApplyDebugLocation and make a clear
distinction between the different use-cases. With the previous default
behavior we would occasionally emit empty debug locations in situations
where they actually were strictly required (= on invoke insns).
We now have a choice between defaulting to an empty location or an
artificial location.

Specifically, this fixes a bug caused by a missing debug location when
emitting C++ EH cleanup blocks from within an artificial function, such as
an ObjC destroy helper function.

rdar://problem/19670595

llvm-svn: 228003
diff --git a/clang/test/CodeGenObjCXX/nested-ehlocation.mm b/clang/test/CodeGenObjCXX/nested-ehlocation.mm
new file mode 100644
index 0000000..de3e359
--- /dev/null
+++ b/clang/test/CodeGenObjCXX/nested-ehlocation.mm
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1  -triple x86_64-apple-macosx -emit-llvm -g -stdlib=libc++ -fblocks -fexceptions -x objective-c++ -o - %s | FileCheck %s
+
+// Verify that all invoke instructions have a debug location.
+// Literally: There are no unwind lines that don't end with ", (!dbg 123)".
+// CHECK-NOT: {{to label %.* unwind label [^,]+$}}
+
+void block(void (^)(void));
+extern void foo();
+struct A {
+  ~A(void) { foo(); }
+  void bar() const {}
+};
+void baz(void const *const) {}
+struct B : A {};
+void test() {
+  A a;
+  B b;
+  block(^(void) {
+    baz(&b);
+    block(^() {
+      a.bar();
+    });
+  });
+}