Skip to content

Commit 0c2ee15

Browse files
committed
Better warning from constant expression evaluation
The constant expression evaluation gives hard to understand error messages as it shows the doxygen interpretation of the expression instead of the original expression. We now show both expressions.
1 parent 7861a62 commit 0c2ee15

File tree

5 files changed

+9
-4
lines changed

5 files changed

+9
-4
lines changed

src/constexp.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class ConstExpressionParser
2525
public:
2626
ConstExpressionParser();
2727
~ConstExpressionParser();
28-
bool parse(const char *fileName,int line,const std::string &expression);
28+
bool parse(const char *fileName,int line,const std::string &expression,const std::string &orgExpression);
2929
private:
3030
struct Private;
3131
std::unique_ptr<Private> p;

src/constexp.l

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ ConstExpressionParser::~ConstExpressionParser()
140140
constexpYYlex_destroy(p->yyscanner);
141141
}
142142
143-
bool ConstExpressionParser::parse(const char *fileName,int lineNr,const std::string &s)
143+
bool ConstExpressionParser::parse(const char *fileName,int lineNr,const std::string &s, const std::string &orgStr)
144144
{
145145
struct yyguts_t *yyg = (struct yyguts_t*)p->yyscanner;
146146
@@ -150,6 +150,7 @@ bool ConstExpressionParser::parse(const char *fileName,int lineNr,const std::str
150150
151151
yyextra->constExpFileName = fileName;
152152
yyextra->constExpLineNr = lineNr;
153+
yyextra->orgString = orgStr;
153154
yyextra->inputString = s;
154155
yyextra->inputPosition = 0;
155156
constexpYYrestart( yyin, p->yyscanner );

src/constexp.y

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ int constexpYYerror(yyscan_t yyscanner, const char *s)
2626
{
2727
struct constexpYY_state* yyextra = constexpYYget_extra(yyscanner);
2828
warn(yyextra->constExpFileName.c_str(), yyextra->constExpLineNr,
29-
"preprocessing issue while doing constant expression evaluation: %s: input='%s'",s,yyextra->inputString.c_str());
29+
"preprocessing issue while doing constant expression evaluation: %s:\n input='%s'\n doxygen interpretation '%s'",
30+
s,yyextra->orgString.c_str(),yyextra->inputString.c_str());
3031
return 0;
3132
}
3233

src/constexp_p.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ struct constexpYY_state
3434
int constExpLineNr;
3535
std::string constExpFileName;
3636

37+
std::string orgString;
3738
std::string inputString;
3839
int inputPosition;
3940
};

src/pre.l

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3067,13 +3067,15 @@ static bool computeExpression(yyscan_t yyscanner,const QCString &expr)
30673067
{
30683068
YY_EXTRA_TYPE state = preYYget_extra(yyscanner);
30693069
QCString e=expr;
3070+
QCString ee=expr;
3071+
ee = removeMarkers(ee);
30703072
state->expanded.clear();
30713073
expandExpression(yyscanner,e,0,0,0);
30723074
//printf("after expansion '%s'\n",qPrint(e));
30733075
e = removeIdsAndMarkers(e);
30743076
if (e.isEmpty()) return FALSE;
30753077
//printf("parsing '%s'\n",qPrint(e));
3076-
return state->constExpParser.parse(state->fileName.data(),state->yyLineNr,e.str());
3078+
return state->constExpParser.parse(state->fileName.data(),state->yyLineNr,e.str(),ee.str());
30773079
}
30783080

30793081
/*! expands the macro definition in \a name

0 commit comments

Comments
 (0)