diff --git a/language/duchain/declaration.h b/language/duchain/declaration.h --- a/language/duchain/declaration.h +++ b/language/duchain/declaration.h @@ -54,14 +54,14 @@ { public: /// Access types - enum AccessPolicy { + enum AccessPolicy : quint8 { Public /**< a public declaration */, Protected /**< a protected declaration */, Private /**< a private declaration */, DefaultAccess /** void setClassId(T*) { + static_assert(T::Identity < std::numeric_limits::max(), "Class ID out of bounds"); classId = T::Identity; } diff --git a/language/duchain/ducontext.h b/language/duchain/ducontext.h --- a/language/duchain/ducontext.h +++ b/language/duchain/ducontext.h @@ -95,7 +95,7 @@ */ virtual ~DUContext(); - enum ContextType { + enum ContextType : quint8 { Global /**< A context that declares functions, namespaces or classes */, Namespace /**< A context that declares namespace members */, Class /**< A context that declares class members */, diff --git a/language/duchain/ducontextdata.h b/language/duchain/ducontextdata.h --- a/language/duchain/ducontextdata.h +++ b/language/duchain/ducontextdata.h @@ -48,7 +48,7 @@ DUContextData(); ~DUContextData(); DUContextData(const DUContextData& rhs); - DUContext::ContextType m_contextType; + IndexedQualifiedIdentifier m_scopeIdentifier; IndexedDeclaration m_owner; typedef DUContext::Import Import; @@ -69,6 +69,7 @@ APPENDED_LIST(DUContextData, Use, m_uses, m_localDeclarations); END_APPENDED_LISTS(DUContextData, m_uses); + DUContext::ContextType m_contextType; bool m_inSymbolTable : 1; bool m_anonymousInParent : 1; //Whether this context was added anonymously into the parent. This means that it cannot be found as child-context in the parent. bool m_propagateDeclarations : 1; diff --git a/language/duchain/topducontext.h b/language/duchain/topducontext.h --- a/language/duchain/topducontext.h +++ b/language/duchain/topducontext.h @@ -177,7 +177,7 @@ Identity = 4 }; - enum Features { + enum Features : quint16 { ///Top-context features standard that can be requested from the duchain, and that are stored in the features() member. Empty = 0, //Only the top-context structure (imports etc.) is built, but no declarations and no contexts SimplifiedVisibleDeclarationsAndContexts = 2, //The top-context should only contain publically simplified accessible declarations and contexts, without doing type look-up, diff --git a/language/duchain/topducontext.cpp b/language/duchain/topducontext.cpp --- a/language/duchain/topducontext.cpp +++ b/language/duchain/topducontext.cpp @@ -916,7 +916,6 @@ bool TopDUContext::deleting() const { - ///@todo remove d_func()->m_deleting, not used any more return m_dynamicData->m_deleting; } diff --git a/language/duchain/topducontextdata.h b/language/duchain/topducontextdata.h --- a/language/duchain/topducontextdata.h +++ b/language/duchain/topducontextdata.h @@ -38,7 +38,6 @@ public: explicit TopDUContextData(IndexedString url) : DUContextData() - , m_deleting(false) , m_url(url) , m_ownIndex(0) , m_currentUsedDeclarationIndex(0) @@ -48,7 +47,6 @@ TopDUContextData(const TopDUContextData& rhs) : DUContextData(rhs) - , m_deleting(false) { initializeAppendedLists(); copyListsFrom(rhs); @@ -65,8 +63,6 @@ TopDUContext::Features m_features; - bool m_deleting : 1; ///@todo remove - IndexedString m_url; uint m_ownIndex; diff --git a/language/duchain/types/abstracttype.h b/language/duchain/types/abstracttype.h --- a/language/duchain/types/abstracttype.h +++ b/language/duchain/types/abstracttype.h @@ -99,8 +99,9 @@ * and attributes of specific Declarations like public/private should be stored in * the Declarations themselves, not in the type-system. */ - enum CommonModifiers { + enum CommonModifiers : quint32 { NoModifiers = 0, + ConstModifier = 1 << 0, VolatileModifier = 1 << 1, TransientModifier = 1 << 2, @@ -113,7 +114,8 @@ LongLongModifier = 1 << 9, SignedModifier = 1 << 10, UnsignedModifier = 1 << 11, - LanguageSpecificModifier = 1 << 12 //TODO make this support 64 bit values + + LanguageSpecificModifier = 1 << 12 }; /// Constructor. @@ -128,14 +130,14 @@ * * \returns the type's modifiers. */ - quint64 modifiers() const; + quint32 modifiers() const; /** * Set the type's modifiers. * * \param modifiers modifiers of this type. */ - void setModifiers(quint64 modifiers); + void setModifiers(quint32 modifiers); /** * Visitor method. Called by TypeVisitor to visit the type heirachy. @@ -184,7 +186,7 @@ IndexedType indexed() const; /// Enumeration of major data types. - enum WhichType { + enum WhichType : quint8 { TypeAbstract /**< an abstract type */, TypeIntegral /**< an integral */, TypePointer /**< a pointer*/, diff --git a/language/duchain/types/abstracttype.cpp b/language/duchain/types/abstracttype.cpp --- a/language/duchain/types/abstracttype.cpp +++ b/language/duchain/types/abstracttype.cpp @@ -47,12 +47,12 @@ { } -quint64 AbstractType::modifiers() const +quint32 AbstractType::modifiers() const { return d_func()->m_modifiers; } -void AbstractType::setModifiers(quint64 modifiers) +void AbstractType::setModifiers(quint32 modifiers) { d_func_dynamic()->m_modifiers = modifiers; } diff --git a/language/duchain/types/delayedtype.h b/language/duchain/types/delayedtype.h --- a/language/duchain/types/delayedtype.h +++ b/language/duchain/types/delayedtype.h @@ -42,7 +42,7 @@ typedef TypePtr Ptr; /// An enumeration of - enum Kind { + enum Kind : quint8 { Delayed /**< The type should be resolved later. This is the default. */, Unresolved /**< The type could not be resolved */ }; diff --git a/language/duchain/types/typesystem.cpp b/language/duchain/types/typesystem.cpp --- a/language/duchain/types/typesystem.cpp +++ b/language/duchain/types/typesystem.cpp @@ -31,8 +31,9 @@ { AbstractTypeData::AbstractTypeData() - : m_modifiers(AbstractType::NoModifiers) - , inRepository(false), refCount(0) + : refCount(0) + , m_modifiers(AbstractType::NoModifiers) + , inRepository(false) { initializeAppendedLists(true); } @@ -51,8 +52,9 @@ } AbstractTypeData::AbstractTypeData( const AbstractTypeData& rhs ) - : m_modifiers(rhs.m_modifiers) - , inRepository(false), refCount(0) + : refCount(0) + , m_modifiers(rhs.m_modifiers) + , inRepository(false) { initializeAppendedLists(!rhs.m_dynamic); //This type will be dynamic exactly if the copied one is not. typeClassId = rhs.typeClassId; diff --git a/language/duchain/types/typesystemdata.h b/language/duchain/types/typesystemdata.h --- a/language/duchain/types/typesystemdata.h +++ b/language/duchain/types/typesystemdata.h @@ -68,20 +68,21 @@ */ template void setTypeClassId() { + static_assert(T::Identity < std::numeric_limits::max(), "TypeClass ID out of bounds"); typeClassId = T::Identity; } - /// Remember which type this data was created for. \sa setTypeClassId() - uint typeClassId; + /// Reference-count for this type within the repository. Not used for comparison or hashes. + uint refCount; /// Type modifier flags - quint64 m_modifiers; + quint32 m_modifiers; + + /// Remember which type this data was created for. \sa setTypeClassId() + quint16 typeClassId; /// Remember whether this type is in a TypeRepository. Not used for comparison or hashes. bool inRepository : 1; - - /// Reference-count for this type within the repository. Not used for comparison or hashes. - uint refCount; APPENDED_LISTS_STUB(AbstractTypeData)