diff options
author | Roberto Raggi <roberto.raggi@nokia.com> | 2010-08-13 10:36:45 +0200 |
---|---|---|
committer | Roberto Raggi <roberto.raggi@nokia.com> | 2010-08-13 10:36:45 +0200 |
commit | af28f72e6564f0a87a9c3662794bc69a84e8531e (patch) | |
tree | e7e81aed61b4e1d1cf283e73dda24be17c7d7c93 /src/shared/cplusplus | |
parent | 89dba0e57bfe375ad9945de6d99e0fc89c68ce06 (diff) | |
download | qt-creator-af28f72e6564f0a87a9c3662794bc69a84e8531e.tar.gz |
Store the default value of the formal argument in a string literal.
Diffstat (limited to 'src/shared/cplusplus')
-rw-r--r-- | src/shared/cplusplus/Bind.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/shared/cplusplus/Bind.cpp b/src/shared/cplusplus/Bind.cpp index 74ae70c839..cb7dc7311a 100644 --- a/src/shared/cplusplus/Bind.cpp +++ b/src/shared/cplusplus/Bind.cpp @@ -56,6 +56,7 @@ #include "Literals.h" #include "Scope.h" #include <vector> +#include <string> #include <memory> #include <cassert> @@ -1696,6 +1697,20 @@ bool Bind::visit(ParameterDeclarationAST *ast) Argument *arg = control()->newArgument(sourceLocation, argName); arg->setType(type); + 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()->stringLiteral(buffer.c_str(), buffer.size()); + arg->setInitializer(initializer); + } + _scope->addMember(arg); ast->symbol = arg; |