vleschuk updated this revision to Diff 68321. vleschuk added a comment. More context in text.
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: !DISubprogram({{.*}}name: "f"{{.*}}flags:{{.*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: !DISubprogram({{.*}}name: "f"{{.*}}flags:{{.*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: !DISubprogram({{.*}}name: "f"{{.*}}flags:{{.*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 @@ -2657,9 +2657,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
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: !DISubprogram({{.*}}name: "f"{{.*}}flags:{{.*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: !DISubprogram({{.*}}name: "f"{{.*}}flags:{{.*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: !DISubprogram({{.*}}name: "f"{{.*}}flags:{{.*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 @@ -2657,9 +2657,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
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits