r278942 - Debug info: Mark noreturn functions with DIFlagNoReturn.

Adrian Prantl via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 17 09:20:33 PDT 2016


Author: adrian
Date: Wed Aug 17 11:20:32 2016
New Revision: 278942

URL: http://llvm.org/viewvc/llvm-project?rev=278942&view=rev
Log:
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

Modified:
    cfe/trunk/lib/AST/Decl.cpp
    cfe/trunk/lib/CodeGen/CGDebugInfo.cpp

Modified: cfe/trunk/lib/AST/Decl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=278942&r1=278941&r2=278942&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Decl.cpp (original)
+++ cfe/trunk/lib/AST/Decl.cpp Wed Aug 17 11:20:32 2016
@@ -2657,9 +2657,13 @@ bool FunctionDecl::isGlobal() const {
 }
 
 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

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=278942&r1=278941&r2=278942&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Wed Aug 17 11:20:32 2016
@@ -2646,6 +2646,9 @@ void CGDebugInfo::collectFunctionDeclPro
       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);
   }




More information about the cfe-commits mailing list