From 37165b13e559bcd35fd981159e49486e0e0bf138 Mon Sep 17 00:00:00 2001
From: Devang Patel <dpatel@apple.com>
Date: Fri, 3 Oct 2008 17:50:00 +0000
Subject: [PATCH] Verify function attributes.

llvm-svn: 57020
---
 llvm/include/llvm/Attributes.h | 4 ++--
 llvm/lib/VMCore/Verifier.cpp   | 6 +++++-
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/llvm/include/llvm/Attributes.h b/llvm/include/llvm/Attributes.h
index d8f6cf6f0955..50a4cef9ea91 100644
--- a/llvm/include/llvm/Attributes.h
+++ b/llvm/include/llvm/Attributes.h
@@ -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;
diff --git a/llvm/lib/VMCore/Verifier.cpp b/llvm/lib/VMCore/Verifier.cpp
index a3d33176ef50..f8cd7780aefd 100644
--- a/llvm/lib/VMCore/Verifier.cpp
+++ b/llvm/lib/VMCore/Verifier.cpp
@@ -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];