Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 6435b362 authored by Sergey Vidyuk's avatar Sergey Vidyuk Committed by Aleix Pol Gonzalez

Support return statement

REVIEW: 111135
BUG: 320875
parent 1726c5c0
......@@ -59,7 +59,7 @@ bool isGenerated(const QString& name)
CMakeProjectVisitor::message_callback CMakeProjectVisitor::s_msgcallback=debugMsgs;
CMakeProjectVisitor::CMakeProjectVisitor(const QString& root, ReferencedTopDUContext parent)
: m_root(root), m_vars(0), m_macros(0), m_topctx(0), m_parentCtx(parent), m_hitBreak(false)
: m_root(root), m_vars(0), m_macros(0), m_topctx(0), m_parentCtx(parent), m_hitBreak(false), m_hitReturn(false)
{
}
......@@ -1241,6 +1241,7 @@ int CMakeProjectVisitor::visit(const MacroCallAst *call)
kDebug(9042) << "visited!" << call->name() <<
m_vars->value("ARGV") << "_" << m_vars->value("ARGN") << "..." << len;
m_hitReturn = false;
if(isfunc)
m_vars->popScope();
//Restoring
......@@ -2200,7 +2201,7 @@ CMakeFunctionDesc CMakeProjectVisitor::resolveVariables(const CMakeFunctionDesc
return ret;
}
enum RecursivityType { No, Yes, End, Break };
enum RecursivityType { No, Yes, End, Break, Return };
RecursivityType recursivity(const QString& functionName)
{
......@@ -2212,6 +2213,8 @@ RecursivityType recursivity(const QString& functionName)
return End;
else if(upperFunctioName=="break")
return Break;
else if(upperFunctioName=="return")
return Return;
return No;
}
......@@ -2249,7 +2252,7 @@ int CMakeProjectVisitor::walk(const CMakeFileContent & fc, int line, bool isClea
// kDebug(9042) << "At line" << line << "/" << fc.count();
RecursivityType r = recursivity(it->name);
if(r==End || r==Break || m_hitBreak)
if(r==End || r==Break || r==Return || m_hitBreak || m_hitReturn)
{
// kDebug(9042) << "Found an end." << func.writeBack();
m_backtrace.pop();
......@@ -2257,6 +2260,8 @@ int CMakeProjectVisitor::walk(const CMakeFileContent & fc, int line, bool isClea
if(r==Break)
m_hitBreak=true;
if(r==Return)
m_hitReturn=true;
return line;
}
......
......@@ -203,6 +203,7 @@ class KDEVCMAKECOMMON_EXPORT CMakeProjectVisitor : CMakeAstVisitor
KDevelop::ReferencedTopDUContext m_topctx;
KDevelop::ReferencedTopDUContext m_parentCtx;
bool m_hitBreak;
bool m_hitReturn;
QMap<QString, QString> m_environmentProfile;
QList<Test> m_testSuites;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment