[llvm-commits] CVS: llvm/include/llvm/DerivedTypes.h ParameterAttributes.h
Reid Spencer
reid at x10sys.com
Sat Apr 21 22:47:25 PDT 2007
Changes in directory llvm/include/llvm:
DerivedTypes.h updated: 1.91 -> 1.92
ParameterAttributes.h updated: 1.7 -> 1.8
---
Log message:
For PR1146: http://llvm.org/PR1146 :
Make ParamAttrsList objects unique. You can no longer directly create or
destroy them but instead must go through the ParamAttrsList::get()
interface.
---
Diffs of the changes: (+26 -47)
DerivedTypes.h | 1
ParameterAttributes.h | 72 ++++++++++++++++++--------------------------------
2 files changed, 26 insertions(+), 47 deletions(-)
Index: llvm/include/llvm/DerivedTypes.h
diff -u llvm/include/llvm/DerivedTypes.h:1.91 llvm/include/llvm/DerivedTypes.h:1.92
--- llvm/include/llvm/DerivedTypes.h:1.91 Mon Apr 9 01:06:57 2007
+++ llvm/include/llvm/DerivedTypes.h Sun Apr 22 00:46:44 2007
@@ -148,7 +148,6 @@
bool IsVarArgs, ParamAttrsList *Attrs = 0);
public:
- virtual ~FunctionType();
/// FunctionType::get - This static method is the primary way of constructing
/// a FunctionType.
///
Index: llvm/include/llvm/ParameterAttributes.h
diff -u llvm/include/llvm/ParameterAttributes.h:1.7 llvm/include/llvm/ParameterAttributes.h:1.8
--- llvm/include/llvm/ParameterAttributes.h:1.7 Tue Apr 10 21:44:19 2007
+++ llvm/include/llvm/ParameterAttributes.h Sun Apr 22 00:46:44 2007
@@ -18,6 +18,7 @@
#define LLVM_PARAMETER_ATTRIBUTES_H
#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/FoldingSet.h"
namespace llvm {
@@ -39,6 +40,17 @@
}
+/// This is just a pair of values to associate a set of parameter attributes
+/// with a parameter index.
+/// @brief ParameterAttributes with a parameter index.
+struct ParamAttrsWithIndex {
+ uint16_t attrs; ///< The attributes that are set, |'d together
+ uint16_t index; ///< Index of the parameter for which the attributes apply
+};
+
+/// @brief A vector of attribute/index pairs.
+typedef SmallVector<ParamAttrsWithIndex,4> ParamAttrsVector;
+
typedef ParamAttr::Attributes ParameterAttributes;
/// This class is used by Function and CallInst to represent the set of
@@ -50,38 +62,27 @@
/// a string of mnemonics suitable for LLVM Assembly output. Various accessors
/// are provided to obtain information about the attributes.
/// @brief A List of ParameterAttributes.
-class ParamAttrsList {
- //void operator=(const ParamAttrsList &); // Do not implement
- //ParamAttrsList(const ParamAttrsList &); // Do not implement
-
- /// @name Types
+class ParamAttrsList : public FoldingSetNode {
+ /// @name Construction
/// @{
- public:
- /// This is an internal structure used to associate the ParameterAttributes
- /// with a parameter index.
- /// @brief ParameterAttributes with a parameter index.
- struct ParamAttrsWithIndex {
- uint16_t attrs; ///< The attributes that are set, |'d together
- uint16_t index; ///< Index of the parameter for which the attributes apply
- };
+ private:
+ // ParamAttrsList is uniqued, thes should not be publicly available
+ void operator=(const ParamAttrsList &); // Do not implement
+ ParamAttrsList(const ParamAttrsList &); // Do not implement
+ ParamAttrsList(); // Do not implement
+ ~ParamAttrsList() {} // Not public!
- /// @brief A vector of attribute/index pairs.
- typedef SmallVector<ParamAttrsWithIndex,4> ParamAttrsVector;
+ /// @brief Construct an ParamAttrsList from a ParamAttrsVector
+ explicit ParamAttrsList(const ParamAttrsVector &attrVec) : attrs(attrVec) {}
- /// @}
- /// @name Construction
- /// @{
public:
- /// @brief Construct an empty ParamAttrsList
- ParamAttrsList() {}
-
/// This method ensures the uniqueness of ParamAttrsList instances. The
/// argument is a vector of attribute/index pairs as represented by the
/// ParamAttrsWithIndex structure. The vector is used in the construction of
/// the ParamAttrsList instance. If an instance with identical vector pairs
/// exists, it will be returned instead of creating a new instance.
/// @brief Get a ParamAttrsList instance.
- ParamAttrsList *get(const ParamAttrsVector &attrVec);
+ static ParamAttrsList *get(const ParamAttrsVector &attrVec);
/// @}
/// @name Accessors
@@ -155,33 +156,12 @@
/// @brief Return the number of parameter attributes this type has.
unsigned size() const { return attrs.size(); }
- /// Clients generally should not use this method. It is used internally by
- /// LLVM.
- /// @returns true if this ParamAttrsList is empty.
- /// @brief Determine emptiness of ParamAttrsList.
- unsigned empty() const { return attrs.empty(); }
-
/// @}
- /// @name Mutators
+ /// @name Implementation Details
/// @{
public:
- /// This method will add the \p attrs to the parameter with index
- /// \p param_index. If the parameter index does not exist it will be created
- /// and the \p attrs will be the only attributes set. Otherwise, any
- /// existing attributes for the specified parameter remain set and the
- /// attributes given by \p attrs are also set.
- /// @brief Add ParameterAttributes.
- void addAttributes(uint16_t param_index, uint16_t attrs);
-
- /// This method will remove the \p attrs to the parameter with index
- /// \p param_index. If the parameter index does not exist in the list,
- /// an assertion will occur. If the specified attributes are the last
- /// attributes set for the specified parameter index, the attributes for
- /// that index are removed completely from the list (size is decremented).
- /// Otherwise, the specified attributes are removed from the set of
- /// attributes for the given index, retaining any others.
- /// @brief Remove a single ParameterAttribute
- void removeAttributes(uint16_t param_index, uint16_t attrs);
+ void Profile(FoldingSetNodeID &ID) const;
+ void dump() const;
/// @}
/// @name Data
More information about the llvm-commits
mailing list