]> granicus.if.org Git - clang/commitdiff
[DWARF5] Added support for DW_AT_noreturn attribute to be emitted for
authorAdrian Prantl <aprantl@apple.com>
Wed, 16 Oct 2019 16:30:38 +0000 (16:30 +0000)
committerAdrian Prantl <aprantl@apple.com>
Wed, 16 Oct 2019 16:30:38 +0000 (16:30 +0000)
C++ class member functions.

Patch by Sourabh Singh Tomar!

Differential Revision: https://reviews.llvm.org/D68697

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@375012 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGDebugInfo.cpp
test/CodeGenCXX/debug-info-noreturn.cpp [new file with mode: 0644]

index 3d140ba7d7b3531f58d436743396554bf2443114..7962ae002b25d9dfaf594d63f918e13f154c4260 100644 (file)
@@ -1605,6 +1605,8 @@ llvm::DISubprogram *CGDebugInfo::CreateCXXMemberFunction(
     ContainingType = RecordTy;
   }
 
+  if (Method->isNoReturn())
+    Flags |= llvm::DINode::FlagNoReturn;
   if (Method->isStatic())
     Flags |= llvm::DINode::FlagStaticMember;
   if (Method->isImplicit())
diff --git a/test/CodeGenCXX/debug-info-noreturn.cpp b/test/CodeGenCXX/debug-info-noreturn.cpp
new file mode 100644 (file)
index 0000000..85b8132
--- /dev/null
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -std=c++11 -emit-llvm -fcxx-exceptions -debug-info-kind=standalone  %s -o - | FileCheck %s
+// Test for NoReturn flags in debug info.
+
+// CHECK: DISubprogram(name: "f", {{.*}}, flags: DIFlagPrototyped | DIFlagNoReturn, spFlags: DISPFlagDefinition
+// CHECK: DISubprogram(name: "foo_member", {{.*}}, flags: DIFlagPrototyped | DIFlagNoReturn, spFlags: 0
+// CHECK-NOT: DISubprogram(name: "func",{{.*}}, flags: DIFlagPrototyped | DIFlagNoReturn, spFlags: DISPFlagDefinition
+
+class foo {
+
+  [[noreturn]] void foo_member() { throw 1; }
+};
+
+[[noreturn]] void f() {
+  throw 1;
+}
+
+void func() {
+  foo object;
+}