Add debug info for macro expansion
This commit is contained in:
parent
b287464b98
commit
85ef5986bf
|
@ -1359,7 +1359,7 @@ QString CppPreprocessor::expandDefines(QString line)
|
||||||
if ((tail < line.length()) && (line[tail]=='(')) {
|
if ((tail < line.length()) && (line[tail]=='(')) {
|
||||||
//braced argument (next word)
|
//braced argument (next word)
|
||||||
defineStart = tail+1;
|
defineStart = tail+1;
|
||||||
if (!skipBraces(line, tail)) {
|
if (!skipParenthesis(line, tail)) {
|
||||||
line = ""; // broken line
|
line = ""; // broken line
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1400,10 +1400,13 @@ QString CppPreprocessor::expandDefines(QString line)
|
||||||
// It is a function. Expand arguments
|
// It is a function. Expand arguments
|
||||||
if ((tail < line.length()) && (line[tail] == '(')) {
|
if ((tail < line.length()) && (line[tail] == '(')) {
|
||||||
head=tail;
|
head=tail;
|
||||||
if (skipBraces(line, tail)) {
|
if (skipParenthesis(line, tail)) {
|
||||||
// qDebug()<<"3 "<<line<<head<<tail;
|
if (name == "__has_builtin") {
|
||||||
QString args = line.mid(head,tail-head+1);
|
insertValue = "0";
|
||||||
insertValue = expandFunction(define,args);
|
} else {
|
||||||
|
QString args = line.mid(head+1,tail-head-1);
|
||||||
|
insertValue = expandFunction(define,args);
|
||||||
|
}
|
||||||
nameEnd = tail+1;
|
nameEnd = tail+1;
|
||||||
} else {
|
} else {
|
||||||
line = "";// broken line
|
line = "";// broken line
|
||||||
|
@ -1428,7 +1431,7 @@ QString CppPreprocessor::expandDefines(QString line)
|
||||||
return line;
|
return line;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CppPreprocessor::skipBraces(const QString &line, int &index, int step)
|
bool CppPreprocessor::skipParenthesis(const QString &line, int &index, int step)
|
||||||
{
|
{
|
||||||
int level = 0;
|
int level = 0;
|
||||||
while ((index >= 0) && (index < line.length())) { // Find the corresponding opening brace
|
while ((index >= 0) && (index < line.length())) { // Find the corresponding opening brace
|
||||||
|
@ -1456,7 +1459,8 @@ QString CppPreprocessor::expandFunction(PDefine define, QString args)
|
||||||
if (define->argList.length()==0) {
|
if (define->argList.length()==0) {
|
||||||
// do nothing
|
// do nothing
|
||||||
} else if (define->argList.length()==1) {
|
} else if (define->argList.length()==1) {
|
||||||
result=result.arg(args);
|
if (define->argUsed[0])
|
||||||
|
result=result.arg(args);
|
||||||
} else {
|
} else {
|
||||||
QStringList argValues;
|
QStringList argValues;
|
||||||
int i=0;
|
int i=0;
|
||||||
|
@ -1498,6 +1502,19 @@ QString CppPreprocessor::expandFunction(PDefine define, QString args)
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
argValues.append(args.mid(lastSplit,i-lastSplit));
|
argValues.append(args.mid(lastSplit,i-lastSplit));
|
||||||
|
#ifdef QT_DEBUG
|
||||||
|
if (
|
||||||
|
(define->varArgIndex==-1 && argValues.length() != define->argList.length())
|
||||||
|
|| (define->varArgIndex!=-1 && argValues.length() < define->argList.length()-1)
|
||||||
|
) {
|
||||||
|
qDebug()<<"*** Expand Macro error ***";
|
||||||
|
qDebug()<<this->mFileName<<":"<<this->mIndex;
|
||||||
|
qDebug()<<"Macro: "<<define->name<<define->argList;
|
||||||
|
qDebug()<<"Actual param: "<<args;
|
||||||
|
qDebug()<<"Params splitted: "<<argValues;
|
||||||
|
qDebug()<<"**********";
|
||||||
|
}
|
||||||
|
#endif
|
||||||
if (argValues.length() >= define->argList.length()
|
if (argValues.length() >= define->argList.length()
|
||||||
&& argValues.length()>0) {
|
&& argValues.length()>0) {
|
||||||
QStringList varArgs;
|
QStringList varArgs;
|
||||||
|
|
|
@ -220,7 +220,7 @@ static bool isNumberChar(const QChar& ch);
|
||||||
|
|
||||||
bool evaluateIf(const QString& line);
|
bool evaluateIf(const QString& line);
|
||||||
QString expandDefines(QString line);
|
QString expandDefines(QString line);
|
||||||
bool skipBraces(const QString&line, int& index, int step = 1);
|
bool skipParenthesis(const QString&line, int& index, int step = 1);
|
||||||
QString expandFunction(PDefine define,QString args);
|
QString expandFunction(PDefine define,QString args);
|
||||||
bool skipSpaces(const QString &expr, int& pos);
|
bool skipSpaces(const QString &expr, int& pos);
|
||||||
bool evalNumber(const QString &expr, int& result, int& pos);
|
bool evalNumber(const QString &expr, int& result, int& pos);
|
||||||
|
|
Loading…
Reference in New Issue