Standardize on int for line and column values

Recently tons of warnings show up for presumably "problematic"
singned <-> unsigned and size conversions.

The Qt side uses 'int', and that's the biggest 'integration surface'
for us, so instead of establishing some internal boundary between
signed and unsigned areas, push that boundary out of creator core code,
and use 'int' everywhere.

Because it reduces friction further, also do it in libcplusplus.

Change-Id: I84f3b79852c8029713e7ea6f133ffb9ef7030a70
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
This commit is contained in:
hjk
2019-07-24 18:40:10 +02:00
parent eab0df22f9
commit 7ab6783e24
153 changed files with 3181 additions and 3194 deletions

View File

@@ -314,9 +314,9 @@ CheckSymbols::CheckSymbols(Document::Ptr doc, const LookupContext &context, cons
: ASTVisitor(doc->translationUnit()), _doc(doc), _context(context)
, _lineOfLastUsage(0), _macroUses(macroUses)
{
unsigned line = 0;
int line = 0;
getTokenEndPosition(translationUnit()->ast()->lastToken(), &line, nullptr);
_chunkSize = qMax(50U, line / 200);
_chunkSize = qMax(50, line / 200);
_usages.reserve(_chunkSize);
_astStack.reserve(200);
@@ -365,7 +365,7 @@ bool CheckSymbols::warning(AST *ast, const QString &text)
const Token &lastToken = tokenAt(ast->lastToken() - 1);
const unsigned length = lastToken.utf16charsEnd() - firstToken.utf16charsBegin();
unsigned line = 1, column = 1;
int line = 1, column = 1;
getTokenStartPosition(ast->firstToken(), &line, &column);
warning(line, column, text, length);
@@ -478,7 +478,7 @@ bool CheckSymbols::visit(NamespaceAST *ast)
if (ast->identifier_token) {
const Token &tok = tokenAt(ast->identifier_token);
if (!tok.generated()) {
unsigned line, column;
int line, column;
getTokenStartPosition(ast->identifier_token, &line, &column);
Result use(line, column, tok.utf16chars(), SemanticHighlighter::TypeUse);
addUse(use);
@@ -786,7 +786,7 @@ void CheckSymbols::checkNamespace(NameAST *name)
if (!name)
return;
unsigned line, column;
int line, column;
getTokenStartPosition(name->firstToken(), &line, &column);
if (ClassOrNamespace *b = _context.lookupType(name->name, enclosingScope())) {
@@ -1184,7 +1184,7 @@ void CheckSymbols::addUse(unsigned tokenIndex, Kind kind)
if (tok.generated())
return;
unsigned line, column;
int line, column;
getTokenStartPosition(tokenIndex, &line, &column);
const unsigned length = tok.utf16chars();
@@ -1221,7 +1221,7 @@ void CheckSymbols::addType(ClassOrNamespace *b, NameAST *ast)
if (tok.generated())
return;
unsigned line, column;
int line, column;
getTokenStartPosition(startToken, &line, &column);
const unsigned length = tok.utf16chars();
const Result use(line, column, length, SemanticHighlighter::TypeUse);
@@ -1263,7 +1263,7 @@ bool CheckSymbols::maybeAddTypeOrStatic(const QList<LookupItem> &candidates, Nam
c->isClass() || c->isEnum() || isTemplateClass(c) ||
c->isForwardClassDeclaration() || c->isTypenameArgument() || c->enclosingEnum() != nullptr) {
unsigned line, column;
int line, column;
getTokenStartPosition(startToken, &line, &column);
const unsigned length = tok.utf16chars();
@@ -1305,7 +1305,7 @@ bool CheckSymbols::maybeAddField(const QList<LookupItem> &candidates, NameAST *a
else if (c->isTypedef() || (c->type() && c->type()->isFunctionType()))
return false; // shadowed
unsigned line, column;
int line, column;
getTokenStartPosition(startToken, &line, &column);
const unsigned length = tok.utf16chars();
@@ -1319,9 +1319,9 @@ bool CheckSymbols::maybeAddField(const QList<LookupItem> &candidates, NameAST *a
}
bool CheckSymbols::maybeAddFunction(const QList<LookupItem> &candidates, NameAST *ast,
unsigned argumentCount, FunctionKind functionKind)
int argumentCount, FunctionKind functionKind)
{
unsigned startToken = ast->firstToken();
int startToken = ast->firstToken();
bool isDestructor = false;
bool isConstructor = false;
if (DestructorNameAST *dtor = ast->asDestructorName()) {
@@ -1399,7 +1399,7 @@ bool CheckSymbols::maybeAddFunction(const QList<LookupItem> &candidates, NameAST
return false;
}
unsigned line, column;
int line, column;
getTokenStartPosition(startToken, &line, &column);
const unsigned length = tok.utf16chars();