diff options
author | Roberto Raggi <roberto.raggi@nokia.com> | 2009-12-08 11:34:22 +0100 |
---|---|---|
committer | Roberto Raggi <roberto.raggi@nokia.com> | 2009-12-08 11:35:34 +0100 |
commit | 5a0b7f8ec8376882bf2c1dc5a701fd813d8d827d (patch) | |
tree | 334cbfba0e3660bf1dbb5abdfb73d303c30c93b6 /src/shared/cplusplus/CheckDeclaration.cpp | |
parent | d20cdc64e3d8f23ac404e3474fdddca847c4ce8a (diff) | |
download | qt-creator-5a0b7f8ec8376882bf2c1dc5a701fd813d8d827d.tar.gz |
Added initializers to the formal arguments.
Diffstat (limited to 'src/shared/cplusplus/CheckDeclaration.cpp')
-rw-r--r-- | src/shared/cplusplus/CheckDeclaration.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/shared/cplusplus/CheckDeclaration.cpp b/src/shared/cplusplus/CheckDeclaration.cpp index 426a7d9de2..3349263e1e 100644 --- a/src/shared/cplusplus/CheckDeclaration.cpp +++ b/src/shared/cplusplus/CheckDeclaration.cpp @@ -56,6 +56,7 @@ #include "Symbols.h" #include "Control.h" #include "Literals.h" +#include <string> #include <cassert> using namespace CPlusPlus; @@ -419,8 +420,19 @@ bool CheckDeclaration::visit(ParameterDeclarationAST *ast) FullySpecifiedType exprTy = semantic()->check(ast->expression, _scope); Argument *arg = control()->newArgument(sourceLocation, argName); ast->symbol = arg; - if (ast->expression) - arg->setInitializer(true); + if (ast->expression) { + unsigned startOfExpression = ast->expression->firstToken(); + unsigned endOfExpression = ast->expression->lastToken(); + std::string buffer; + for (unsigned index = startOfExpression; index != endOfExpression; ++index) { + const Token &tk = tokenAt(index); + if (tk.whitespace() || tk.newline()) + buffer += ' '; + buffer += tk.spell(); + } + const StringLiteral *initializer = control()->findOrInsertStringLiteral(buffer.c_str(), buffer.size()); + arg->setInitializer(initializer); + } arg->setType(argTy); _scope->enterSymbol(arg); return false; |