Check nested name specifiers.

This commit is contained in:
Roberto Raggi
2009-06-04 12:18:05 +02:00
parent 45fb9726ab
commit 90efa0f174

View File

@@ -256,6 +256,7 @@ class Process;
class CheckUndefinedSymbols: protected ASTVisitor
{
QSet<QByteArray> _types;
QSet<QByteArray> _namespaceNames;
public:
CheckUndefinedSymbols(Document::Ptr doc)
@@ -313,6 +314,10 @@ protected:
if (! processed->contains(binding)) {
processed->insert(binding);
if (Identifier *id = binding->identifier()) {
_namespaceNames.insert(QByteArray(id->chars(), id->size()));
}
foreach (Namespace *ns, binding->symbols) {
for (unsigned i = 0; i < ns->memberCount(); ++i) {
Symbol *member = ns->memberAt(i);
@@ -504,6 +509,26 @@ protected:
return true;
}
virtual bool visit(QualifiedNameAST *ast)
{
if (ast->name) {
QualifiedNameId *q = ast->name->asQualifiedNameId();
for (unsigned i = 0; i < q->nameCount() - 1; ++i) {
Name *name = q->nameAt(i);
if (Identifier *id = name->identifier()) {
const QByteArray spell = QByteArray::fromRawData(id->chars(), id->size());
if (! (_namespaceNames.contains(spell) || _types.contains(spell))) {
translationUnit()->warning(ast->firstToken(),
"`%s' is not a namespace or class name",
spell.constData());
}
}
}
}
return true;
}
LookupContext lookupContext(unsigned line, unsigned column) const;
private: