diff options
author | Ivan Donchevskii <ivan.donchevskii@qt.io> | 2018-08-23 09:13:31 +0200 |
---|---|---|
committer | Ivan Donchevskii <ivan.donchevskii@qt.io> | 2018-09-12 10:44:44 +0000 |
commit | ad5336a028917a526f89ea1fae12c8dc4761409d (patch) | |
tree | a0c8db24cf60aaf2bc8c41ad8972405a273fcdec /src/tools | |
parent | 75c95d4b73842d51b6016a082a0ebd9daa6baba6 (diff) | |
download | qt-creator-ad5336a028917a526f89ea1fae12c8dc4761409d.tar.gz |
Clang: Enable follow symbol for 'auto' keyword
It will follow to the Type which is deduced from auto
or to the pointee type if auto is deduced to pointer.
Task-number: QTCREATORBUG-17191
Change-Id: I57db3f9b68c3da861691ab148fe39774ad5fceec
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
Diffstat (limited to 'src/tools')
-rw-r--r-- | src/tools/clangbackend/source/clangfollowsymbol.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/tools/clangbackend/source/clangfollowsymbol.cpp b/src/tools/clangbackend/source/clangfollowsymbol.cpp index 2dcdca4bef..b32b71573e 100644 --- a/src/tools/clangbackend/source/clangfollowsymbol.cpp +++ b/src/tools/clangbackend/source/clangfollowsymbol.cpp @@ -151,8 +151,17 @@ FollowSymbolResult FollowSymbol::followSymbol(CXTranslationUnit tu, } // For definitions we can always find a declaration in current TU - if (cursor.isDefinition()) + if (cursor.isDefinition()) { + if (tokenSpelling == "auto") { + Type type = cursor.type().pointeeType(); + if (!type.isValid()) + type = cursor.type(); + const Cursor declCursor = type.declaration(); + return extractMatchingTokenRange(declCursor, declCursor.spelling()); + } + return extractMatchingTokenRange(cursor.canonical(), tokenSpelling); + } if (!cursor.isDeclaration()) { // This is the symbol usage |