From 3f0cf6d6ac56049745968554376e6e5e6b17e691 Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Tue, 15 Feb 2022 14:56:48 +0100 Subject: [PATCH] CppEditor: Do not consider generated access specifiers ... when looking for places to insert class members. Apparently, these can come from other translation units and thus have invalid offsets. Fixes: QTCREATORBUG-27063 Change-Id: Ia9a318284c0a8f4dd280315a5b47eac7ffd96a30 Reviewed-by: Reviewed-by: Qt CI Bot Reviewed-by: Christian Stenger --- src/plugins/cppeditor/insertionpointlocator.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/plugins/cppeditor/insertionpointlocator.cpp b/src/plugins/cppeditor/insertionpointlocator.cpp index 7d657bacc3b..fceb9a96055 100644 --- a/src/plugins/cppeditor/insertionpointlocator.cpp +++ b/src/plugins/cppeditor/insertionpointlocator.cpp @@ -177,6 +177,8 @@ QList collectAccessRanges(const CPlusPlus::TranslationUnit *tu, if (AccessDeclarationAST *xsDecl = decl->asAccessDeclaration()) { const unsigned token = xsDecl->access_specifier_token; + if (tu->tokenAt(token).generated()) + continue; InsertionPointLocator::AccessSpec newXsSpec = initialXs; bool isSlot = xsDecl->slots_token && tu->tokenKind(xsDecl->slots_token) == T_Q_SLOTS;