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>
This commit is contained in:
Ivan Donchevskii
2018-08-23 09:13:31 +02:00
parent 75c95d4b73
commit ad5336a028
2 changed files with 13 additions and 2 deletions

View File

@@ -135,8 +135,10 @@ static Utils::Link linkAtCursor(const QTextCursor &cursor,
return token; return token;
} }
if (mark.extraInfo.identifier || mark.extraInfo.token == "operator") if (mark.extraInfo.identifier || mark.extraInfo.token == "operator"
|| mark.extraInfo.token == "auto") {
return token; return token;
}
return Link(); return Link();
} }

View File

@@ -151,8 +151,17 @@ FollowSymbolResult FollowSymbol::followSymbol(CXTranslationUnit tu,
} }
// For definitions we can always find a declaration in current 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); return extractMatchingTokenRange(cursor.canonical(), tokenSpelling);
}
if (!cursor.isDeclaration()) { if (!cursor.isDeclaration()) {
// This is the symbol usage // This is the symbol usage