diff options
author | Pierre Moreau <dev@pmoreau.org> | 2018-04-17 18:41:46 +0200 |
---|---|---|
committer | Alexey Sotkin <alexey.sotkin@intel.com> | 2018-04-24 12:21:49 +0300 |
commit | a8d032140fe6deac00c37c6d069e4dee9f0bba3c (patch) | |
tree | 4f8eadaca328c27db3ab8292fe92c3e16f7c34e2 | |
parent | 24bf6ffe25759cf4a14cbee902ee0ddd43dff589 (diff) |
Manually remove “m_” prefix used on some class attributes
clang-tidy does not properly remove when run, so let’s remove it before
running clang-tidy.
Command used: sed -i -e 's/\<m_\([a-zA-Z0-9_]\+\)\>/\u\1/g' `find . -iname "*.cpp"` `find . -iname "*.h"`
-rw-r--r-- | lib/SPIRV/Mangler/Mangler.cpp | 58 | ||||
-rw-r--r-- | lib/SPIRV/Mangler/NameMangleAPI.h | 2 | ||||
-rw-r--r-- | lib/SPIRV/Mangler/ParameterType.cpp | 38 | ||||
-rw-r--r-- | lib/SPIRV/Mangler/ParameterType.h | 44 | ||||
-rw-r--r-- | lib/SPIRV/Mangler/Refcount.h | 32 |
5 files changed, 87 insertions, 87 deletions
diff --git a/lib/SPIRV/Mangler/Mangler.cpp b/lib/SPIRV/Mangler/Mangler.cpp index 91b99e6..4eed0af 100644 --- a/lib/SPIRV/Mangler/Mangler.cpp +++ b/lib/SPIRV/Mangler/Mangler.cpp @@ -30,14 +30,14 @@ namespace SPIR { class MangleVisitor : public TypeVisitor { public: MangleVisitor(SPIRversion ver, std::stringstream &s) - : TypeVisitor(ver), m_stream(s), seqId(0) {} + : TypeVisitor(ver), Stream(s), seqId(0) {} // // mangle substitution methods // void mangleSequenceID(unsigned SeqID) { if (SeqID == 1) - m_stream << '0'; + Stream << '0'; else if (SeqID > 1) { std::string bstr; std::string charset = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; @@ -46,16 +46,16 @@ public: for (; SeqID != 0; SeqID /= 36) bstr += charset.substr(SeqID % 36, 1); std::reverse(bstr.begin(), bstr.end()); - m_stream << bstr; + Stream << bstr; } - m_stream << '_'; + Stream << '_'; } bool mangleSubstitution(const ParamType *type, std::string typeStr) { size_t fpos; std::stringstream thistypeStr; thistypeStr << typeStr; - if ((fpos = m_stream.str().find(typeStr)) != std::string::npos) { + if ((fpos = Stream.str().find(typeStr)) != std::string::npos) { const char *nType; if (const PointerType *p = SPIR::dyn_cast<PointerType>(type)) { if ((nType = @@ -75,7 +75,7 @@ public: return false; unsigned SeqID = I->second; - m_stream << 'S'; + Stream << 'S'; mangleSequenceID(SeqID); return true; } @@ -88,7 +88,7 @@ public: MangleError visit(const PrimitiveType *t) override { MangleError me = MANGLE_SUCCESS; #if defined(SPIRV_SPIR20_MANGLING_REQUIREMENTS) - m_stream << mangledPrimitiveString(t->getPrimitive()); + Stream << mangledPrimitiveString(t->getPrimitive()); #else std::string mangledPrimitive = std::string(mangledPrimitiveString(t->getPrimitive())); @@ -98,19 +98,19 @@ public: if (mangledPrimitive == "12memory_scope" || mangledPrimitive == "12memory_order") { if (!mangleSubstitution(t, mangledPrimitiveString(t->getPrimitive()))) { - size_t index = m_stream.str().size(); - m_stream << mangledPrimitiveString(t->getPrimitive()); - substitutions[m_stream.str().substr(index)] = seqId++; + size_t index = Stream.str().size(); + Stream << mangledPrimitiveString(t->getPrimitive()); + substitutions[Stream.str().substr(index)] = seqId++; } } else { - m_stream << mangledPrimitive; + Stream << mangledPrimitive; } #endif return me; } MangleError visit(const PointerType *p) override { - size_t fpos = m_stream.str().size(); + size_t fpos = Stream.str().size(); std::string qualStr; MangleError me = MANGLE_SUCCESS; for (unsigned int i = ATTR_QUALIFIER_FIRST; i <= ATTR_QUALIFIER_LAST; i++) { @@ -125,20 +125,20 @@ public: // (but see a comment in the beginning of this file), a pointer type, // or a primitive type with qualifiers (addr. space and/or CV qualifiers). // So, stream "P", type qualifiers - m_stream << "P" << qualStr; + Stream << "P" << qualStr; // and the pointee type itself. me = p->getPointee()->accept(this); // The type qualifiers plus a pointee type is a substitutable entity if (qualStr.length() > 0) - substitutions[m_stream.str().substr(fpos + 1)] = seqId++; + substitutions[Stream.str().substr(fpos + 1)] = seqId++; // The complete pointer type is substitutable as well - substitutions[m_stream.str().substr(fpos)] = seqId++; + substitutions[Stream.str().substr(fpos)] = seqId++; } return me; } MangleError visit(const VectorType *v) override { - size_t index = m_stream.str().size(); + size_t index = Stream.str().size(); std::stringstream typeStr; typeStr << "Dv" << v->getLength() << "_"; MangleError me = MANGLE_SUCCESS; @@ -146,30 +146,30 @@ public: if (!mangleSubstitution(v, typeStr.str())) #endif { - m_stream << typeStr.str(); + Stream << typeStr.str(); me = v->getScalarType()->accept(this); - substitutions[m_stream.str().substr(index)] = seqId++; + substitutions[Stream.str().substr(index)] = seqId++; } return me; } MangleError visit(const AtomicType *p) override { MangleError me = MANGLE_SUCCESS; - size_t index = m_stream.str().size(); + size_t index = Stream.str().size(); const char *typeStr = "U7_Atomic"; if (!mangleSubstitution(p, typeStr)) { - m_stream << typeStr; + Stream << typeStr; me = p->getBaseType()->accept(this); - substitutions[m_stream.str().substr(index)] = seqId++; + substitutions[Stream.str().substr(index)] = seqId++; } return me; } MangleError visit(const BlockType *p) override { - m_stream << "U" + Stream << "U" << "13block_pointerFv"; if (p->getNumOfParams() == 0) - m_stream << "v"; + Stream << "v"; else for (unsigned int i = 0; i < p->getNumOfParams(); ++i) { MangleError err = p->getParam(i)->accept(this); @@ -177,19 +177,19 @@ public: return err; } } - m_stream << "E"; + Stream << "E"; return MANGLE_SUCCESS; } MangleError visit(const UserDefinedType *pTy) override { std::string name = pTy->toString(); - m_stream << name.size() << name; + Stream << name.size() << name; return MANGLE_SUCCESS; } private: // Holds the mangled string representing the prototype of the function. - std::stringstream &m_stream; + std::stringstream &Stream; unsigned seqId; std::map<std::string, unsigned> substitutions; }; @@ -197,7 +197,7 @@ private: // // NameMangler // -NameMangler::NameMangler(SPIRversion version) : m_spir_version(version) {} +NameMangler::NameMangler(SPIRversion version) : Spir_version(version) {} MangleError NameMangler::mangle(const FunctionDescriptor &fd, std::string &mangledName) { @@ -207,14 +207,14 @@ MangleError NameMangler::mangle(const FunctionDescriptor &fd, } std::stringstream ret; ret << "_Z" << fd.name.length() << fd.name; - MangleVisitor visitor(m_spir_version, ret); + MangleVisitor visitor(Spir_version, ret); for (unsigned int i = 0; i < fd.parameters.size(); ++i) { MangleError err = fd.parameters[i]->accept(&visitor); if (err == MANGLE_TYPE_NOT_SUPPORTED) { mangledName.assign("Type "); mangledName.append(fd.parameters[i]->toString()); mangledName.append(" is not supported in "); - std::string ver = getSPIRVersionAsString(m_spir_version); + std::string ver = getSPIRVersionAsString(Spir_version); mangledName.append(ver); return err; } diff --git a/lib/SPIRV/Mangler/NameMangleAPI.h b/lib/SPIRV/Mangler/NameMangleAPI.h index 56d1ec4..c80ec69 100644 --- a/lib/SPIRV/Mangler/NameMangleAPI.h +++ b/lib/SPIRV/Mangler/NameMangleAPI.h @@ -34,7 +34,7 @@ struct NameMangler { MangleError mangle(const FunctionDescriptor &, std::string &); private: - SPIRversion m_spir_version; + SPIRversion Spir_version; }; } // namespace SPIR diff --git a/lib/SPIRV/Mangler/ParameterType.cpp b/lib/SPIRV/Mangler/ParameterType.cpp index 64f4066..7435d88 100644 --- a/lib/SPIRV/Mangler/ParameterType.cpp +++ b/lib/SPIRV/Mangler/ParameterType.cpp @@ -21,7 +21,7 @@ namespace SPIR { // PrimitiveType::PrimitiveType(TypePrimitiveEnum primitive) - : ParamType(TYPE_ID_PRIMITIVE), m_primitive(primitive) {} + : ParamType(TYPE_ID_PRIMITIVE), Primitive(primitive) {} MangleError PrimitiveType::accept(TypeVisitor *visitor) const { if (getSupportedVersion(this->getPrimitive()) >= SPIR20 && @@ -32,16 +32,16 @@ MangleError PrimitiveType::accept(TypeVisitor *visitor) const { } std::string PrimitiveType::toString() const { - assert((m_primitive >= PRIMITIVE_FIRST && m_primitive <= PRIMITIVE_LAST) && + assert((Primitive >= PRIMITIVE_FIRST && Primitive <= PRIMITIVE_LAST) && "illegal primitive"); std::stringstream myName; - myName << readablePrimitiveString(m_primitive); + myName << readablePrimitiveString(Primitive); return myName.str(); } bool PrimitiveType::equals(const ParamType *type) const { const PrimitiveType *p = SPIR::dyn_cast<PrimitiveType>(type); - return p && (m_primitive == p->m_primitive); + return p && (Primitive == p->Primitive); } // @@ -49,11 +49,11 @@ bool PrimitiveType::equals(const ParamType *type) const { // PointerType::PointerType(const RefParamType type) - : ParamType(TYPE_ID_POINTER), m_pType(type) { + : ParamType(TYPE_ID_POINTER), PType(type) { for (unsigned int i = ATTR_QUALIFIER_FIRST; i <= ATTR_QUALIFIER_LAST; i++) { setQualifier((TypeAttributeEnum)i, false); } - m_address_space = ATTR_PRIVATE; + Address_space = ATTR_PRIVATE; } MangleError PointerType::accept(TypeVisitor *visitor) const { @@ -64,25 +64,25 @@ void PointerType::setAddressSpace(TypeAttributeEnum attr) { if (attr < ATTR_ADDR_SPACE_FIRST || attr > ATTR_ADDR_SPACE_LAST) { return; } - m_address_space = attr; + Address_space = attr; } TypeAttributeEnum PointerType::getAddressSpace() const { - return m_address_space; + return Address_space; } void PointerType::setQualifier(TypeAttributeEnum qual, bool enabled) { if (qual < ATTR_QUALIFIER_FIRST || qual > ATTR_QUALIFIER_LAST) { return; } - m_qualifiers[qual - ATTR_QUALIFIER_FIRST] = enabled; + Qualifiers[qual - ATTR_QUALIFIER_FIRST] = enabled; } bool PointerType::hasQualifier(TypeAttributeEnum qual) const { if (qual < ATTR_QUALIFIER_FIRST || qual > ATTR_QUALIFIER_LAST) { return false; } - return m_qualifiers[qual - ATTR_QUALIFIER_FIRST]; + return Qualifiers[qual - ATTR_QUALIFIER_FIRST]; } std::string PointerType::toString() const { @@ -93,7 +93,7 @@ std::string PointerType::toString() const { myName << getReadableAttribute(qual) << " "; } } - myName << getReadableAttribute(TypeAttributeEnum(m_address_space)) << " "; + myName << getReadableAttribute(TypeAttributeEnum(Address_space)) << " "; myName << getPointee()->toString() << " *"; return myName.str(); } @@ -120,7 +120,7 @@ bool PointerType::equals(const ParamType *type) const { // VectorType::VectorType(const RefParamType type, int len) - : ParamType(TYPE_ID_VECTOR), m_pType(type), m_len(len) {} + : ParamType(TYPE_ID_VECTOR), PType(type), Len(len) {} MangleError VectorType::accept(TypeVisitor *visitor) const { return visitor->visit(this); @@ -129,13 +129,13 @@ MangleError VectorType::accept(TypeVisitor *visitor) const { std::string VectorType::toString() const { std::stringstream myName; myName << getScalarType()->toString(); - myName << m_len; + myName << Len; return myName.str(); } bool VectorType::equals(const ParamType *type) const { const VectorType *pVec = SPIR::dyn_cast<VectorType>(type); - return pVec && (m_len == pVec->m_len) && + return pVec && (Len == pVec->Len) && (*getScalarType()).equals(&*(pVec->getScalarType())); } @@ -144,7 +144,7 @@ bool VectorType::equals(const ParamType *type) const { // AtomicType::AtomicType(const RefParamType type) - : ParamType(TYPE_ID_ATOMIC), m_pType(type) {} + : ParamType(TYPE_ID_ATOMIC), PType(type) {} MangleError AtomicType::accept(TypeVisitor *visitor) const { if (visitor->spirVer < SPIR20) { @@ -183,7 +183,7 @@ std::string BlockType::toString() const { for (unsigned int i = 0; i < getNumOfParams(); ++i) { if (i > 0) myName << ", "; - myName << m_params[i]->toString(); + myName << Params[i]->toString(); } myName << ")*"; return myName.str(); @@ -206,7 +206,7 @@ bool BlockType::equals(const ParamType *type) const { // User Defined Type // UserDefinedType::UserDefinedType(const std::string &name) - : ParamType(TYPE_ID_STRUCTURE), m_name(name) {} + : ParamType(TYPE_ID_STRUCTURE), Name(name) {} MangleError UserDefinedType::accept(TypeVisitor *visitor) const { return visitor->visit(this); @@ -214,13 +214,13 @@ MangleError UserDefinedType::accept(TypeVisitor *visitor) const { std::string UserDefinedType::toString() const { std::stringstream myName; - myName << m_name; + myName << Name; return myName.str(); } bool UserDefinedType::equals(const ParamType *pType) const { const UserDefinedType *pTy = SPIR::dyn_cast<UserDefinedType>(pType); - return pTy && (m_name == pTy->m_name); + return pTy && (Name == pTy->Name); } // diff --git a/lib/SPIRV/Mangler/ParameterType.h b/lib/SPIRV/Mangler/ParameterType.h index 31d0627..b3ed4a1 100644 --- a/lib/SPIRV/Mangler/ParameterType.h +++ b/lib/SPIRV/Mangler/ParameterType.h @@ -114,7 +114,7 @@ struct TypeVisitor; struct ParamType { /// @brief Constructor. /// @param TypeEnum type id. - ParamType(TypeEnum typeId) : m_typeId(typeId){}; + ParamType(TypeEnum typeId) : TypeId(typeId){}; /// @brief Destructor. virtual ~ParamType(){}; @@ -141,7 +141,7 @@ struct ParamType { /// @brief Returns type id of underlying type. /// @return type id. - TypeEnum getTypeId() const { return m_typeId; } + TypeEnum getTypeId() const { return TypeId; } private: // @brief Default Constructor. @@ -149,7 +149,7 @@ private: protected: /// An enumeration to identify the type id of this instance. - TypeEnum m_typeId; + TypeEnum TypeId; }; struct PrimitiveType : public ParamType { @@ -182,11 +182,11 @@ struct PrimitiveType : public ParamType { /// @brief Returns the primitive enumeration of the type. /// @return primitive type. - TypePrimitiveEnum getPrimitive() const { return m_primitive; } + TypePrimitiveEnum getPrimitive() const { return Primitive; } protected: /// An enumeration to identify the primitive type. - TypePrimitiveEnum m_primitive; + TypePrimitiveEnum Primitive; }; struct PointerType : public ParamType { @@ -219,7 +219,7 @@ struct PointerType : public ParamType { /// @brief Returns the type the pointer is pointing at. /// @return pointee type. - const RefParamType &getPointee() const { return m_pType; } + const RefParamType &getPointee() const { return PType; } /// @brief Sets the address space attribute - default is __private /// @param TypeAttributeEnum address space attribute id. @@ -242,11 +242,11 @@ struct PointerType : public ParamType { private: /// The type this pointer is pointing at. - RefParamType m_pType; + RefParamType PType; /// Array of the pointer's enabled type qualifiers. - bool m_qualifiers[ATTR_QUALIFIER_LAST - ATTR_QUALIFIER_FIRST + 1]; + bool Qualifiers[ATTR_QUALIFIER_LAST - ATTR_QUALIFIER_FIRST + 1]; /// Pointer's address space. - TypeAttributeEnum m_address_space; + TypeAttributeEnum Address_space; }; struct VectorType : public ParamType { @@ -280,17 +280,17 @@ struct VectorType : public ParamType { /// @brief Returns the type the vector is packing. /// @return scalar type. - const RefParamType &getScalarType() const { return m_pType; } + const RefParamType &getScalarType() const { return PType; } /// @brief Returns the length of the vector type. /// @return vector type length. - int getLength() const { return m_len; } + int getLength() const { return Len; } private: /// The scalar type of this vector type. - RefParamType m_pType; + RefParamType PType; /// The length of the vector. - int m_len; + int Len; }; struct AtomicType : public ParamType { @@ -322,11 +322,11 @@ struct AtomicType : public ParamType { /// @brief returns the base type of the atomic parameter. /// @return base type - const RefParamType &getBaseType() const { return m_pType; } + const RefParamType &getBaseType() const { return PType; } private: /// the type this pointer is pointing at - RefParamType m_pType; + RefParamType PType; }; struct BlockType : public ParamType { @@ -357,14 +357,14 @@ struct BlockType : public ParamType { /// @brief returns the number of parameters of the block. /// @return parameters count - unsigned int getNumOfParams() const { return (unsigned int)m_params.size(); } + unsigned int getNumOfParams() const { return (unsigned int)Params.size(); } ///@brief returns the type of parameter "index" of the block. // @param index the sequential number of the queried parameter ///@return parameter type const RefParamType &getParam(unsigned int index) const { - assert(m_params.size() > index && "index is OOB"); - return m_params[index]; + assert(Params.size() > index && "index is OOB"); + return Params[index]; } ///@brief set the type of parameter "index" of the block. @@ -372,9 +372,9 @@ struct BlockType : public ParamType { // @param type the parameter type void setParam(unsigned int index, RefParamType type) { if (index < getNumOfParams()) { - m_params[index] = type; + Params[index] = type; } else if (index == getNumOfParams()) { - m_params.push_back(type); + Params.push_back(type); } else { assert(false && "index is OOB"); } @@ -382,7 +382,7 @@ struct BlockType : public ParamType { protected: /// an enumeration to identify the primitive type - std::vector<RefParamType> m_params; + std::vector<RefParamType> Params; }; struct UserDefinedType : public ParamType { @@ -412,7 +412,7 @@ struct UserDefinedType : public ParamType { protected: /// The name of the user defined type. - std::string m_name; + std::string Name; }; /// @brief Can be overridden so an object of static type Type* will diff --git a/lib/SPIRV/Mangler/Refcount.h b/lib/SPIRV/Mangler/Refcount.h index 0ff1d81..43a9393 100644 --- a/lib/SPIRV/Mangler/Refcount.h +++ b/lib/SPIRV/Mangler/Refcount.h @@ -19,9 +19,9 @@ namespace SPIR { template <typename T> class RefCount { public: - RefCount() : Count(0), m_ptr(0) {} + RefCount() : Count(0), Ptr(0) {} - RefCount(T *ptr) : m_ptr(ptr) { Count = new int(1); } + RefCount(T *ptr) : Ptr(ptr) { Count = new int(1); } RefCount(const RefCount<T> &other) { cpy(other); } @@ -40,43 +40,43 @@ public: } void init(T *ptr) { - assert(!m_ptr && "overrunning non NULL pointer"); + assert(!Ptr && "overrunning non NULL pointer"); assert(!Count && "overrunning non NULL pointer"); Count = new int(1); - m_ptr = ptr; + Ptr = ptr; } - bool isNull() const { return (!m_ptr); } + bool isNull() const { return (!Ptr); } // Pointer access const T &operator*() const { sanity(); - return *m_ptr; + return *Ptr; } T &operator*() { sanity(); - return *m_ptr; + return *Ptr; } - operator T *() { return m_ptr; } + operator T *() { return Ptr; } - operator const T *() const { return m_ptr; } + operator const T *() const { return Ptr; } - T *operator->() { return m_ptr; } + T *operator->() { return Ptr; } - const T *operator->() const { return m_ptr; } + const T *operator->() const { return Ptr; } private: void sanity() const { - assert(m_ptr && "NULL pointer"); + assert(Ptr && "NULL pointer"); assert(Count && "NULL ref counter"); assert(*Count && "zero ref counter"); } void cpy(const RefCount<T> &other) { Count = other.Count; - m_ptr = other.m_ptr; + Ptr = other.Ptr; if (Count) ++*Count; } @@ -85,14 +85,14 @@ private: sanity(); if (0 == --*Count) { delete Count; - delete m_ptr; - m_ptr = 0; + delete Ptr; + Ptr = 0; Count = 0; } } int *Count; - T *m_ptr; + T *Ptr; }; // End RefCount } // namespace SPIR |