forked from qt-creator/qt-creator
C++: fix constantValue for EnumeratorDeclaration
For the case:
const int x = 12;
enum E { e = x };
constantValue for EnumeratorDeclaration has value=' x'. It should have 'x'.
Change-Id: Iaca77cccd1e0dc5274696b0c96cec6ac2f904979
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
This commit is contained in:
committed by
Erik Verbruggen
parent
46461fc183
commit
37430df636
7
src/libs/3rdparty/cplusplus/Bind.cpp
vendored
7
src/libs/3rdparty/cplusplus/Bind.cpp
vendored
@@ -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()));
|
||||
e->setConstantValue(asStringLiteral(expr->firstToken(), expr->lastToken(), false));
|
||||
|
||||
symbol->addMember(e);
|
||||
}
|
||||
@@ -1137,12 +1137,13 @@ FullySpecifiedType Bind::trailingReturnType(TrailingReturnTypeAST *ast, const Fu
|
||||
return type;
|
||||
}
|
||||
|
||||
const StringLiteral *Bind::asStringLiteral(unsigned firstToken, unsigned lastToken)
|
||||
const StringLiteral *Bind::asStringLiteral(unsigned firstToken, unsigned lastToken,
|
||||
bool addWhitespace)
|
||||
{
|
||||
std::string buffer;
|
||||
for (unsigned index = firstToken; index != lastToken; ++index) {
|
||||
const Token &tk = tokenAt(index);
|
||||
if (tk.whitespace() || tk.newline())
|
||||
if (addWhitespace && (tk.whitespace() || tk.newline()))
|
||||
buffer += ' ';
|
||||
buffer += tk.spell();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user