Commit c4737c1f authored by Roberto Raggi's avatar Roberto Raggi

Store the names in a set.

parent c4d12742
......@@ -378,8 +378,9 @@ bool CheckDeclaration::visit(LinkageSpecificationAST *ast)
bool CheckDeclaration::visit(NamespaceAST *ast)
{
const Identifier *id = identifier(ast->identifier_token);
const Name *namespaceName = control()->nameId(id);
const Name *namespaceName = 0;
if (const Identifier *id = identifier(ast->identifier_token))
namespaceName = control()->nameId(id);
unsigned sourceLocation = ast->firstToken();
......
This diff is collapsed.
......@@ -50,17 +50,11 @@
#include "NameVisitor.h"
#include "Literals.h"
#include <cstring>
#include <cassert>
#include <algorithm>
using namespace CPlusPlus;
QualifiedNameId::QualifiedNameId(const Name *const *names,
unsigned nameCount,
bool isGlobal)
: _names(names, names + nameCount),
_isGlobal(isGlobal)
{ }
QualifiedNameId::~QualifiedNameId()
{ }
......@@ -159,13 +153,6 @@ bool DestructorNameId::isEqualTo(const Name *other) const
return l->isEqualTo(r);
}
TemplateNameId::TemplateNameId(const Identifier *identifier,
const FullySpecifiedType templateArguments[],
unsigned templateArgumentCount)
: _identifier(identifier),
_templateArguments(templateArguments, templateArguments + templateArgumentCount)
{ }
TemplateNameId::~TemplateNameId()
{ }
......@@ -249,13 +236,6 @@ bool ConversionNameId::isEqualTo(const Name *other) const
return _type.isEqualTo(c->type());
}
SelectorNameId::SelectorNameId(const Name *const *names,
unsigned nameCount,
bool hasArguments)
: _names(names, names + nameCount),
_hasArguments(hasArguments)
{ }
SelectorNameId::~SelectorNameId()
{ }
......
......@@ -59,7 +59,10 @@ namespace CPlusPlus {
class CPLUSPLUS_EXPORT QualifiedNameId: public Name
{
public:
QualifiedNameId(const Name *const *names, unsigned nameCount, bool isGlobal = false);
template <typename _Iterator>
QualifiedNameId(_Iterator first, _Iterator last, bool isGlobal = false)
: _names(first, last), _isGlobal(isGlobal) {}
virtual ~QualifiedNameId();
virtual const Identifier *identifier() const;
......@@ -75,6 +78,11 @@ public:
virtual const QualifiedNameId *asQualifiedNameId() const
{ return this; }
typedef std::vector<const Name *>::const_iterator NameIterator;
NameIterator firstName() const { return _names.begin(); }
NameIterator lastName() const { return _names.end(); }
protected:
virtual void accept0(NameVisitor *visitor) const;
......@@ -126,9 +134,10 @@ private:
class CPLUSPLUS_EXPORT TemplateNameId: public Name
{
public:
TemplateNameId(const Identifier *identifier,
const FullySpecifiedType templateArguments[],
unsigned templateArgumentCount);
template <typename _Iterator>
TemplateNameId(const Identifier *identifier, _Iterator first, _Iterator last)
: _identifier(identifier), _templateArguments(first, last) {}
virtual ~TemplateNameId();
virtual const Identifier *identifier() const;
......@@ -142,6 +151,11 @@ public:
virtual const TemplateNameId *asTemplateNameId() const
{ return this; }
typedef std::vector<FullySpecifiedType>::const_iterator TemplateArgumentIterator;
TemplateArgumentIterator firstTemplateArgument() const { return _templateArguments.begin(); }
TemplateArgumentIterator lastTemplateArgument() const { return _templateArguments.end(); }
protected:
virtual void accept0(NameVisitor *visitor) const;
......@@ -250,7 +264,10 @@ private:
class CPLUSPLUS_EXPORT SelectorNameId: public Name
{
public:
SelectorNameId(const Name *const *names, unsigned nameCount, bool hasArguments);
template <typename _Iterator>
SelectorNameId(_Iterator first, _Iterator last, bool hasArguments)
: _names(first, last), _hasArguments(hasArguments) {}
virtual ~SelectorNameId();
virtual const Identifier *identifier() const;
......@@ -264,6 +281,11 @@ public:
virtual const SelectorNameId *asSelectorNameId() const
{ return this; }
typedef std::vector<const Name *>::const_iterator NameIterator;
NameIterator firstName() const { return _names.begin(); }
NameIterator lastName() const { return _names.end(); }
protected:
virtual void accept0(NameVisitor *visitor) const;
......@@ -274,5 +296,4 @@ private:
} // end of namespace CPlusPlus
#endif // CPLUSPLUS_NAMES_H
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