diff --git a/src/tools/clangbackend/source/tokeninfo.cpp b/src/tools/clangbackend/source/tokeninfo.cpp index 8e380b639c7..76f6595a66d 100644 --- a/src/tools/clangbackend/source/tokeninfo.cpp +++ b/src/tools/clangbackend/source/tokeninfo.cpp @@ -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); diff --git a/tests/unit/unittest/data/highlightingmarks.cpp b/tests/unit/unittest/data/highlightingmarks.cpp index f4c9aa74bbb..79bca7d40d6 100644 --- a/tests/unit/unittest/data/highlightingmarks.cpp +++ b/tests/unit/unittest/data/highlightingmarks.cpp @@ -788,3 +788,7 @@ static inline constexpr vecn operator<(vecn a, vecn b) } return x; } + +struct foo { +#define blubb +}; diff --git a/tests/unit/unittest/tokenprocessor-test.cpp b/tests/unit/unittest/tokenprocessor-test.cpp index b7ebeba692e..b6acb918aba 100644 --- a/tests/unit/unittest/tokenprocessor-test.cpp +++ b/tests/unit/unittest/tokenprocessor-test.cpp @@ -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()