From d047a9df7d4b2934d6a9c22528b668d6100c0f87 Mon Sep 17 00:00:00 2001 From: Juergen Ributzka Date: Tue, 5 Aug 2014 05:43:41 +0000 Subject: [PATCH] Provide convenient access to the zext/sext attributes of function arguments. NFC. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@214843 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/Argument.h | 8 ++++++++ lib/IR/Function.cpp | 14 ++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/include/llvm/IR/Argument.h b/include/llvm/IR/Argument.h index 7c398a5e553..dd76a90aa5e 100644 --- a/include/llvm/IR/Argument.h +++ b/include/llvm/IR/Argument.h @@ -105,6 +105,14 @@ public: /// its containing function. bool hasInAllocaAttr() const; + /// \brief Return true if this argument has the zext attribute on it in its + /// containing function. + bool hasZExtAttr() const; + + /// \brief Return true if this argument has the sext attribute on it in its + /// containing function. + bool hasSExtAttr() const; + /// \brief Add a Attribute to an argument. void addAttr(AttributeSet AS); diff --git a/lib/IR/Function.cpp b/lib/IR/Function.cpp index de59b26ec92..f1fe6604333 100644 --- a/lib/IR/Function.cpp +++ b/lib/IR/Function.cpp @@ -166,6 +166,20 @@ bool Argument::hasReturnedAttr() const { hasAttribute(getArgNo()+1, Attribute::Returned); } +/// hasZExtAttr - Return true if this argument has the zext attribute on it in +/// its containing function. +bool Argument::hasZExtAttr() const { + return getParent()->getAttributes(). + hasAttribute(getArgNo()+1, Attribute::ZExt); +} + +/// hasSExtAttr Return true if this argument has the sext attribute on it in its +/// containing function. +bool Argument::hasSExtAttr() const { + return getParent()->getAttributes(). + hasAttribute(getArgNo()+1, Attribute::SExt); +} + /// Return true if this argument has the readonly or readnone attribute on it /// in its containing function. bool Argument::onlyReadsMemory() const { -- 2.34.1