diff options
author | Mike Stump <mrs@apple.com> | 2009-07-25 21:26:53 +0000 |
---|---|---|
committer | Mike Stump <mrs@apple.com> | 2009-07-25 21:26:53 +0000 |
commit | 2455636163fdd18581d7fdae816433f886d88213 (patch) | |
tree | 400db92d5838683de2174dddb056f3a186d6c8cc /lib/Sema | |
parent | 742cd1b7bb86b52b23b335d47abbd842dac0e1bf (diff) |
Add noreturn as a type attribute, handle printing for them and handle
calls to noreturn function pointers when CFG building.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77089 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema')
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 5 | ||||
-rw-r--r-- | lib/Sema/SemaType.cpp | 19 |
2 files changed, 23 insertions, 1 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 91de998936..07e1ce77de 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -1084,7 +1084,10 @@ Sema::ControlFlowKind Sema::CheckFallThrough(Stmt *Root) { bool NoReturnEdge = false; if (CallExpr *C = dyn_cast<CallExpr>(S)) { Expr *CEE = C->getCallee()->IgnoreParenCasts(); - if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(CEE)) { + if (CEE->getType().getNoReturnAttr()) { + NoReturnEdge = true; + HasFakeEdge = true; + } else if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(CEE)) { if (FunctionDecl *FD = dyn_cast<FunctionDecl>(DRE->getDecl())) { if (FD->hasAttr<NoReturnAttr>()) { NoReturnEdge = true; diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp index a686e1db59..226f214391 100644 --- a/lib/Sema/SemaType.cpp +++ b/lib/Sema/SemaType.cpp @@ -1506,6 +1506,22 @@ static void HandleObjCGCTypeAttribute(QualType &Type, Type = S.Context.getObjCGCQualType(Type, GCAttr); } +/// HandleNoReturnTypeAttribute - Process the noreturn attribute on the +/// specified type. The attribute contains 0 arguments. +static void HandleNoReturnTypeAttribute(QualType &Type, + const AttributeList &Attr, Sema &S) { + if (Attr.getNumArgs() != 0) + return; + + // We only apply this to a pointer to function or a pointer to block. + if (!Type->isFunctionPointerType() + && !Type->isBlockPointerType() + && !Type->isFunctionType()) + return; + + Type = S.Context.getNoReturnType(Type); +} + void Sema::ProcessTypeAttributeList(QualType &Result, const AttributeList *AL) { // Scan through and apply attributes to this type where it makes sense. Some // attributes (such as __address_space__, __vector_size__, etc) apply to the @@ -1522,6 +1538,9 @@ void Sema::ProcessTypeAttributeList(QualType &Result, const AttributeList *AL) { case AttributeList::AT_objc_gc: HandleObjCGCTypeAttribute(Result, *AL, *this); break; + case AttributeList::AT_noreturn: + HandleNoReturnTypeAttribute(Result, *AL, *this); + break; } } } |