Commit 1901a1c7 authored by Friedemann Kleint's avatar Friedemann Kleint

Fix MSVC-64 warnings about size_t -> int truncations in C++-lib.

Change-Id: Ibe6f41ac15df1ec685b0d0766ff568abf6f3ae7e
Reviewed-by: default avatarNikolai Kosjar <nikolai.kosjar@digia.com>
parent 5c337423
......@@ -1146,7 +1146,7 @@ const StringLiteral *Bind::asStringLiteral(unsigned firstToken, unsigned lastTok
buffer += ' ';
buffer += tk.spell();
}
return control()->stringLiteral(buffer.c_str(), buffer.size());
return control()->stringLiteral(buffer.c_str(), unsigned(buffer.size()));
}
// StatementAST
......@@ -1168,7 +1168,7 @@ bool Bind::visit(QtMemberDeclarationAST *ast)
privateClass += nameId->identifier()->chars();
privateClass += "Private";
const Name *privName = control()->identifier(privateClass.c_str(), privateClass.size());
const Name *privName = control()->identifier(privateClass.c_str(), unsigned(privateClass.size()));
declTy.setType(control()->namedType(privName));
}
}
......@@ -1262,7 +1262,7 @@ bool Bind::visit(ForeachStatementAST *ast)
unsigned endOfExpression = ast->expression->lastToken();
const StringLiteral *sl = asStringLiteral(startOfExpression, endOfExpression);
const std::string buff = std::string("*") + sl->chars() + ".begin()";
initializer = control()->stringLiteral(buff.c_str(), buff.size());
initializer = control()->stringLiteral(buff.c_str(), unsigned(buff.size()));
}
}
......@@ -1312,7 +1312,7 @@ bool Bind::visit(RangeBasedForStatementAST *ast)
unsigned endOfExpression = ast->expression->lastToken();
const StringLiteral *sl = asStringLiteral(startOfExpression, endOfExpression);
const std::string buff = std::string("*") + sl->chars() + ".begin()";
initializer = control()->stringLiteral(buff.c_str(), buff.size());
initializer = control()->stringLiteral(buff.c_str(), unsigned(buff.size()));
}
}
......@@ -2591,7 +2591,7 @@ bool Bind::visit(ObjCSelectorAST *ast) // ### review
}
if (! arguments.empty()) {
_name = control()->selectorNameId(&arguments[0], arguments.size(), hasArgs);
_name = control()->selectorNameId(&arguments[0], unsigned(arguments.size()), hasArgs);
ast->name = _name;
}
......@@ -2676,7 +2676,7 @@ bool Bind::visit(TemplateIdAST *ast)
_name = control()->templateNameId(id, isSpecialization);
else
_name = control()->templateNameId(id, isSpecialization, &templateArguments[0],
templateArguments.size());
unsigned(templateArguments.size()));
ast->name = _name;
return false;
......
......@@ -584,7 +584,7 @@ const Identifier *Control::identifier(const char *chars, unsigned size)
const Identifier *Control::identifier(const char *chars)
{
unsigned length = std::strlen(chars);
const unsigned length = unsigned(std::strlen(chars));
return identifier(chars, length);
}
......@@ -611,7 +611,7 @@ const StringLiteral *Control::stringLiteral(const char *chars, unsigned size)
const StringLiteral *Control::stringLiteral(const char *chars)
{
unsigned length = std::strlen(chars);
const unsigned length = unsigned(std::strlen(chars));
return stringLiteral(chars, length);
}
......@@ -620,7 +620,7 @@ const NumericLiteral *Control::numericLiteral(const char *chars, unsigned size)
const NumericLiteral *Control::numericLiteral(const char *chars)
{
unsigned length = std::strlen(chars);
const unsigned length = unsigned(std::strlen(chars));
return numericLiteral(chars, length);
}
......
......@@ -100,7 +100,7 @@ const Identifier *TemplateNameId::identifier() const
{ return _identifier; }
unsigned TemplateNameId::templateArgumentCount() const
{ return _templateArguments.size(); }
{ return unsigned(_templateArguments.size()); }
const FullySpecifiedType &TemplateNameId::templateArgumentAt(unsigned index) const
{ return _templateArguments[index]; }
......@@ -217,7 +217,7 @@ const Identifier *SelectorNameId::identifier() const
}
unsigned SelectorNameId::nameCount() const
{ return _names.size(); }
{ return unsigned(_names.size()); }
const Name *SelectorNameId::nameAt(unsigned index) const
{ return _names[index]; }
......
......@@ -722,7 +722,7 @@ bool Class::matchType0(const Type *otherType, TypeMatcher *matcher) const
}
unsigned Class::baseClassCount() const
{ return _baseClasses.size(); }
{ return unsigned(_baseClasses.size()); }
BaseClass *Class::baseClassAt(unsigned index) const
{ return _baseClasses.at(index); }
......@@ -885,7 +885,7 @@ void ObjCClass::setBaseClass(ObjCBaseClass *baseClass)
{ _baseClass = baseClass; }
unsigned ObjCClass::protocolCount() const
{ return _protocols.size(); }
{ return unsigned(_protocols.size()); }
ObjCBaseProtocol *ObjCClass::protocolAt(unsigned index) const
{ return _protocols.at(index); }
......@@ -951,7 +951,7 @@ ObjCProtocol::~ObjCProtocol()
{}
unsigned ObjCProtocol::protocolCount() const
{ return _protocols.size(); }
{ return unsigned(_protocols.size()); }
ObjCBaseProtocol *ObjCProtocol::protocolAt(unsigned index) const
{ return _protocols.at(index); }
......
......@@ -443,7 +443,7 @@ void CloneName::visit(const TemplateNameId *name)
_name = _control->templateNameId(_clone->identifier(name->identifier()), name->isSpecialization());
else
_name = _control->templateNameId(_clone->identifier(name->identifier()), name->isSpecialization(),
&args[0], args.size());
&args[0], unsigned(args.size()));
}
void CloneName::visit(const DestructorNameId *name)
......@@ -473,7 +473,7 @@ void CloneName::visit(const SelectorNameId *name)
std::vector<const Name *> names(name->nameCount());
for (unsigned i = 0; i < names.size(); ++i)
names[i] = _clone->name(name->nameAt(i), _subst);
_name = _control->selectorNameId(&names[0], names.size(), name->hasArguments());
_name = _control->selectorNameId(&names[0], unsigned(names.size()), name->hasArguments());
}
......
......@@ -117,7 +117,7 @@ const char *TranslationUnit::spell(unsigned index) const
}
unsigned TranslationUnit::commentCount() const
{ return _comments->size(); }
{ return unsigned(_comments->size()); }
const Token &TranslationUnit::commentAt(unsigned index) const
{ return _comments->at(index); }
......@@ -266,11 +266,11 @@ void TranslationUnit::tokenize()
}
goto _Lrecognize;
} else if (tk.f.kind == T_LBRACE) {
braces.push(_tokens->size());
braces.push(unsigned(_tokens->size()));
} else if (tk.f.kind == T_RBRACE && ! braces.empty()) {
const unsigned open_brace_index = braces.top();
braces.pop();
(*_tokens)[open_brace_index].close_brace = _tokens->size();
(*_tokens)[open_brace_index].close_brace = unsigned(_tokens->size());
} else if (tk.isComment()) {
_comments->push_back(tk);
continue; // comments are not in the regular token stream
......@@ -298,7 +298,7 @@ void TranslationUnit::tokenize()
for (; ! braces.empty(); braces.pop()) {
unsigned open_brace_index = braces.top();
(*_tokens)[open_brace_index].close_brace = _tokens->size();
(*_tokens)[open_brace_index].close_brace = unsigned(_tokens->size());
}
}
......
......@@ -63,7 +63,7 @@ public:
void setSource(const char *source, unsigned size);
unsigned tokenCount() const { return _tokens->size(); }
unsigned tokenCount() const { return unsigned(_tokens->size()); }
const Token &tokenAt(unsigned index) const { return _tokens->at(index); }
int tokenKind(unsigned index) const { return _tokens->at(index).f.kind; }
const char *spell(unsigned index) const;
......
......@@ -35,7 +35,7 @@ using namespace CPlusPlus;
bool ByteArrayRef::startsWith(const char *s) const
{
int l = std::strlen(s);
const int l = int(std::strlen(s));
if (l > m_length)
return false;
return !qstrncmp(start(), s, l);
......
......@@ -1064,7 +1064,7 @@ bool Preprocessor::handleIdentifier(PPToken *tk)
// This is not the most beautiful approach but it's quite reasonable. What we do here
// is to create a fake identifier token which is only composed by whitespaces. It's
// also not marked as expanded so it it can be treated as a regular token.
QByteArray content(idTk.f.length + computeDistance(idTk), ' ');
const QByteArray content(int(idTk.f.length + computeDistance(idTk)), ' ');
PPToken fakeIdentifier = generateToken(T_IDENTIFIER,
content.constData(), content.length(),
idTk.lineno, false, false);
......@@ -1131,7 +1131,7 @@ bool Preprocessor::handleFunctionLikeMacro(const Macro *macro,
for (size_t i = 0; i < bodySize && expanded.size() < MAX_TOKEN_EXPANSION_COUNT;
++i) {
int expandedSize = expanded.size();
PPToken bodyTk = body.at(i);
PPToken bodyTk = body.at(int(i));
if (bodyTk.is(T_IDENTIFIER)) {
const ByteArrayRef id = bodyTk.asByteArrayRef();
......@@ -1152,7 +1152,7 @@ bool Preprocessor::handleFunctionLikeMacro(const Macro *macro,
const int actualsSize = actualsForThisParam.size();
if (i > 0 && body[i - 1].is(T_POUND)) {
if (i > 0 && body[int(i) - 1].is(T_POUND)) {
QByteArray enclosedString;
enclosedString.reserve(256);
......@@ -1205,7 +1205,7 @@ bool Preprocessor::handleFunctionLikeMacro(const Macro *macro,
expanded.push_back(bodyTk);
}
if (i > 1 && body[i - 1].is(T_POUND_POUND)) {
if (i > 1 && body[int(i) - 1].is(T_POUND_POUND)) {
if (expandedSize < 1 || expanded.size() == expandedSize) //### TODO: [cpp.concat] placemarkers
continue;
const PPToken &leftTk = expanded[expandedSize - 1];
......@@ -1414,7 +1414,7 @@ void Preprocessor::preprocess(const QString &fileName, const QByteArray &source,
unsigned trackedColumn = 0;
if (tk.expanded() && !tk.generated()) {
trackedLine = tk.lineno;
trackedColumn = computeDistance(tk, true);
trackedColumn = unsigned(computeDistance(tk, true));
}
m_state.m_expandedTokensInfo.append(qMakePair(trackedLine, trackedColumn));
} else if (m_state.m_expansionStatus == JustFinishedExpansion) {
......@@ -1985,7 +1985,7 @@ PPToken Preprocessor::generateToken(enum Kind kind,
else if (kind == T_NUMERIC_LITERAL)
tk.number = m_state.m_lexer->control()->numericLiteral(m_scratchBuffer.constData() + pos, length);
}
tk.offset = pos;
tk.offset = unsigned(pos);
tk.f.length = length;
tk.f.generated = true;
tk.f.expanded = true;
......
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