From d643918761969eebcafbc2514f91f8520fc264d0 Mon Sep 17 00:00:00 2001 From: Robert Reif Date: Thu, 24 Mar 2011 22:08:18 -0400 Subject: [PATCH] symbol database: add a link from a Function to its Function Scope namd make function parameters belong to Function Scope --- lib/symboldatabase.cpp | 6 ++++-- lib/symboldatabase.h | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index bacf7ccd5..1083e5b5f 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -287,6 +287,7 @@ SymbolDatabase::SymbolDatabase(const Tokenizer *tokenizer, const Settings *setti { scope->functionOf = functionOf; scope->function = &functionOf->functionList.back(); + scope->function->functionScope = scope; } tok = tok2; @@ -980,7 +981,8 @@ void SymbolDatabase::addFunction(Scope **scope, const Token **tok, const Token * if (*scope) { (*scope)->functionOf = scope1; - (*scope)->function = &scope1->functionList.back(); + (*scope)->function = &*func; + (*scope)->function->functionScope = *scope; added = true; } @@ -1253,7 +1255,7 @@ void Function::addArguments(const SymbolDatabase *symbolDatabase, const Scope *s bool isClassVar = startTok == endTok && !startTok->isStandardType(); - argumentList.push_back(Variable(nameTok, startTok, endTok, count++, Argument, false, false, isConstVar, isClassVar, argType, scope, isArrayVar)); + argumentList.push_back(Variable(nameTok, startTok, endTok, count++, Argument, false, false, isConstVar, isClassVar, argType, functionScope, isArrayVar)); if (tok->str() == ")") break; diff --git a/lib/symboldatabase.h b/lib/symboldatabase.h index 37f94d59c..f3c70c5be 100644 --- a/lib/symboldatabase.h +++ b/lib/symboldatabase.h @@ -332,7 +332,8 @@ public: isExplicit(false), isOperator(false), retFuncPtr(false), - type(eFunction) + type(eFunction), + functionScope(NULL) { } @@ -357,6 +358,7 @@ public: bool isOperator; // is operator bool retFuncPtr; // returns function pointer Type type; // constructor, destructor, ... + Scope *functionScope; // scope of function body std::list argumentList; // argument list };