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 : uchar { Public /**< a public declaration */, Protected /**< a protected declaration */, Private /**< a private declaration */, DefaultAccess /** ret; - if(m_direct == false) { + if(m_isDirect == false) { //Find the declaration by its qualified identifier and additionalIdentity - QualifiedIdentifier id(indirect.m_identifier); + QualifiedIdentifier id(m_indirectData.identifier); if(top) { //Do filtering PersistentSymbolTable::FilteredDeclarationIterator filter = PersistentSymbolTable::self().getFilteredDeclarations(id, top->recursiveImportIndices()); for(; filter; ++filter) { Declaration* decl = filter->data(); - if(decl && indirect.m_additionalIdentity == decl->additionalIdentity()) { + if(decl && m_indirectData.additionalIdentity == decl->additionalIdentity()) { //Hit ret.append(decl); } @@ -97,15 +127,15 @@ if(!top) { Declaration* decl = iDecl.data(); - if(decl && indirect.m_additionalIdentity == decl->additionalIdentity()) { + if(decl && m_indirectData.additionalIdentity == decl->additionalIdentity()) { //Hit ret.append(decl); } } } } }else{ - Declaration* decl = direct.declaration(); + Declaration* decl = m_directData.declaration(); if(decl) ret.append(decl); } @@ -126,17 +156,17 @@ { Declaration* ret = 0; - if(m_direct == false) { + if(m_isDirect == false) { //Find the declaration by its qualified identifier and additionalIdentity - QualifiedIdentifier id(indirect.m_identifier); + QualifiedIdentifier id(m_indirectData.identifier); if(top) { //Do filtering PersistentSymbolTable::FilteredDeclarationIterator filter = PersistentSymbolTable::self().getFilteredDeclarations(id, top->recursiveImportIndices()); for(; filter; ++filter) { Declaration* decl = filter->data(); - if(decl && indirect.m_additionalIdentity == decl->additionalIdentity()) { + if(decl && m_indirectData.additionalIdentity == decl->additionalIdentity()) { //Hit ret = decl; if(!ret->isForwardDeclaration()) @@ -157,7 +187,7 @@ if(!top) { Declaration* decl = iDecl.data(); - if(decl && indirect.m_additionalIdentity == decl->additionalIdentity()) { + if(decl && m_indirectData.additionalIdentity == decl->additionalIdentity()) { //Hit ret = decl; if(!ret->isForwardDeclaration()) @@ -168,7 +198,7 @@ } }else{ //Find the declaration by m_topContext and m_declaration - ret = direct.declaration(); + ret = m_directData.declaration(); } @@ -193,8 +223,8 @@ QualifiedIdentifier DeclarationId::qualifiedIdentifier() const { - if(!m_direct) { - QualifiedIdentifier baseIdentifier = indirect.m_identifier.identifier(); + if(!m_isDirect) { + QualifiedIdentifier baseIdentifier = m_indirectData.identifier.identifier(); if(!m_specialization.index()) return baseIdentifier; return m_specialization.information().applyToIdentifier(baseIdentifier); @@ -206,7 +236,7 @@ return QualifiedIdentifier(i18n("(unknown direct declaration)")); } - return QualifiedIdentifier(i18n("(missing)")) + indirect.m_identifier.identifier(); + return QualifiedIdentifier(i18n("(missing)")) + m_indirectData.identifier.identifier(); } } diff --git a/language/duchain/duchainbase.h b/language/duchain/duchainbase.h --- a/language/duchain/duchainbase.h +++ b/language/duchain/duchainbase.h @@ -76,7 +76,7 @@ APPENDED_LISTS_STUB(DUChainBaseData) - uint classId; + quint16 classId; bool isDynamic() const { return m_dynamic; @@ -90,6 +90,7 @@ */ template 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 : uchar { 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 : ushort { ///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 @@ -101,6 +101,7 @@ */ enum CommonModifiers { 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 << 16 }; /// 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 : uchar { 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 : uchar { 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)