[llvm-commits] [llvm] r165497 - in /llvm/trunk: include/llvm/Attributes.h lib/VMCore/Verifier.cpp

Bill Wendling isanbard at gmail.com
Tue Oct 9 02:51:11 PDT 2012


Author: void
Date: Tue Oct  9 04:51:10 2012
New Revision: 165497

URL: http://llvm.org/viewvc/llvm-project?rev=165497&view=rev
Log:
Move the 'ParameterOnly' variable inside of the Attributes class and make it a method.

Modified:
    llvm/trunk/include/llvm/Attributes.h
    llvm/trunk/lib/VMCore/Verifier.cpp

Modified: llvm/trunk/include/llvm/Attributes.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Attributes.h?rev=165497&r1=165496&r2=165497&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Attributes.h (original)
+++ llvm/trunk/include/llvm/Attributes.h Tue Oct  9 04:51:10 2012
@@ -110,10 +110,6 @@
 ///                      an exception might pass by.
 /// uwtable + nounwind = Needs an entry because the ABI says so.
 
-/// @brief Attributes that only apply to function parameters.
-const AttrConst ParameterOnly = {ByVal_i | Nest_i |
-    StructRet_i | NoCapture_i};
-
 /// @brief Attributes that may be applied to the function itself.  These cannot
 /// be used on return values or function parameters.
 const AttrConst FunctionOnly = {NoReturn_i | NoUnwind_i | ReadNone_i |
@@ -215,11 +211,6 @@
   static Attributes get(Builder &B);
   static Attributes get(LLVMContext &Context, Builder &B);
 
-  /// @brief Parameter attributes that do not apply to vararg call arguments.
-  bool hasIncompatibleWithVarArgsAttrs() const {
-    return hasAttribute(Attributes::StructRet);
-  }
-
   /// @brief Return true if the attribute is present.
   bool hasAttribute(AttrVal Val) const;
 
@@ -231,14 +222,27 @@
   /// @brief Return true if the attributes are a non-null intersection.
   bool hasAttributes(const Attributes &A) const;
 
-  /// This returns the alignment field of an attribute as a byte alignment
+  /// @brief Returns the alignment field of an attribute as a byte alignment
   /// value.
   unsigned getAlignment() const;
 
-  /// This returns the stack alignment field of an attribute as a byte alignment
-  /// value.
+  /// @brief Returns the stack alignment field of an attribute as a byte
+  /// alignment value.
   unsigned getStackAlignment() const;
 
+  /// @brief Parameter attributes that do not apply to vararg call arguments.
+  bool hasIncompatibleWithVarArgsAttrs() const {
+    return hasAttribute(Attributes::StructRet);
+  }
+
+  /// @brief Attributes that only apply to function parameters.
+  bool hasParameterOnlyAttrs() const {
+    return hasAttribute(Attributes::ByVal) ||
+      hasAttribute(Attributes::Nest) ||
+      hasAttribute(Attributes::StructRet) ||
+      hasAttribute(Attributes::NoCapture);
+  }
+
   bool isEmptyOrSingleton() const;
 
   // This is a "safe bool() operator".

Modified: llvm/trunk/lib/VMCore/Verifier.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Verifier.cpp?rev=165497&r1=165496&r2=165497&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/Verifier.cpp (original)
+++ llvm/trunk/lib/VMCore/Verifier.cpp Tue Oct  9 04:51:10 2012
@@ -533,11 +533,10 @@
   Assert1(!FnCheckAttr, "Attribute " + FnCheckAttr.getAsString() +
           " only applies to the function!", V);
 
-  if (isReturnValue) {
-    Attributes RetI = Attrs & Attribute::ParameterOnly;
-    Assert1(!RetI, "Attribute " + RetI.getAsString() +
-            " does not apply to return values!", V);
-  }
+  if (isReturnValue)
+    Assert1(!Attrs.hasParameterOnlyAttrs(),
+            "Attributes 'byval', 'nest', 'sret', and 'nocapture' "
+            "do not apply to return values!", V);
 
   for (unsigned i = 0;
        i < array_lengthof(Attribute::MutuallyIncompatible); ++i) {
@@ -550,16 +549,14 @@
   Assert1(!TypeI, "Wrong type for attribute " +
           TypeI.getAsString(), V);
 
-  Attributes ByValI = Attrs & Attribute::ByVal;
-  if (PointerType *PTy = dyn_cast<PointerType>(Ty)) {
-    Assert1(!ByValI || PTy->getElementType()->isSized(),
-            "Attribute " + ByValI.getAsString() +
-            " does not support unsized types!", V);
-  } else {
-    Assert1(!ByValI,
-            "Attribute " + ByValI.getAsString() +
-            " only applies to parameters with pointer type!", V);
-  }
+  if (PointerType *PTy = dyn_cast<PointerType>(Ty))
+    Assert1(!Attrs.hasAttribute(Attributes::ByVal) ||
+            PTy->getElementType()->isSized(),
+            "Attribute 'byval' does not support unsized types!", V);
+  else
+    Assert1(!Attrs.hasAttribute(Attributes::ByVal),
+            "Attribute 'byval' only applies to parameters with pointer type!",
+            V);
 }
 
 // VerifyFunctionAttrs - Check parameter attributes against a function type.





More information about the llvm-commits mailing list