Commit f0682231 authored by Przemyslaw Gorszkowski's avatar Przemyslaw Gorszkowski Committed by Nikolai Kosjar

C++: fix tooltip for constantValue of enumeratorDeclaration

E.g.:
enum E { x = 1 + 2 + 1 };

constantValue for enumeratorDeclaration currently is equal: '1+2+1'
(spaces between are removed).
Fixed version produces "1 + 2 + 1".

Change-Id: I38f7703bd5c856c28aadeecd7f7923aa4a7da422
Reviewed-by: default avatarNikolai Kosjar <nikolai.kosjar@digia.com>
parent fe39e8e9
......@@ -476,7 +476,7 @@ void Bind::enumerator(EnumeratorAST *ast, Enum *symbol)
e->setType(control()->integerType(IntegerType::Int)); // ### introduce IntegerType::Enumerator
if (ExpressionAST *expr = ast->expression)
e->setConstantValue(asStringLiteral(expr->firstToken(), expr->lastToken(), false));
e->setConstantValue(asStringLiteral(expr->firstToken(), expr->lastToken()));
symbol->addMember(e);
}
......@@ -1137,13 +1137,12 @@ FullySpecifiedType Bind::trailingReturnType(TrailingReturnTypeAST *ast, const Fu
return type;
}
const StringLiteral *Bind::asStringLiteral(unsigned firstToken, unsigned lastToken,
bool addWhitespace)
const StringLiteral *Bind::asStringLiteral(unsigned firstToken, unsigned lastToken)
{
std::string buffer;
for (unsigned index = firstToken; index != lastToken; ++index) {
const Token &tk = tokenAt(index);
if (addWhitespace && (tk.whitespace() || tk.newline()))
if (index != firstToken && (tk.whitespace() || tk.newline()))
buffer += ' ';
buffer += tk.spell();
}
......
......@@ -105,8 +105,7 @@ protected:
void capture(CaptureAST *ast);
void lambdaDeclarator(LambdaDeclaratorAST *ast);
FullySpecifiedType trailingReturnType(TrailingReturnTypeAST *ast, const FullySpecifiedType &init);
const StringLiteral *asStringLiteral(unsigned firstToken, unsigned lastToken,
bool addWhitespace = true);
const StringLiteral *asStringLiteral(unsigned firstToken, unsigned lastToken);
virtual bool preVisit(AST *);
virtual void postVisit(AST *);
......
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