diff options
author | Christian Kandeler <christian.kandeler@qt.io> | 2020-11-18 18:04:21 +0100 |
---|---|---|
committer | Christian Kandeler <christian.kandeler@qt.io> | 2020-11-23 10:07:20 +0000 |
commit | d3fafcde0fd4f74112d20228ac7175a02ffcb821 (patch) | |
tree | d053af9a59ced07acc03384154b3ffc410185a2c /src/libs/3rdparty/cplusplus/Scope.cpp | |
parent | b0dd6b748f68af8b53d5c3fc470e5758ddf969de (diff) |
CppEditor: Support decl/def switch for conversion operators
Fixes: QTCREATORBUG-21168
Change-Id: I515fe146a679e007c96fa8d23f1457dadf07db3c
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Diffstat (limited to 'src/libs/3rdparty/cplusplus/Scope.cpp')
-rw-r--r-- | src/libs/3rdparty/cplusplus/Scope.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/libs/3rdparty/cplusplus/Scope.cpp b/src/libs/3rdparty/cplusplus/Scope.cpp index 43d8c98965..dcafc0c066 100644 --- a/src/libs/3rdparty/cplusplus/Scope.cpp +++ b/src/libs/3rdparty/cplusplus/Scope.cpp @@ -71,6 +71,7 @@ public: Symbol *lookat(const Identifier *id) const; Symbol *lookat(OperatorNameId::Kind operatorId) const; + Symbol *lookat(const ConversionNameId *convId) const; private: /// Returns the hash value for the given Symbol. @@ -181,6 +182,23 @@ Symbol *SymbolTable::lookat(OperatorNameId::Kind operatorId) const return symbol; } +Symbol *SymbolTable::lookat(const ConversionNameId *convId) const +{ + if (!_hash) + return nullptr; + + Symbol *symbol = _hash[0]; // See Symbol::HashCode + for (; symbol; symbol = symbol->_next) { + if (const Name *identity = symbol->unqualifiedName()) { + if (const ConversionNameId * const id = identity->asConversionNameId()) { + if (id->type().match(convId->type())) + break; + } + } + } + return symbol; +} + void SymbolTable::rehash() { _hashSize <<= 1; @@ -281,6 +299,9 @@ Symbol *Scope::find(const Identifier *id) const Symbol *Scope::find(OperatorNameId::Kind operatorId) const { return _members ? _members->lookat(operatorId) : nullptr; } +Symbol *Scope::find(const ConversionNameId *conv) const +{ return _members ? _members->lookat(conv) : nullptr; } + /// Set the start offset of the scope int Scope::startOffset() const { return _startOffset; } |