diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2011-10-03 14:59:42 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2011-10-03 14:59:42 +0000 |
commit | 70107f989c2e62372b5adc310a95be668b7cb33b (patch) | |
tree | 7b91830d2d5f246fe3382704a9e0f5f5050cd01e /clang/lib | |
parent | cc349c8dd83fb0fdc827c786415bbec629cb05c6 (diff) | |
download | bcm5719-llvm-70107f989c2e62372b5adc310a95be668b7cb33b.tar.gz bcm5719-llvm-70107f989c2e62372b5adc310a95be668b7cb33b.zip |
Propagate __attribute__((returns_twice)) from C to IL.
llvm-svn: 141002
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/CodeGen/CGCall.cpp | 3 | ||||
-rw-r--r-- | clang/lib/Sema/AttributeList.cpp | 2 | ||||
-rw-r--r-- | clang/lib/Sema/SemaDeclAttr.cpp | 20 |
3 files changed, 24 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp index eb0dcf3bef9..f52abef3306 100644 --- a/clang/lib/CodeGen/CGCall.cpp +++ b/clang/lib/CodeGen/CGCall.cpp @@ -740,6 +740,9 @@ void CodeGenModule::ConstructAttributeList(const CGFunctionInfo &FI, if (TargetDecl->hasAttr<NoReturnAttr>()) FuncAttrs |= llvm::Attribute::NoReturn; + if (TargetDecl->hasAttr<ReturnsTwiceAttr>()) + FuncAttrs |= llvm::Attribute::ReturnsTwice; + // 'const' and 'pure' attribute functions are also nounwind. if (TargetDecl->hasAttr<ConstAttr>()) { FuncAttrs |= llvm::Attribute::ReadNone; diff --git a/clang/lib/Sema/AttributeList.cpp b/clang/lib/Sema/AttributeList.cpp index 9d366ad255b..13a0edec28d 100644 --- a/clang/lib/Sema/AttributeList.cpp +++ b/clang/lib/Sema/AttributeList.cpp @@ -159,7 +159,7 @@ AttributeList::Kind AttributeList::getKind(const IdentifierInfo *Name) { .Case("address_space", AT_address_space) .Case("opencl_image_access", AT_opencl_image_access) .Case("always_inline", AT_always_inline) - .Case("returns_twice", IgnoredAttribute) + .Case("returns_twice", AT_returns_twice) .Case("vec_type_hint", IgnoredAttribute) .Case("objc_exception", AT_objc_exception) .Case("objc_method_family", AT_objc_method_family) diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index d9e4df058da..79afbe538d3 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/lib/Sema/SemaDeclAttr.cpp @@ -1427,6 +1427,23 @@ static void handleUnusedAttr(Sema &S, Decl *D, const AttributeList &Attr) { D->addAttr(::new (S.Context) UnusedAttr(Attr.getRange(), S.Context)); } +static void handleReturnsTwiceAttr(Sema &S, Decl *D, + const AttributeList &Attr) { + // check the attribute arguments. + if (Attr.hasParameterOrArguments()) { + S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << 0; + return; + } + + if (!isa<FunctionDecl>(D)) { + S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type) + << Attr.getName() << ExpectedFunction; + return; + } + + D->addAttr(::new (S.Context) ReturnsTwiceAttr(Attr.getRange(), S.Context)); +} + static void handleUsedAttr(Sema &S, Decl *D, const AttributeList &Attr) { // check the attribute arguments. if (Attr.hasParameterOrArguments()) { @@ -3567,6 +3584,9 @@ static void ProcessInheritableDeclAttr(Sema &S, Scope *scope, Decl *D, handleArcWeakrefUnavailableAttr (S, D, Attr); break; case AttributeList::AT_unused: handleUnusedAttr (S, D, Attr); break; + case AttributeList::AT_returns_twice: + handleReturnsTwiceAttr(S, D, Attr); + break; case AttributeList::AT_used: handleUsedAttr (S, D, Attr); break; case AttributeList::AT_visibility: handleVisibilityAttr (S, D, Attr); break; case AttributeList::AT_warn_unused_result: handleWarnUnusedResult(S, D, Attr); |