forked from qt-creator/qt-creator
Some clang-tidy -use-modernize-nullptr
Change-Id: I1bed5e85a5b7948d08502a72a10f80baa075c204 Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
@@ -234,7 +234,7 @@ static bool symbolIdentical(Symbol *s1, Symbol *s2)
|
||||
|
||||
static const Name *toName(const QList<const Name *> &names, Control *control)
|
||||
{
|
||||
const Name *n = 0;
|
||||
const Name *n = nullptr;
|
||||
for (int i = names.size() - 1; i >= 0; --i) {
|
||||
if (! n)
|
||||
n = names.at(i);
|
||||
@@ -260,7 +260,7 @@ static bool isInlineNamespace(ClassOrNamespace *con, const Name *name)
|
||||
|
||||
const Name *LookupContext::minimalName(Symbol *symbol, ClassOrNamespace *target, Control *control)
|
||||
{
|
||||
const Name *n = 0;
|
||||
const Name *n = nullptr;
|
||||
QList<const Name *> names = LookupContext::fullyQualifiedName(symbol);
|
||||
|
||||
for (int i = names.size() - 1; i >= 0; --i) {
|
||||
@@ -360,7 +360,7 @@ ClassOrNamespace *LookupContext::lookupType(const Name *name, Scope *scope,
|
||||
QSet<const Declaration *> typedefsBeingResolved) const
|
||||
{
|
||||
if (! scope || ! name) {
|
||||
return 0;
|
||||
return nullptr;
|
||||
} else if (Block *block = scope->asBlock()) {
|
||||
for (int i = 0; i < block->memberCount(); ++i) {
|
||||
Symbol *m = block->memberAt(i);
|
||||
@@ -379,8 +379,8 @@ ClassOrNamespace *LookupContext::lookupType(const Name *name, Scope *scope,
|
||||
if (const NamedType *namedTy = d->type()->asNamedType()) {
|
||||
// Stop on recursive typedef declarations
|
||||
if (typedefsBeingResolved.contains(d))
|
||||
return 0;
|
||||
return lookupType(namedTy->name(), scope, 0,
|
||||
return nullptr;
|
||||
return lookupType(namedTy->name(), scope, nullptr,
|
||||
QSet<const Declaration *>(typedefsBeingResolved)
|
||||
<< d);
|
||||
}
|
||||
@@ -421,7 +421,7 @@ ClassOrNamespace *LookupContext::lookupType(const Name *name, Scope *scope,
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
ClassOrNamespace *LookupContext::lookupType(Symbol *symbol,
|
||||
@@ -438,8 +438,8 @@ QList<LookupItem> LookupContext::lookup(const Name *name, Scope *scope) const
|
||||
return candidates;
|
||||
|
||||
for (; scope; scope = scope->enclosingScope()) {
|
||||
if (name->identifier() != 0 && scope->isBlock()) {
|
||||
bindings()->lookupInScope(name, scope, &candidates, /*templateId = */ 0, /*binding=*/ 0);
|
||||
if (name->identifier() != nullptr && scope->isBlock()) {
|
||||
bindings()->lookupInScope(name, scope, &candidates, /*templateId = */ nullptr, /*binding=*/ nullptr);
|
||||
|
||||
if (! candidates.isEmpty()) {
|
||||
// it's a local.
|
||||
@@ -475,7 +475,7 @@ QList<LookupItem> LookupContext::lookup(const Name *name, Scope *scope) const
|
||||
}
|
||||
|
||||
} else if (Function *fun = scope->asFunction()) {
|
||||
bindings()->lookupInScope(name, fun, &candidates, /*templateId = */ 0, /*binding=*/ 0);
|
||||
bindings()->lookupInScope(name, fun, &candidates, /*templateId = */ nullptr, /*binding=*/ nullptr);
|
||||
|
||||
if (! candidates.isEmpty()) {
|
||||
// it's an argument or a template parameter.
|
||||
@@ -507,13 +507,13 @@ QList<LookupItem> LookupContext::lookup(const Name *name, Scope *scope) const
|
||||
// continue, and look at the enclosing scope.
|
||||
|
||||
} else if (ObjCMethod *method = scope->asObjCMethod()) {
|
||||
bindings()->lookupInScope(name, method, &candidates, /*templateId = */ 0, /*binding=*/ 0);
|
||||
bindings()->lookupInScope(name, method, &candidates, /*templateId = */ nullptr, /*binding=*/ nullptr);
|
||||
|
||||
if (! candidates.isEmpty())
|
||||
break; // it's a formal argument.
|
||||
|
||||
} else if (Template *templ = scope->asTemplate()) {
|
||||
bindings()->lookupInScope(name, templ, &candidates, /*templateId = */ 0, /*binding=*/ 0);
|
||||
bindings()->lookupInScope(name, templ, &candidates, /*templateId = */ nullptr, /*binding=*/ nullptr);
|
||||
|
||||
if (! candidates.isEmpty()) {
|
||||
// it's a template parameter.
|
||||
@@ -569,7 +569,7 @@ ClassOrNamespace *LookupContext::lookupParent(Symbol *symbol) const
|
||||
foreach (const Name *name, fqName) {
|
||||
binding = binding->findType(name);
|
||||
if (!binding)
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return binding;
|
||||
@@ -578,11 +578,11 @@ ClassOrNamespace *LookupContext::lookupParent(Symbol *symbol) const
|
||||
ClassOrNamespace::ClassOrNamespace(CreateBindings *factory, ClassOrNamespace *parent)
|
||||
: _factory(factory)
|
||||
, _parent(parent)
|
||||
, _scopeLookupCache(0)
|
||||
, _templateId(0)
|
||||
, _instantiationOrigin(0)
|
||||
, _rootClass(0)
|
||||
, _name(0)
|
||||
, _scopeLookupCache(nullptr)
|
||||
, _templateId(nullptr)
|
||||
, _instantiationOrigin(nullptr)
|
||||
, _rootClass(nullptr)
|
||||
, _name(nullptr)
|
||||
{
|
||||
Q_ASSERT(factory);
|
||||
}
|
||||
@@ -667,7 +667,7 @@ QList<LookupItem> ClassOrNamespace::lookup_helper(const Name *name, bool searchI
|
||||
// It's also possible that there are matches in the parent binding through
|
||||
// a qualified name. For instance, a nested class which is forward declared
|
||||
// in the class but defined outside it - we should capture both.
|
||||
Symbol *match = 0;
|
||||
Symbol *match = nullptr;
|
||||
QSet<ClassOrNamespace *> processed;
|
||||
for (ClassOrNamespace *parentBinding = binding->parent();
|
||||
parentBinding && !match;
|
||||
@@ -696,7 +696,7 @@ QList<LookupItem> ClassOrNamespace::lookup_helper(const Name *name, bool searchI
|
||||
if (processedOwnParents.contains(binding))
|
||||
break;
|
||||
processedOwnParents.insert(binding);
|
||||
lookup_helper(name, binding, &result, &processed, /*templateId = */ 0);
|
||||
lookup_helper(name, binding, &result, &processed, /*templateId = */ nullptr);
|
||||
binding = binding->_parent;
|
||||
} while (searchInEnclosingScope && binding);
|
||||
}
|
||||
@@ -829,7 +829,7 @@ void CreateBindings::lookupInScope(const Name *name, Scope *scope,
|
||||
ClassOrNamespace *ClassOrNamespace::lookupType(const Name *name)
|
||||
{
|
||||
if (! name)
|
||||
return 0;
|
||||
return nullptr;
|
||||
|
||||
QSet<ClassOrNamespace *> processed;
|
||||
return lookupType_helper(name, &processed, /*searchInEnclosingScope =*/ true, this);
|
||||
@@ -857,7 +857,7 @@ ClassOrNamespace *ClassOrNamespace::lookupType(const Name *name, Block *block)
|
||||
return foundNestedBlock;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
ClassOrNamespace *ClassOrNamespace::findType(const Name *name)
|
||||
@@ -889,7 +889,7 @@ ClassOrNamespace *ClassOrNamespace::findBlock_helper(Block *block,
|
||||
if (!searchInEnclosingScope)
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
ClassOrNamespace *ClassOrNamespace::findBlock(Block *block)
|
||||
@@ -935,7 +935,7 @@ ClassOrNamespace *ClassOrNamespace::lookupType_helper(const Name *name,
|
||||
if (ClassOrNamespace *binding = lookupType_helper(q->base(), processed, true, origin))
|
||||
return binding->lookupType_helper(q->name(), &innerProcessed, false, origin);
|
||||
|
||||
return 0;
|
||||
return nullptr;
|
||||
|
||||
} else if (! processed->contains(this)) {
|
||||
processed->insert(this);
|
||||
@@ -985,7 +985,7 @@ ClassOrNamespace *ClassOrNamespace::lookupType_helper(const Name *name,
|
||||
return _parent->lookupType_helper(name, processed, searchInEnclosingScope, origin);
|
||||
}
|
||||
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static ClassOrNamespace *findSpecializationWithMatchingTemplateArgument(const Name *argumentName,
|
||||
@@ -1008,7 +1008,7 @@ static ClassOrNamespace *findSpecializationWithMatchingTemplateArgument(const Na
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
ClassOrNamespace *ClassOrNamespace::findSpecialization(const TemplateNameId *templId,
|
||||
@@ -1057,7 +1057,7 @@ ClassOrNamespace *ClassOrNamespace::findSpecialization(const TemplateNameId *tem
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
ClassOrNamespace *ClassOrNamespace::findOrCreateNestedAnonymousType(
|
||||
@@ -1080,7 +1080,7 @@ ClassOrNamespace *ClassOrNamespace::nestedType(const Name *name,
|
||||
QSet<ClassOrNamespace *> *processed,
|
||||
ClassOrNamespace *origin)
|
||||
{
|
||||
Q_ASSERT(name != 0);
|
||||
Q_ASSERT(name != nullptr);
|
||||
Q_ASSERT(name->isNameId() || name->isTemplateNameId() || name->isAnonymousNameId());
|
||||
|
||||
const_cast<ClassOrNamespace *>(this)->flush();
|
||||
@@ -1090,7 +1090,7 @@ ClassOrNamespace *ClassOrNamespace::nestedType(const Name *name,
|
||||
|
||||
Table::const_iterator it = _classOrNamespaces.find(name);
|
||||
if (it == _classOrNamespaces.end())
|
||||
return 0;
|
||||
return nullptr;
|
||||
|
||||
ClassOrNamespace *reference = it->second;
|
||||
ClassOrNamespace *baseTemplateClassReference = reference;
|
||||
@@ -1151,7 +1151,7 @@ ClassOrNamespace *ClassOrNamespace::nestedType(const Name *name,
|
||||
// are templates. We need to collect them now. First, we track the bases which are already
|
||||
// part of the binding so we can identify the missings ones later.
|
||||
|
||||
Class *referenceClass = 0;
|
||||
Class *referenceClass = nullptr;
|
||||
QList<const Name *> allBases;
|
||||
foreach (Symbol *s, reference->symbols()) {
|
||||
if (Class *clazz = s->asClass()) {
|
||||
@@ -1272,7 +1272,7 @@ ClassOrNamespace *ClassOrNamespace::nestedType(const Name *name,
|
||||
templParams.insert(templateSpecialization->templateParameterAt(i)->name(), i);
|
||||
|
||||
foreach (const Name *baseName, allBases) {
|
||||
ClassOrNamespace *baseBinding = 0;
|
||||
ClassOrNamespace *baseBinding = nullptr;
|
||||
|
||||
if (const Identifier *nameId = baseName->asNameId()) {
|
||||
// This is the simple case in which a template parameter is itself a base.
|
||||
@@ -1354,7 +1354,7 @@ ClassOrNamespace *ClassOrNamespace::nestedType(const Name *name,
|
||||
if (const QualifiedNameId *qBaseName = baseName->asQualifiedNameId()) {
|
||||
if (const Name *qualification = qBaseName->base())
|
||||
binding = lookupType(qualification);
|
||||
else if (binding->parent() != 0)
|
||||
else if (binding->parent() != nullptr)
|
||||
//if this is global identifier we take global namespace
|
||||
//Ex: class A{}; namespace NS { class A: public ::A{}; }
|
||||
binding = binding->globalNamespace();
|
||||
@@ -1471,7 +1471,7 @@ NamedType *ClassOrNamespace::NestedClassInstantiator::findNamedType(Type *member
|
||||
else if (ReferenceType *referenceType = memberType->asReferenceType())
|
||||
return findNamedType(referenceType->elementType().type());
|
||||
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void ClassOrNamespace::flush()
|
||||
@@ -1539,7 +1539,7 @@ ClassOrNamespace *ClassOrNamespace::findOrCreateType(const Name *name, ClassOrNa
|
||||
return e;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
CreateBindings::CreateBindings(Document::Ptr thisDocument, const Snapshot &snapshot)
|
||||
@@ -1547,7 +1547,7 @@ CreateBindings::CreateBindings(Document::Ptr thisDocument, const Snapshot &snaps
|
||||
, _control(QSharedPointer<Control>(new Control))
|
||||
, _expandTemplates(false)
|
||||
{
|
||||
_globalNamespace = allocClassOrNamespace(/*parent = */ 0);
|
||||
_globalNamespace = allocClassOrNamespace(/*parent = */ nullptr);
|
||||
_currentClassOrNamespace = _globalNamespace;
|
||||
|
||||
process(thisDocument);
|
||||
@@ -1636,7 +1636,7 @@ void CreateBindings::process(Document::Ptr doc)
|
||||
|
||||
ClassOrNamespace *CreateBindings::enterClassOrNamespaceBinding(Symbol *symbol)
|
||||
{
|
||||
ClassOrNamespace *entity = _currentClassOrNamespace->findOrCreateType(symbol->name(), 0,
|
||||
ClassOrNamespace *entity = _currentClassOrNamespace->findOrCreateType(symbol->name(), nullptr,
|
||||
symbol->asClass());
|
||||
entity->addSymbol(symbol);
|
||||
|
||||
@@ -1645,7 +1645,7 @@ ClassOrNamespace *CreateBindings::enterClassOrNamespaceBinding(Symbol *symbol)
|
||||
|
||||
ClassOrNamespace *CreateBindings::enterGlobalClassOrNamespace(Symbol *symbol)
|
||||
{
|
||||
ClassOrNamespace *entity = _globalNamespace->findOrCreateType(symbol->name(), 0,
|
||||
ClassOrNamespace *entity = _globalNamespace->findOrCreateType(symbol->name(), nullptr,
|
||||
symbol->asClass());
|
||||
entity->addSymbol(symbol);
|
||||
|
||||
@@ -1678,13 +1678,13 @@ bool CreateBindings::visit(Namespace *ns)
|
||||
bool CreateBindings::visit(Class *klass)
|
||||
{
|
||||
ClassOrNamespace *previous = _currentClassOrNamespace;
|
||||
ClassOrNamespace *binding = 0;
|
||||
ClassOrNamespace *binding = nullptr;
|
||||
|
||||
if (klass->name() && klass->name()->isQualifiedNameId())
|
||||
binding = _currentClassOrNamespace->lookupType(klass->name());
|
||||
|
||||
if (! binding)
|
||||
binding = _currentClassOrNamespace->findOrCreateType(klass->name(), 0, klass);
|
||||
binding = _currentClassOrNamespace->findOrCreateType(klass->name(), nullptr, klass);
|
||||
|
||||
_currentClassOrNamespace = binding;
|
||||
_currentClassOrNamespace->addSymbol(klass);
|
||||
@@ -1737,7 +1737,7 @@ bool CreateBindings::visit(Declaration *decl)
|
||||
} else if (Class *klass = ty->asClassType()) {
|
||||
if (const Identifier *nameId = decl->name()->asNameId()) {
|
||||
ClassOrNamespace *binding
|
||||
= _currentClassOrNamespace->findOrCreateType(nameId, 0, klass);
|
||||
= _currentClassOrNamespace->findOrCreateType(nameId, nullptr, klass);
|
||||
binding->addSymbol(klass);
|
||||
}
|
||||
}
|
||||
@@ -1794,7 +1794,7 @@ bool CreateBindings::visit(Block *block)
|
||||
_entities.append(binding);
|
||||
} else {
|
||||
delete binding;
|
||||
binding = 0;
|
||||
binding = nullptr;
|
||||
}
|
||||
|
||||
_currentClassOrNamespace = previous;
|
||||
|
||||
Reference in New Issue
Block a user