[llvm] d909764 - Use findEnumAttribute helper for preallocated

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 16 10:51:00 PDT 2020


Author: Matt Arsenault
Date: 2020-07-16T13:50:49-04:00
New Revision: d909764cc763ae4cdf2125e0adfe288afa829f5b

URL: https://github.com/llvm/llvm-project/commit/d909764cc763ae4cdf2125e0adfe288afa829f5b
DIFF: https://github.com/llvm/llvm-project/commit/d909764cc763ae4cdf2125e0adfe288afa829f5b.diff

LOG: Use findEnumAttribute helper for preallocated

Added: 
    

Modified: 
    llvm/lib/IR/Attributes.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/IR/Attributes.cpp b/llvm/lib/IR/Attributes.cpp
index f67d96a854f4..d57597a55dc8 100644
--- a/llvm/lib/IR/Attributes.cpp
+++ b/llvm/lib/IR/Attributes.cpp
@@ -925,14 +925,13 @@ MaybeAlign AttributeSetNode::getStackAlignment() const {
 Type *AttributeSetNode::getByValType() const {
   if (auto A = findEnumAttribute(Attribute::ByVal))
     return A->getValueAsType();
-  return 0;
+  return nullptr;
 }
 
 Type *AttributeSetNode::getPreallocatedType() const {
-  for (const auto &I : *this)
-    if (I.hasAttribute(Attribute::Preallocated))
-      return I.getValueAsType();
-  return 0;
+  if (auto A = findEnumAttribute(Attribute::Preallocated))
+    return A->getValueAsType();
+  return nullptr;
 }
 
 uint64_t AttributeSetNode::getDereferenceableBytes() const {


        


More information about the llvm-commits mailing list