From c884c23225743eeeeca2f0dac1258f18a3a10413 Mon Sep 17 00:00:00 2001 From: Adrian Prantl Date: Wed, 17 Aug 2016 16:20:32 +0000 Subject: [PATCH] Debug info: Mark noreturn functions with DIFlagNoReturn. This affects functions with the C++11 [[ noreturn ]] and C11 _Noreturn specifiers. Patch by Victor Leschuk! https://reviews.llvm.org/D23168 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@278942 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/AST/Decl.cpp | 10 +++++++--- lib/CodeGen/CGDebugInfo.cpp | 3 +++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp index 98711822a5..cf34c7ab8d 100644 --- a/lib/AST/Decl.cpp +++ b/lib/AST/Decl.cpp @@ -2657,9 +2657,13 @@ bool FunctionDecl::isGlobal() const { } bool FunctionDecl::isNoReturn() const { - return hasAttr() || hasAttr() || - hasAttr() || - getType()->getAs()->getNoReturnAttr(); + bool HasNoReturnAttr = hasAttr() || hasAttr() + || hasAttr(); + const auto *FuncType = getType()->getAs(); + bool TypeHasNoReturnAttr = false; + if (FuncType) + TypeHasNoReturnAttr = FuncType->getNoReturnAttr(); + return HasNoReturnAttr || TypeHasNoReturnAttr; } void diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp index ee2e21bdd4..f56cd0a6bb 100644 --- a/lib/CodeGen/CGDebugInfo.cpp +++ b/lib/CodeGen/CGDebugInfo.cpp @@ -2646,6 +2646,9 @@ void CGDebugInfo::collectFunctionDeclProps(GlobalDecl GD, llvm::DIFile *Unit, 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); } -- 2.40.0