clangbackend: Add another exception to our "find real cursor" heuristic

Leave preprocessor directives alone.

Fixes: QTCREATORBUG-25692
Change-Id: I1c31f4120e9b86a58123f8877cebd354e800fb8b
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
Christian Kandeler
2021-05-14 11:28:29 +02:00
parent ba83b852b6
commit 2182993b97
3 changed files with 13 additions and 1 deletions

View File

@@ -380,7 +380,9 @@ void TokenInfo::identifierKind(const Cursor &cursor, Recursion recursion)
if (cursor.isInvalidDeclaration())
return;
if (recursion == Recursion::FirstPass && cursor.kind() != CXCursor_NotImplemented) {
if (recursion == Recursion::FirstPass
&& cursor.kind() != CXCursor_NotImplemented
&& cursor.kind() != CXCursor_PreprocessingDirective) {
const Cursor c = realCursor(cursor);
if (!clang_isInvalid(c.kind()) && c != cursor) {
identifierKind(c, Recursion::FirstPass);

View File

@@ -788,3 +788,7 @@ static inline constexpr vecn<T, S> operator<(vecn<T, S> a, vecn<T, S> b)
}
return x;
}
struct foo {
#define blubb
};

View File

@@ -1807,6 +1807,12 @@ TEST_F(TokenProcessor, OperatorInTemplate)
ASSERT_THAT(infos[9], HasOnlyType(HighlightingType::Punctuation));
}
TEST_F(TokenProcessor, PreProcessorInStruct)
{
const auto infos = translationUnit.tokenInfosInRange(sourceRange(793, 14));
ASSERT_THAT(infos[1], HasOnlyType(HighlightingType::Preprocessor));
}
Data *TokenProcessor::d;
void TokenProcessor::SetUpTestCase()