diff --git a/src/plugins/clangcodemodel/clangoverviewmodel.cpp b/src/plugins/clangcodemodel/clangoverviewmodel.cpp index 22a2576b716..e7e5671d4b5 100644 --- a/src/plugins/clangcodemodel/clangoverviewmodel.cpp +++ b/src/plugins/clangcodemodel/clangoverviewmodel.cpp @@ -80,6 +80,17 @@ void buildTree(const TokenContainers &containers, if (lexicalParentIndex >= 0 && treeItemCache[lexicalParentIndex]) parent = treeItemCache[lexicalParentIndex]; + if (parent != root + && (container.extraInfo.storageClass == ClangBackEnd::StorageClass::Extern + || container.extraInfo.storageClass == ClangBackEnd::StorageClass::Static)) { + ClangBackEnd::HighlightingType parentType = parent->token.types.mainHighlightingType; + if (parentType == ClangBackEnd::HighlightingType::VirtualFunction + || parentType == ClangBackEnd::HighlightingType::Function) { + // Treat static and extern variables inside a function scope as local variables. + continue; + } + } + parent->appendChild(item.release()); }