From a17ded3862948738d416535c3e4538e882fda835 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Mon, 13 Jan 2020 13:16:02 +0100 Subject: [PATCH] Clang import; handle {} that is not a scope better --- lib/clangimport.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/clangimport.cpp b/lib/clangimport.cpp index 01cd665bd..10f2bb549 100644 --- a/lib/clangimport.cpp +++ b/lib/clangimport.cpp @@ -179,6 +179,8 @@ namespace clangimport { return ret; } + // "}" tokens that are not end-of-scope + std::set mNotScope; private: void notFound(const std::string &addr) { auto it = mNotFound.find(addr); @@ -217,6 +219,7 @@ namespace clangimport { createTokens(tokenList); if (nodeType == VarDecl || nodeType == RecordDecl || nodeType == TypedefDecl) addtoken(tokenList, ";"); + mData->mNotScope.clear(); } private: Token *createTokens(TokenList *tokenList); @@ -388,7 +391,7 @@ const Scope *clangimport::AstNode::getNestedInScope(TokenList *tokenList) { if (!tokenList->back()) return &mData->mSymbolDatabase->scopeList.front(); - if (tokenList->back()->str() == "}" && !tokenList->back()->link()->astParent()) + if (tokenList->back()->str() == "}" && mData->mNotScope.find(tokenList->back()) == mData->mNotScope.end()) return tokenList->back()->scope()->nestedIn; return tokenList->back()->scope(); } @@ -666,6 +669,7 @@ Token *clangimport::AstNode::createTokens(TokenList *tokenList) end->scope(scope); start->link(end); end->link(start); + mData->mNotScope.insert(end); return start; } if (nodeType == IntegerLiteral)