Verify function attributes.
authorDevang Patel <dpatel@apple.com>
Fri, 3 Oct 2008 17:50:00 +0000 (17:50 +0000)
committerDevang Patel <dpatel@apple.com>
Fri, 3 Oct 2008 17:50:00 +0000 (17:50 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@57020 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Attributes.h
lib/VMCore/Verifier.cpp

index d8f6cf6f09552844287f00459f361f50de9f96e7..50a4cef9ea91d752bf2fba9f8d159bd70fa918f5 100644 (file)
@@ -53,8 +53,8 @@ const Attributes Alignment = 0xffff<<16; ///< Alignment of parameter (16 bits)
 /// @brief Attributes that only apply to function parameters.
 const Attributes ParameterOnly = ByVal | Nest | StructRet;
 
-/// @brief Attributes that only apply to function return values.
-const Attributes ReturnOnly = NoReturn | NoUnwind | ReadNone | ReadOnly;
+/// @brief Attributes that only apply to function.
+const Attributes FunctionOnly = NoReturn | NoUnwind | ReadNone | ReadOnly;
 
 /// @brief Parameter attributes that do not apply to vararg call arguments.
 const Attributes VarArgsIncompatible = StructRet;
index a3d33176ef50af87ddc8224ef1c1d2006df11f37..f8cd7780aefd0d894b5f7390c8a14d71c3cb5db9 100644 (file)
@@ -416,7 +416,7 @@ void Verifier::VerifyAttrs(Attributes Attrs, const Type *Ty,
     Assert1(!RetI, "Attribute " + Attribute::getAsString(RetI) +
             " does not apply to return values!", V);
   } else {
-    Attributes ParmI = Attrs & Attribute::ReturnOnly;
+    Attributes ParmI = Attrs & Attribute::FunctionOnly;
     Assert1(!ParmI, "Attribute " + Attribute::getAsString(ParmI) +
             " only applies to return values!", V);
   }
@@ -477,6 +477,10 @@ void Verifier::VerifyFunctionAttrs(const FunctionType *FT,
   }
 
   Attributes FAttrs = Attrs.getFnAttributes();
+  Assert1(!(FAttrs & (!Attribute::FunctionOnly)),
+          "Attribute " + Attribute::getAsString(FAttrs) +
+          " does not apply to function!", V);
+      
   for (unsigned i = 0;
        i < array_lengthof(Attribute::MutuallyIncompatible); ++i) {
     Attributes MutI = FAttrs & Attribute::MutuallyIncompatible[i];