[PATCH] D23168: emit_DW_AT_noreturn flag
Victor via cfe-commits
cfe-commits at lists.llvm.org
Thu Aug 11 09:07:49 PDT 2016
vleschuk updated this revision to Diff 67694.
vleschuk added a comment.
Add IR tests
https://reviews.llvm.org/D23168
Files:
lib/AST/Decl.cpp
lib/CodeGen/CGDebugInfo.cpp
test/Frontend/dinoreturn.c
test/Frontend/dinoreturn.cpp
test/Frontend/dinoreturn.m
Index: test/Frontend/dinoreturn.m
===================================================================
--- /dev/null
+++ test/Frontend/dinoreturn.m
@@ -0,0 +1,5 @@
+// RUN: %clang %s -c -emit-llvm -S -g -o - | FileCheck %s
+// CHECK: DIFlagNoReturn
+__attribute__ ((noreturn)) void f() {
+ exit(0);
+}
Index: test/Frontend/dinoreturn.cpp
===================================================================
--- /dev/null
+++ test/Frontend/dinoreturn.cpp
@@ -0,0 +1,5 @@
+// RUN: %clang %s -c -std=c++11 -x c++ -emit-llvm -S -g -o - | FileCheck %s
+// CHECK: DIFlagNoReturn
+[[ noreturn ]] void f() {
+ throw 1;
+}
Index: test/Frontend/dinoreturn.c
===================================================================
--- /dev/null
+++ test/Frontend/dinoreturn.c
@@ -0,0 +1,6 @@
+// RUN: %clang %s -c -std=c11 -emit-llvm -S -g -o - | FileCheck %s
+// CHECK: DIFlagNoReturn
+#include <stdlib.h>
+_Noreturn void f() {
+ exit(0);
+}
Index: lib/CodeGen/CGDebugInfo.cpp
===================================================================
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -2641,6 +2641,9 @@
llvm::DIScope *Mod = getParentModuleOrNull(RDecl);
FDContext = getContextDescriptor(RDecl, Mod ? Mod : TheCU);
}
+ // Check if it is a noreturn-marked function
+ if (FD->isNoReturn())
+ Flags |= llvm::DINode::FlagNoReturn;
// Collect template parameters.
TParamsArray = CollectFunctionTemplateParams(FD, Unit);
}
Index: lib/AST/Decl.cpp
===================================================================
--- lib/AST/Decl.cpp
+++ lib/AST/Decl.cpp
@@ -2653,9 +2653,13 @@
}
bool FunctionDecl::isNoReturn() const {
- return hasAttr<NoReturnAttr>() || hasAttr<CXX11NoReturnAttr>() ||
- hasAttr<C11NoReturnAttr>() ||
- getType()->getAs<FunctionType>()->getNoReturnAttr();
+ bool HasNoReturnAttr = hasAttr<NoReturnAttr>() || hasAttr<CXX11NoReturnAttr>()
+ || hasAttr<C11NoReturnAttr>();
+ const auto *FuncType = getType()->getAs<FunctionType>();
+ bool TypeHasNoReturnAttr = false;
+ if (FuncType)
+ TypeHasNoReturnAttr = FuncType->getNoReturnAttr();
+ return HasNoReturnAttr || TypeHasNoReturnAttr;
}
void
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D23168.67694.patch
Type: text/x-patch
Size: 2222 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160811/7c65fe76/attachment-0001.bin>
More information about the cfe-commits
mailing list