forked from qt-creator/qt-creator
Use const literals.
This commit is contained in:
@@ -65,7 +65,7 @@ void CheckUndefinedSymbols::operator()(AST *ast)
|
||||
QByteArray CheckUndefinedSymbols::templateParameterName(NameAST *ast) const
|
||||
{
|
||||
if (ast && ast->name) {
|
||||
if (Identifier *id = ast->name->identifier())
|
||||
if (const Identifier *id = ast->name->identifier())
|
||||
return QByteArray::fromRawData(id->chars(), id->size());
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ bool CheckUndefinedSymbols::isType(const QByteArray &name) const
|
||||
Symbol *member = members->symbolAt(m);
|
||||
|
||||
if (member->isTypedef() && member->isDeclaration()) {
|
||||
if (Identifier *id = member->identifier()) {
|
||||
if (const Identifier *id = member->identifier()) {
|
||||
if (name == id->chars())
|
||||
return true;
|
||||
}
|
||||
@@ -114,7 +114,7 @@ bool CheckUndefinedSymbols::isType(const QByteArray &name) const
|
||||
return _types.contains(name);
|
||||
}
|
||||
|
||||
bool CheckUndefinedSymbols::isType(Identifier *id) const
|
||||
bool CheckUndefinedSymbols::isType(const Identifier *id) const
|
||||
{
|
||||
if (! id)
|
||||
return false;
|
||||
@@ -127,7 +127,7 @@ void CheckUndefinedSymbols::addType(Name *name)
|
||||
if (! name)
|
||||
return;
|
||||
|
||||
if (Identifier *id = name->identifier())
|
||||
if (const Identifier *id = name->identifier())
|
||||
_types.insert(QByteArray(id->chars(), id->size()));
|
||||
}
|
||||
|
||||
@@ -136,7 +136,7 @@ void CheckUndefinedSymbols::addProtocol(Name *name)
|
||||
if (!name)
|
||||
return;
|
||||
|
||||
if (Identifier *id = name->identifier())
|
||||
if (const Identifier *id = name->identifier())
|
||||
_protocols.insert(QByteArray(id->chars(), id->size()));
|
||||
}
|
||||
|
||||
@@ -176,7 +176,7 @@ void CheckUndefinedSymbols::buildTypeMap(NamespaceBinding *binding, QSet<Namespa
|
||||
if (! processed->contains(binding)) {
|
||||
processed->insert(binding);
|
||||
|
||||
if (Identifier *id = binding->identifier()) {
|
||||
if (const Identifier *id = binding->identifier()) {
|
||||
_namespaceNames.insert(QByteArray(id->chars(), id->size()));
|
||||
}
|
||||
|
||||
@@ -256,7 +256,7 @@ bool CheckUndefinedSymbols::visit(NamedTypeSpecifierAST *ast)
|
||||
unsigned line, col;
|
||||
getTokenStartPosition(ast->firstToken(), &line, &col);
|
||||
// qWarning() << _doc->fileName() << line << col;
|
||||
} else if (Identifier *id = ast->name->name->identifier()) {
|
||||
} else if (const Identifier *id = ast->name->name->identifier()) {
|
||||
if (! isType(id)) {
|
||||
if (FunctionDeclaratorAST *functionDeclarator = currentFunctionDeclarator()) {
|
||||
if (functionDeclarator->as_cpp_initializer)
|
||||
@@ -368,7 +368,7 @@ bool CheckUndefinedSymbols::visit(BaseSpecifierAST *base)
|
||||
bool resolvedBaseClassName = false;
|
||||
|
||||
if (Name *name = nameAST->name) {
|
||||
Identifier *id = name->identifier();
|
||||
const Identifier *id = name->identifier();
|
||||
const QByteArray spell = QByteArray::fromRawData(id->chars(), id->size());
|
||||
if (isType(spell))
|
||||
resolvedBaseClassName = true;
|
||||
@@ -406,7 +406,7 @@ bool CheckUndefinedSymbols::visit(QualifiedNameAST *ast)
|
||||
QualifiedNameId *q = ast->name->asQualifiedNameId();
|
||||
for (unsigned i = 0; i < q->nameCount() - 1; ++i) {
|
||||
Name *name = q->nameAt(i);
|
||||
if (Identifier *id = name->identifier()) {
|
||||
if (const Identifier *id = name->identifier()) {
|
||||
const QByteArray spell = QByteArray::fromRawData(id->chars(), id->size());
|
||||
if (! (_namespaceNames.contains(spell) || isType(id))) {
|
||||
translationUnit()->warning(ast->firstToken(),
|
||||
@@ -475,7 +475,7 @@ bool CheckUndefinedSymbols::visit(ObjCClassDeclarationAST *ast)
|
||||
bool resolvedSuperClassName = false;
|
||||
|
||||
if (Name *name = nameAST->name) {
|
||||
Identifier *id = name->identifier();
|
||||
const Identifier *id = name->identifier();
|
||||
const QByteArray spell = QByteArray::fromRawData(id->chars(), id->size());
|
||||
if (isType(spell))
|
||||
resolvedSuperClassName = true;
|
||||
@@ -497,7 +497,7 @@ bool CheckUndefinedSymbols::visit(ObjCProtocolRefsAST *ast)
|
||||
bool resolvedProtocolName = false;
|
||||
|
||||
if (Name *name = nameAST->name) {
|
||||
Identifier *id = name->identifier();
|
||||
const Identifier *id = name->identifier();
|
||||
const QByteArray spell = QByteArray::fromRawData(id->chars(), id->size());
|
||||
if (isProtocol(spell))
|
||||
resolvedProtocolName = true;
|
||||
@@ -522,11 +522,11 @@ bool CheckUndefinedSymbols::visit(ObjCProtocolRefsAST *ast)
|
||||
bool CheckUndefinedSymbols::visit(ObjCPropertyDeclarationAST *ast)
|
||||
{
|
||||
for (List<ObjCPropertyDeclaration *> *iter = ast->symbols; iter; iter = iter->next) {
|
||||
if (Name *getterName = iter->value->getterName()) {
|
||||
if (/*Name *getterName = */ iter->value->getterName()) {
|
||||
// FIXME: resolve the symbol for the name, and check its signature.
|
||||
}
|
||||
|
||||
if (Name *setterName = iter->value->setterName()) {
|
||||
if (/*Name *setterName = */ iter->value->setterName()) {
|
||||
// FIXME: resolve the symbol for the name, and check its signature.
|
||||
}
|
||||
}
|
||||
|
@@ -52,7 +52,7 @@ public:
|
||||
protected:
|
||||
using ASTVisitor::visit;
|
||||
|
||||
bool isType(Identifier *id) const;
|
||||
bool isType(const Identifier *id) const;
|
||||
bool isType(const QByteArray &name) const;
|
||||
|
||||
void addType(Name *name);
|
||||
|
@@ -57,7 +57,7 @@ Location::Location(Symbol *symbol)
|
||||
_sourceLocation(symbol->sourceLocation())
|
||||
{ }
|
||||
|
||||
Location::Location(StringLiteral *fileId, unsigned sourceLocation)
|
||||
Location::Location(const StringLiteral *fileId, unsigned sourceLocation)
|
||||
: _fileId(fileId), _sourceLocation(sourceLocation)
|
||||
{ }
|
||||
|
||||
@@ -93,7 +93,7 @@ NameId *NamespaceBinding::name() const
|
||||
return 0;
|
||||
}
|
||||
|
||||
Identifier *NamespaceBinding::identifier() const
|
||||
const Identifier *NamespaceBinding::identifier() const
|
||||
{
|
||||
if (NameId *nameId = name())
|
||||
return nameId->identifier();
|
||||
@@ -113,7 +113,7 @@ NamespaceBinding *NamespaceBinding::globalNamespaceBinding()
|
||||
return it;
|
||||
}
|
||||
|
||||
Binding *NamespaceBinding::findClassOrNamespaceBinding(Identifier *id, QSet<Binding *> *processed)
|
||||
Binding *NamespaceBinding::findClassOrNamespaceBinding(const Identifier *id, QSet<Binding *> *processed)
|
||||
{
|
||||
if (processed->contains(this))
|
||||
return 0;
|
||||
@@ -156,7 +156,7 @@ ClassBinding *NamespaceBinding::findClassBinding(Name *name, QSet<Binding *> *pr
|
||||
Binding *current = this;
|
||||
|
||||
for (unsigned i = 0; i < q->nameCount(); ++i) {
|
||||
Identifier *nameId = q->nameAt(i)->identifier();
|
||||
const Identifier *nameId = q->nameAt(i)->identifier();
|
||||
if (! nameId)
|
||||
return 0;
|
||||
|
||||
@@ -173,7 +173,7 @@ ClassBinding *NamespaceBinding::findClassBinding(Name *name, QSet<Binding *> *pr
|
||||
|
||||
processed->insert(this);
|
||||
|
||||
Identifier *id = name->identifier();
|
||||
const Identifier *id = name->identifier();
|
||||
|
||||
foreach (ClassBinding *classBinding, classBindings) {
|
||||
if (id->isEqualTo(classBinding->identifier()))
|
||||
@@ -306,7 +306,7 @@ static void closure(const Location &loc,
|
||||
|
||||
Q_ASSERT(name->isNameId());
|
||||
|
||||
Identifier *id = name->asNameId()->identifier();
|
||||
const Identifier *id = name->asNameId()->identifier();
|
||||
bool ignoreUsingDirectives = false;
|
||||
|
||||
foreach (Namespace *symbol, binding->symbols) {
|
||||
@@ -394,7 +394,7 @@ QByteArray NamespaceBinding::qualifiedId() const
|
||||
s.append(parent->qualifiedId());
|
||||
s.append("::");
|
||||
|
||||
if (Identifier *id = identifier())
|
||||
if (const Identifier *id = identifier())
|
||||
s.append(id->chars(), id->size());
|
||||
|
||||
else
|
||||
@@ -409,7 +409,7 @@ QByteArray ClassBinding::qualifiedId() const
|
||||
QByteArray s = parent->qualifiedId();
|
||||
s += "::";
|
||||
|
||||
if (Identifier *id = identifier())
|
||||
if (const Identifier *id = identifier())
|
||||
s.append(id->chars(), id->size());
|
||||
|
||||
else
|
||||
@@ -418,7 +418,7 @@ QByteArray ClassBinding::qualifiedId() const
|
||||
return s;
|
||||
}
|
||||
|
||||
Binding *ClassBinding::findClassOrNamespaceBinding(Identifier *id, QSet<Binding *> *processed)
|
||||
Binding *ClassBinding::findClassOrNamespaceBinding(const Identifier *id, QSet<Binding *> *processed)
|
||||
{
|
||||
if (id->isEqualTo(identifier()))
|
||||
return this;
|
||||
@@ -461,7 +461,7 @@ ClassBinding *ClassBinding::findClassBinding(Name *name, QSet<Binding *> *proces
|
||||
Binding *currentBinding = this;
|
||||
|
||||
for (unsigned i = 0; i < q->nameCount() - 1; ++i) {
|
||||
Identifier *id = q->nameAt(i)->identifier();
|
||||
const Identifier *id = q->nameAt(i)->identifier();
|
||||
if (! id)
|
||||
return 0;
|
||||
|
||||
@@ -479,12 +479,12 @@ ClassBinding *ClassBinding::findClassBinding(Name *name, QSet<Binding *> *proces
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (Identifier *id = name->identifier()) {
|
||||
if (const Identifier *id = name->identifier()) {
|
||||
if (id->isEqualTo(identifier()))
|
||||
return this;
|
||||
|
||||
foreach (ClassBinding *nestedClassBinding, children) {
|
||||
if (Identifier *nestedClassId = nestedClassBinding->identifier()) {
|
||||
if (const Identifier *nestedClassId = nestedClassBinding->identifier()) {
|
||||
if (nestedClassId->isEqualTo(id))
|
||||
return nestedClassBinding;
|
||||
}
|
||||
@@ -557,7 +557,7 @@ Name *ClassBinding::name() const
|
||||
return symbols.first()->name();
|
||||
}
|
||||
|
||||
Identifier *ClassBinding::identifier() const
|
||||
const Identifier *ClassBinding::identifier() const
|
||||
{
|
||||
if (Name *n = name())
|
||||
return n->identifier();
|
||||
|
@@ -53,7 +53,7 @@ class CPLUSPLUS_EXPORT Location
|
||||
public:
|
||||
Location();
|
||||
Location(Symbol *symbol);
|
||||
Location(StringLiteral *fileId, unsigned sourceLocation);
|
||||
Location(const StringLiteral *fileId, unsigned sourceLocation);
|
||||
|
||||
inline bool isValid() const
|
||||
{ return _fileId != 0; }
|
||||
@@ -61,14 +61,14 @@ public:
|
||||
inline operator bool() const
|
||||
{ return _fileId != 0; }
|
||||
|
||||
inline StringLiteral *fileId() const
|
||||
inline const StringLiteral *fileId() const
|
||||
{ return _fileId; }
|
||||
|
||||
inline unsigned sourceLocation() const
|
||||
{ return _sourceLocation; }
|
||||
|
||||
private:
|
||||
StringLiteral *_fileId;
|
||||
const StringLiteral *_fileId;
|
||||
unsigned _sourceLocation;
|
||||
};
|
||||
|
||||
@@ -85,7 +85,7 @@ public:
|
||||
virtual ClassBinding *asClassBinding() { return 0; }
|
||||
|
||||
virtual ClassBinding *findClassBinding(Name *name, QSet<Binding *> *processed) = 0;
|
||||
virtual Binding *findClassOrNamespaceBinding(Identifier *id, QSet<Binding *> *processed) = 0;
|
||||
virtual Binding *findClassOrNamespaceBinding(const Identifier *id, QSet<Binding *> *processed) = 0;
|
||||
};
|
||||
|
||||
class CPLUSPLUS_EXPORT NamespaceBinding: public Binding
|
||||
@@ -101,7 +101,7 @@ public:
|
||||
NameId *name() const;
|
||||
|
||||
/// Returns this binding's identifier.
|
||||
Identifier *identifier() const;
|
||||
const Identifier *identifier() const;
|
||||
|
||||
/// Returns the binding for the global namespace (aka ::).
|
||||
NamespaceBinding *globalNamespaceBinding();
|
||||
@@ -117,7 +117,7 @@ public:
|
||||
bool lookAtParent = true);
|
||||
|
||||
virtual ClassBinding *findClassBinding(Name *name, QSet<Binding *> *processed);
|
||||
virtual Binding *findClassOrNamespaceBinding(Identifier *id, QSet<Binding *> *processed);
|
||||
virtual Binding *findClassOrNamespaceBinding(const Identifier *id, QSet<Binding *> *processed);
|
||||
|
||||
/// Helpers.
|
||||
virtual QByteArray qualifiedId() const;
|
||||
@@ -168,11 +168,11 @@ public:
|
||||
Name *name() const;
|
||||
|
||||
/// Returns this binding's identifier.
|
||||
Identifier *identifier() const;
|
||||
const Identifier *identifier() const;
|
||||
virtual QByteArray qualifiedId() const;
|
||||
|
||||
virtual ClassBinding *findClassBinding(Name *name, QSet<Binding *> *processed);
|
||||
virtual Binding *findClassOrNamespaceBinding(Identifier *id, QSet<Binding *> *processed);
|
||||
virtual Binding *findClassOrNamespaceBinding(const Identifier *id, QSet<Binding *> *processed);
|
||||
|
||||
void dump();
|
||||
|
||||
|
@@ -66,7 +66,7 @@ public:
|
||||
{ }
|
||||
|
||||
virtual void report(int level,
|
||||
StringLiteral *fileId,
|
||||
const StringLiteral *fileId,
|
||||
unsigned line, unsigned column,
|
||||
const char *format, va_list ap)
|
||||
{
|
||||
@@ -118,8 +118,8 @@ Document::Document(const QString &fileName)
|
||||
_control->setDiagnosticClient(new DocumentDiagnosticClient(this, &_diagnosticMessages));
|
||||
|
||||
const QByteArray localFileName = fileName.toUtf8();
|
||||
StringLiteral *fileId = _control->findOrInsertStringLiteral(localFileName.constData(),
|
||||
localFileName.size());
|
||||
const StringLiteral *fileId = _control->findOrInsertStringLiteral(localFileName.constData(),
|
||||
localFileName.size());
|
||||
_translationUnit = new TranslationUnit(_control, fileId);
|
||||
_translationUnit->setQtMocRunEnabled(true);
|
||||
_translationUnit->setObjCEnabled(true);
|
||||
|
@@ -57,7 +57,7 @@ void FindUsages::setGlobalNamespaceBinding(NamespaceBindingPtr globalNamespaceBi
|
||||
_globalNamespaceBinding = globalNamespaceBinding;
|
||||
}
|
||||
|
||||
QList<int> FindUsages::operator()(Symbol *symbol, Identifier *id, AST *ast)
|
||||
QList<int> FindUsages::operator()(Symbol *symbol, const Identifier *id, AST *ast)
|
||||
{
|
||||
_processed.clear();
|
||||
_references.clear();
|
||||
@@ -344,7 +344,7 @@ bool FindUsages::visit(QualifiedNameAST *ast)
|
||||
|
||||
bool FindUsages::visit(EnumeratorAST *ast)
|
||||
{
|
||||
Identifier *id = identifier(ast->identifier_token);
|
||||
const Identifier *id = identifier(ast->identifier_token);
|
||||
if (id == _id) {
|
||||
LookupContext context = currentContext(ast);
|
||||
const QList<Symbol *> candidates = context.resolve(control()->nameId(id));
|
||||
@@ -358,7 +358,7 @@ bool FindUsages::visit(EnumeratorAST *ast)
|
||||
|
||||
bool FindUsages::visit(SimpleNameAST *ast)
|
||||
{
|
||||
Identifier *id = identifier(ast->identifier_token);
|
||||
const Identifier *id = identifier(ast->identifier_token);
|
||||
if (id == _id) {
|
||||
LookupContext context = currentContext(ast);
|
||||
const QList<Symbol *> candidates = context.resolve(ast->name);
|
||||
@@ -370,7 +370,7 @@ bool FindUsages::visit(SimpleNameAST *ast)
|
||||
|
||||
bool FindUsages::visit(DestructorNameAST *ast)
|
||||
{
|
||||
Identifier *id = identifier(ast->identifier_token);
|
||||
const Identifier *id = identifier(ast->identifier_token);
|
||||
if (id == _id) {
|
||||
LookupContext context = currentContext(ast);
|
||||
const QList<Symbol *> candidates = context.resolve(ast->name);
|
||||
|
@@ -64,7 +64,7 @@ public:
|
||||
|
||||
void setGlobalNamespaceBinding(NamespaceBindingPtr globalNamespaceBinding);
|
||||
|
||||
QList<int> operator()(Symbol *symbol, Identifier *id, AST *ast);
|
||||
QList<int> operator()(Symbol *symbol, const Identifier *id, AST *ast);
|
||||
|
||||
protected:
|
||||
using ASTVisitor::visit;
|
||||
@@ -101,7 +101,7 @@ protected:
|
||||
|
||||
private:
|
||||
QFutureInterface<Usage> *_future;
|
||||
Identifier *_id;
|
||||
const Identifier *_id;
|
||||
Symbol *_declSymbol;
|
||||
Document::Ptr _doc;
|
||||
Snapshot _snapshot;
|
||||
|
@@ -55,7 +55,7 @@ public:
|
||||
FullySpecifiedType apply(Name *name);
|
||||
FullySpecifiedType apply(const FullySpecifiedType &type);
|
||||
|
||||
int findSubstitution(Identifier *id) const;
|
||||
int findSubstitution(const Identifier *id) const;
|
||||
FullySpecifiedType applySubstitution(int index) const;
|
||||
|
||||
private:
|
||||
@@ -218,7 +218,7 @@ private:
|
||||
Control *control() const
|
||||
{ return q->control(); }
|
||||
|
||||
int findSubstitution(Identifier *id) const
|
||||
int findSubstitution(const Identifier *id) const
|
||||
{ return q->findSubstitution(id); }
|
||||
|
||||
FullySpecifiedType applySubstitution(int index) const
|
||||
@@ -337,12 +337,12 @@ FullySpecifiedType ApplySubstitution::apply(const FullySpecifiedType &type)
|
||||
return ty;
|
||||
}
|
||||
|
||||
int ApplySubstitution::findSubstitution(Identifier *id) const
|
||||
int ApplySubstitution::findSubstitution(const Identifier *id) const
|
||||
{
|
||||
Q_ASSERT(id != 0);
|
||||
|
||||
for (int index = 0; index < substitution.size(); ++index) {
|
||||
QPair<Identifier *, FullySpecifiedType> s = substitution.at(index);
|
||||
QPair<const Identifier *, FullySpecifiedType> s = substitution.at(index);
|
||||
|
||||
if (id->isEqualTo(s.first))
|
||||
return index;
|
||||
|
@@ -44,7 +44,7 @@ namespace CPlusPlus {
|
||||
class CPLUSPLUS_EXPORT GenTemplateInstance
|
||||
{
|
||||
public:
|
||||
typedef QList< QPair<Identifier *, FullySpecifiedType> > Substitution;
|
||||
typedef QList< QPair<const Identifier *, FullySpecifiedType> > Substitution;
|
||||
|
||||
public:
|
||||
GenTemplateInstance(const LookupContext &context, const Substitution &substitution);
|
||||
|
@@ -240,7 +240,7 @@ QList<Symbol *> LookupContext::resolve(Name *name, const QList<Scope *> &visible
|
||||
else if (OperatorNameId *opId = name->asOperatorNameId())
|
||||
return resolveOperatorNameId(opId, visibleScopes, mode);
|
||||
|
||||
else if (Identifier *id = name->identifier()) {
|
||||
else if (const Identifier *id = name->identifier()) {
|
||||
for (int scopeIndex = 0; scopeIndex < visibleScopes.size(); ++scopeIndex) {
|
||||
Scope *scope = visibleScopes.at(scopeIndex);
|
||||
|
||||
@@ -251,7 +251,7 @@ QList<Symbol *> LookupContext::resolve(Name *name, const QList<Scope *> &visible
|
||||
else if (! maybeValidSymbol(symbol, mode, candidates))
|
||||
continue; // skip it, we're not looking for this kind of symbols
|
||||
|
||||
else if (Identifier *symbolId = symbol->identifier()) {
|
||||
else if (const Identifier *symbolId = symbol->identifier()) {
|
||||
if (! symbolId->isEqualTo(id))
|
||||
continue; // skip it, the symbol's id is not compatible with this lookup.
|
||||
}
|
||||
@@ -265,7 +265,7 @@ QList<Symbol *> LookupContext::resolve(Name *name, const QList<Scope *> &visible
|
||||
Name *classOrNamespaceName = control()->qualifiedNameId(q->names(),
|
||||
q->nameCount() - 1);
|
||||
|
||||
if (Identifier *classOrNamespaceNameId = identifier(classOrNamespaceName)) {
|
||||
if (const Identifier *classOrNamespaceNameId = identifier(classOrNamespaceName)) {
|
||||
if (classOrNamespaceNameId->isEqualTo(id))
|
||||
continue;
|
||||
}
|
||||
@@ -299,7 +299,7 @@ QList<Symbol *> LookupContext::resolve(Name *name, const QList<Scope *> &visible
|
||||
return candidates;
|
||||
}
|
||||
|
||||
Identifier *LookupContext::identifier(const Name *name) const
|
||||
const Identifier *LookupContext::identifier(const Name *name) const
|
||||
{
|
||||
if (name)
|
||||
return name->identifier();
|
||||
@@ -667,7 +667,7 @@ Symbol *LookupContext::canonicalSymbol(Symbol *symbol,
|
||||
if (! canonicalSymbol)
|
||||
return 0;
|
||||
|
||||
if (Identifier *symbolId = canonicalSymbol->identifier()) {
|
||||
if (const Identifier *symbolId = canonicalSymbol->identifier()) {
|
||||
if (symbolId && canonicalSymbol->type()->isFunctionType()) {
|
||||
Class *enclosingClass = canonicalSymbol->scope()->owner()->asClass();
|
||||
const QList<ClassBinding *> classBindings = visibleClassBindings(enclosingClass, globalNamespace);
|
||||
|
@@ -198,7 +198,7 @@ private:
|
||||
QList<Scope *> resolveNestedNameSpecifier(QualifiedNameId *q,
|
||||
const QList<Scope *> &visibleScopes) const;
|
||||
|
||||
Identifier *identifier(const Name *name) const;
|
||||
const Identifier *identifier(const Name *name) const;
|
||||
|
||||
QList<Scope *> buildVisibleScopes();
|
||||
|
||||
|
@@ -64,7 +64,7 @@ QString NamePrettyPrinter::switchName(const QString &name)
|
||||
|
||||
void NamePrettyPrinter::visit(NameId *name)
|
||||
{
|
||||
Identifier *id = name->identifier();
|
||||
const Identifier *id = name->identifier();
|
||||
if (id)
|
||||
_name = QString::fromLatin1(id->chars(), id->size());
|
||||
else
|
||||
@@ -73,7 +73,7 @@ void NamePrettyPrinter::visit(NameId *name)
|
||||
|
||||
void NamePrettyPrinter::visit(TemplateNameId *name)
|
||||
{
|
||||
Identifier *id = name->identifier();
|
||||
const Identifier *id = name->identifier();
|
||||
if (id)
|
||||
_name = QString::fromLatin1(id->chars(), id->size());
|
||||
else
|
||||
@@ -95,7 +95,7 @@ void NamePrettyPrinter::visit(TemplateNameId *name)
|
||||
|
||||
void NamePrettyPrinter::visit(DestructorNameId *name)
|
||||
{
|
||||
Identifier *id = name->identifier();
|
||||
const Identifier *id = name->identifier();
|
||||
_name += QLatin1Char('~');
|
||||
_name += QString::fromLatin1(id->chars(), id->size());
|
||||
}
|
||||
@@ -261,8 +261,7 @@ void NamePrettyPrinter::visit(SelectorNameId *name)
|
||||
if (!n)
|
||||
continue;
|
||||
|
||||
Identifier *id = n->identifier();
|
||||
if (id) {
|
||||
if (const Identifier *id = n->identifier()) {
|
||||
_name += QString::fromLatin1(id->chars(), id->size());
|
||||
|
||||
if (name->hasArguments() || name->nameCount() > 1)
|
||||
|
@@ -226,7 +226,7 @@ bool ResolveExpression::visit(SizeofExpressionAST *)
|
||||
bool ResolveExpression::visit(NumericLiteralAST *ast)
|
||||
{
|
||||
Type *type = 0;
|
||||
NumericLiteral *literal = numericLiteral(ast->literal_token);
|
||||
const NumericLiteral *literal = numericLiteral(ast->literal_token);
|
||||
|
||||
if (literal->isChar())
|
||||
type = control()->integerType(IntegerType::Char);
|
||||
@@ -723,7 +723,7 @@ ResolveExpression::resolveMember(Name *memberName, Class *klass,
|
||||
if (i < klass->templateParameterCount()) {
|
||||
Name *templArgName = klass->templateParameterAt(i)->name();
|
||||
if (templArgName && templArgName->identifier()) {
|
||||
Identifier *templArgId = templArgName->identifier();
|
||||
const Identifier *templArgId = templArgName->identifier();
|
||||
subst.append(qMakePair(templArgId, templArgTy));
|
||||
}
|
||||
}
|
||||
|
@@ -219,7 +219,7 @@ protected:
|
||||
if (! (ast && ast->name))
|
||||
return false;
|
||||
|
||||
Identifier *id = ast->name->identifier();
|
||||
const Identifier *id = ast->name->identifier();
|
||||
|
||||
if (scope) {
|
||||
for (Symbol *member = scope->lookat(id); member; member = member->next()) {
|
||||
@@ -1701,9 +1701,9 @@ void CPPEditor::performQuickFix(int index)
|
||||
{
|
||||
CPPQuickFixCollector *quickFixCollector = CppPlugin::instance()->quickFixCollector();
|
||||
QuickFixOperationPtr op = m_quickFixes.at(index);
|
||||
//quickFixCollector->perform(op);
|
||||
op->createChangeSet();
|
||||
setChangeSet(op->changeSet());
|
||||
quickFixCollector->perform(op);
|
||||
//op->createChangeSet();
|
||||
//setChangeSet(op->changeSet());
|
||||
}
|
||||
|
||||
void CPPEditor::contextMenuEvent(QContextMenuEvent *e)
|
||||
|
@@ -162,7 +162,7 @@ static QString buildHelpId(Symbol *symbol, Name *name)
|
||||
|
||||
if (owner && owner->name() && ! scope->isEnumScope()) {
|
||||
Name *name = owner->name();
|
||||
Identifier *id = 0;
|
||||
const Identifier *id = 0;
|
||||
|
||||
if (NameId *nameId = name->asNameId())
|
||||
id = nameId->identifier();
|
||||
@@ -341,7 +341,7 @@ void CppHoverHandler::updateHelpIdAndTooltip(TextEditor::ITextEditor *editor, in
|
||||
if (resolvedSymbol && resolvedSymbol->scope()
|
||||
&& resolvedSymbol->scope()->isClassScope()) {
|
||||
Class *enclosingClass = resolvedSymbol->scope()->owner()->asClass();
|
||||
if (Identifier *id = enclosingClass->identifier()) {
|
||||
if (const Identifier *id = enclosingClass->identifier()) {
|
||||
if (id->isEqualTo(resolvedSymbol->identifier()))
|
||||
resolvedSymbol = enclosingClass;
|
||||
}
|
||||
|
@@ -79,8 +79,8 @@ QList<int> CppFindReferences::references(Symbol *symbol,
|
||||
Document::Ptr doc,
|
||||
const Snapshot& snapshot) const
|
||||
{
|
||||
Identifier *id = 0;
|
||||
if (Identifier *symbolId = symbol->identifier())
|
||||
const Identifier *id = 0;
|
||||
if (const Identifier *symbolId = symbol->identifier())
|
||||
id = doc->control()->findIdentifier(symbolId->chars(), symbolId->size());
|
||||
|
||||
QList<int> references;
|
||||
@@ -106,7 +106,7 @@ static void find_helper(QFutureInterface<Usage> &future,
|
||||
QTime tm;
|
||||
tm.start();
|
||||
|
||||
Identifier *symbolId = symbol->identifier();
|
||||
const Identifier *symbolId = symbol->identifier();
|
||||
Q_ASSERT(symbolId != 0);
|
||||
|
||||
const QString sourceFile = QString::fromUtf8(symbol->fileName(), symbol->fileNameLength());
|
||||
@@ -142,7 +142,7 @@ static void find_helper(QFutureInterface<Usage> &future,
|
||||
|
||||
if (Document::Ptr previousDoc = snapshot.value(fileName)) {
|
||||
Control *control = previousDoc->control();
|
||||
Identifier *id = control->findIdentifier(symbolId->chars(), symbolId->size());
|
||||
const Identifier *id = control->findIdentifier(symbolId->chars(), symbolId->size());
|
||||
if (! id)
|
||||
continue; // skip this document, it's not using symbolId.
|
||||
}
|
||||
@@ -164,7 +164,7 @@ static void find_helper(QFutureInterface<Usage> &future,
|
||||
doc->tokenize();
|
||||
|
||||
Control *control = doc->control();
|
||||
if (Identifier *id = control->findIdentifier(symbolId->chars(), symbolId->size())) {
|
||||
if (const Identifier *id = control->findIdentifier(symbolId->chars(), symbolId->size())) {
|
||||
QTime tm;
|
||||
tm.start();
|
||||
doc->parse();
|
||||
@@ -202,7 +202,7 @@ void CppFindReferences::findUsages(Symbol *symbol)
|
||||
|
||||
void CppFindReferences::renameUsages(Symbol *symbol)
|
||||
{
|
||||
if (Identifier *id = symbol->identifier()) {
|
||||
if (const Identifier *id = symbol->identifier()) {
|
||||
const QString textToReplace = QString::fromUtf8(id->chars(), id->size());
|
||||
|
||||
Find::SearchResult *search = _resultWindow->startNewSearch(Find::SearchResultWindow::SearchAndReplace);
|
||||
|
@@ -666,7 +666,7 @@ static int blockStartState(const QTextBlock &block)
|
||||
return state & 0xff;
|
||||
}
|
||||
|
||||
void ScriptEditor::indentBlock(QTextDocument *, QTextBlock block, QChar typedChar)
|
||||
void ScriptEditor::indentBlock(QTextDocument *, QTextBlock block, QChar /*typedChar*/)
|
||||
{
|
||||
TextEditor::TabSettings ts = tabSettings();
|
||||
|
||||
|
@@ -104,7 +104,7 @@ namespace QmlEditor {
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual bool visit(Block *ast)
|
||||
virtual bool visit(Block * /*ast*/)
|
||||
{
|
||||
// TODO
|
||||
// if (_pos > ast->lbraceToken.end() && _pos < ast->rbraceToken.offset) {
|
||||
|
@@ -89,28 +89,28 @@ int ASTVisitor::tokenKind(unsigned index) const
|
||||
const char *ASTVisitor::spell(unsigned index) const
|
||||
{ return translationUnit()->spell(index); }
|
||||
|
||||
Identifier *ASTVisitor::identifier(unsigned index) const
|
||||
const Identifier *ASTVisitor::identifier(unsigned index) const
|
||||
{ return translationUnit()->identifier(index); }
|
||||
|
||||
Literal *ASTVisitor::literal(unsigned index) const
|
||||
const Literal *ASTVisitor::literal(unsigned index) const
|
||||
{ return translationUnit()->literal(index); }
|
||||
|
||||
NumericLiteral *ASTVisitor::numericLiteral(unsigned index) const
|
||||
const NumericLiteral *ASTVisitor::numericLiteral(unsigned index) const
|
||||
{ return translationUnit()->numericLiteral(index); }
|
||||
|
||||
StringLiteral *ASTVisitor::stringLiteral(unsigned index) const
|
||||
const StringLiteral *ASTVisitor::stringLiteral(unsigned index) const
|
||||
{ return translationUnit()->stringLiteral(index); }
|
||||
|
||||
void ASTVisitor::getPosition(unsigned offset,
|
||||
unsigned *line,
|
||||
unsigned *column,
|
||||
StringLiteral **fileName) const
|
||||
const StringLiteral **fileName) const
|
||||
{ translationUnit()->getPosition(offset, line, column, fileName); }
|
||||
|
||||
void ASTVisitor::getTokenPosition(unsigned index,
|
||||
unsigned *line,
|
||||
unsigned *column,
|
||||
StringLiteral **fileName) const
|
||||
const StringLiteral **fileName) const
|
||||
{ translationUnit()->getTokenPosition(index, line, column, fileName); }
|
||||
|
||||
void ASTVisitor::getTokenStartPosition(unsigned index, unsigned *line, unsigned *column) const
|
||||
|
@@ -72,20 +72,20 @@ public:
|
||||
const Token &tokenAt(unsigned index) const;
|
||||
int tokenKind(unsigned index) const;
|
||||
const char *spell(unsigned index) const;
|
||||
Identifier *identifier(unsigned index) const;
|
||||
Literal *literal(unsigned index) const;
|
||||
NumericLiteral *numericLiteral(unsigned index) const;
|
||||
StringLiteral *stringLiteral(unsigned index) const;
|
||||
const Identifier *identifier(unsigned index) const;
|
||||
const Literal *literal(unsigned index) const;
|
||||
const NumericLiteral *numericLiteral(unsigned index) const;
|
||||
const StringLiteral *stringLiteral(unsigned index) const;
|
||||
|
||||
void getPosition(unsigned offset,
|
||||
unsigned *line,
|
||||
unsigned *column = 0,
|
||||
StringLiteral **fileName = 0) const;
|
||||
const StringLiteral **fileName = 0) const;
|
||||
|
||||
void getTokenPosition(unsigned index,
|
||||
unsigned *line,
|
||||
unsigned *column = 0,
|
||||
StringLiteral **fileName = 0) const;
|
||||
const StringLiteral **fileName = 0) const;
|
||||
|
||||
void getTokenStartPosition(unsigned index, unsigned *line, unsigned *column) const;
|
||||
void getTokenEndPosition(unsigned index, unsigned *line, unsigned *column) const;
|
||||
|
@@ -378,7 +378,7 @@ bool CheckDeclaration::visit(LinkageSpecificationAST *ast)
|
||||
|
||||
bool CheckDeclaration::visit(NamespaceAST *ast)
|
||||
{
|
||||
Identifier *id = identifier(ast->identifier_token);
|
||||
const Identifier *id = identifier(ast->identifier_token);
|
||||
Name *namespaceName = control()->nameId(id);
|
||||
|
||||
unsigned sourceLocation = ast->firstToken();
|
||||
@@ -718,7 +718,7 @@ bool CheckDeclaration::visit(ObjCPropertyDeclarationAST *ast)
|
||||
if (!attrAst)
|
||||
continue;
|
||||
|
||||
Identifier *attrId = identifier(attrAst->attribute_identifier_token);
|
||||
const Identifier *attrId = identifier(attrAst->attribute_identifier_token);
|
||||
if (attrId == control()->objcGetterId()) {
|
||||
if (checkPropertyAttribute(attrAst, propAttrs, ObjCPropertyDeclaration::Getter)) {
|
||||
getterName = semantic()->check(attrAst->method_selector, _scope);
|
||||
|
@@ -343,7 +343,7 @@ bool CheckName::visit(ConversionFunctionIdAST *ast)
|
||||
|
||||
bool CheckName::visit(SimpleNameAST *ast)
|
||||
{
|
||||
Identifier *id = identifier(ast->identifier_token);
|
||||
const Identifier *id = identifier(ast->identifier_token);
|
||||
_name = control()->nameId(id);
|
||||
ast->name = _name;
|
||||
return false;
|
||||
@@ -351,7 +351,7 @@ bool CheckName::visit(SimpleNameAST *ast)
|
||||
|
||||
bool CheckName::visit(DestructorNameAST *ast)
|
||||
{
|
||||
Identifier *id = identifier(ast->identifier_token);
|
||||
const Identifier *id = identifier(ast->identifier_token);
|
||||
_name = control()->destructorNameId(id);
|
||||
ast->name = _name;
|
||||
return false;
|
||||
@@ -359,7 +359,7 @@ bool CheckName::visit(DestructorNameAST *ast)
|
||||
|
||||
bool CheckName::visit(TemplateIdAST *ast)
|
||||
{
|
||||
Identifier *id = identifier(ast->identifier_token);
|
||||
const Identifier *id = identifier(ast->identifier_token);
|
||||
std::vector<FullySpecifiedType> templateArguments;
|
||||
for (TemplateArgumentListAST *it = ast->template_argument_list; it;
|
||||
it = it->next) {
|
||||
@@ -380,7 +380,7 @@ bool CheckName::visit(ObjCSelectorWithoutArgumentsAST *ast)
|
||||
{
|
||||
if (ast->name_token) {
|
||||
std::vector<Name *> names;
|
||||
Identifier *id = control()->findOrInsertIdentifier(spell(ast->name_token));
|
||||
const Identifier *id = control()->findOrInsertIdentifier(spell(ast->name_token));
|
||||
NameId *nameId = control()->nameId(id);
|
||||
names.push_back(nameId);
|
||||
_name = control()->selectorNameId(&names[0], names.size(), false);
|
||||
@@ -395,7 +395,7 @@ bool CheckName::visit(ObjCSelectorWithArgumentsAST *ast)
|
||||
std::vector<Name *> names;
|
||||
for (ObjCSelectorArgumentListAST *it = ast->selector_argument_list; it; it = it->next) {
|
||||
if (it->value->name_token) {
|
||||
Identifier *id = control()->findOrInsertIdentifier(spell(it->value->name_token));
|
||||
const Identifier *id = control()->findOrInsertIdentifier(spell(it->value->name_token));
|
||||
NameId *nameId = control()->nameId(id);
|
||||
names.push_back(nameId);
|
||||
} else {
|
||||
@@ -420,7 +420,7 @@ bool CheckName::visit(ObjCMessageArgumentDeclarationAST *ast)
|
||||
type = semantic()->check(ast->type_name, _scope);
|
||||
|
||||
if (ast->param_name_token) {
|
||||
Identifier *id = identifier(ast->param_name_token);
|
||||
const Identifier *id = identifier(ast->param_name_token);
|
||||
_name = control()->nameId(id);
|
||||
ast->name = _name;
|
||||
|
||||
|
@@ -386,7 +386,7 @@ bool CheckSpecifier::visit(EnumSpecifierAST *ast)
|
||||
_fullySpecifiedType.setType(e);
|
||||
for (EnumeratorListAST *it = ast->enumerator_list; it; it = it->next) {
|
||||
EnumeratorAST *enumerator = it->value;
|
||||
Identifier *id = identifier(enumerator->identifier_token);
|
||||
const Identifier *id = identifier(enumerator->identifier_token);
|
||||
if (! id)
|
||||
continue;
|
||||
NameId *enumeratorName = control()->nameId(id);
|
||||
@@ -403,7 +403,7 @@ bool CheckSpecifier::visit(TypeofSpecifierAST *ast)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CheckSpecifier::visit(AttributeSpecifierAST *ast)
|
||||
bool CheckSpecifier::visit(AttributeSpecifierAST * /*ast*/)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@@ -184,17 +184,17 @@ public:
|
||||
delete_array_entries(symbols);
|
||||
}
|
||||
|
||||
NameId *findOrInsertNameId(Identifier *id)
|
||||
NameId *findOrInsertNameId(const Identifier *id)
|
||||
{
|
||||
if (! id)
|
||||
return 0;
|
||||
std::map<Identifier *, NameId *>::iterator it = nameIds.lower_bound(id);
|
||||
std::map<const Identifier *, NameId *>::iterator it = nameIds.lower_bound(id);
|
||||
if (it == nameIds.end() || it->first != id)
|
||||
it = nameIds.insert(it, std::make_pair(id, new NameId(id)));
|
||||
return it->second;
|
||||
}
|
||||
|
||||
TemplateNameId *findOrInsertTemplateNameId(Identifier *id,
|
||||
TemplateNameId *findOrInsertTemplateNameId(const Identifier *id,
|
||||
const std::vector<FullySpecifiedType> &templateArguments)
|
||||
{
|
||||
if (! id)
|
||||
@@ -213,11 +213,11 @@ public:
|
||||
return it->second;
|
||||
}
|
||||
|
||||
DestructorNameId *findOrInsertDestructorNameId(Identifier *id)
|
||||
DestructorNameId *findOrInsertDestructorNameId(const Identifier *id)
|
||||
{
|
||||
if (! id)
|
||||
return 0;
|
||||
std::map<Identifier *, DestructorNameId *>::iterator it = destructorNameIds.lower_bound(id);
|
||||
std::map<const Identifier *, DestructorNameId *>::iterator it = destructorNameIds.lower_bound(id);
|
||||
if (it == destructorNameIds.end() || it->first != id)
|
||||
it = destructorNameIds.insert(it, std::make_pair(id, new DestructorNameId(id)));
|
||||
return it->second;
|
||||
@@ -441,10 +441,10 @@ public:
|
||||
}
|
||||
|
||||
struct TemplateNameIdKey {
|
||||
Identifier *id;
|
||||
const Identifier *id;
|
||||
std::vector<FullySpecifiedType> templateArguments;
|
||||
|
||||
TemplateNameIdKey(Identifier *id, const std::vector<FullySpecifiedType> &templateArguments)
|
||||
TemplateNameIdKey(const Identifier *id, const std::vector<FullySpecifiedType> &templateArguments)
|
||||
: id(id), templateArguments(templateArguments)
|
||||
{ }
|
||||
|
||||
@@ -522,8 +522,8 @@ public:
|
||||
// ### replace std::map with lookup tables. ASAP!
|
||||
|
||||
// names
|
||||
std::map<Identifier *, NameId *> nameIds;
|
||||
std::map<Identifier *, DestructorNameId *> destructorNameIds;
|
||||
std::map<const Identifier *, NameId *> nameIds;
|
||||
std::map<const Identifier *, DestructorNameId *> destructorNameIds;
|
||||
std::map<int, OperatorNameId *> operatorNameIds;
|
||||
std::map<FullySpecifiedType, ConversionNameId *> conversionNameIds;
|
||||
std::map<TemplateNameIdKey, TemplateNameId *> templateNameIds;
|
||||
@@ -544,14 +544,14 @@ public:
|
||||
std::vector<Symbol *> symbols;
|
||||
|
||||
// ObjC context keywords:
|
||||
Identifier *objcGetterId;
|
||||
Identifier *objcSetterId;
|
||||
Identifier *objcReadwriteId;
|
||||
Identifier *objcReadonlyId;
|
||||
Identifier *objcAssignId;
|
||||
Identifier *objcRetainId;
|
||||
Identifier *objcCopyId;
|
||||
Identifier *objcNonatomicId;
|
||||
const Identifier *objcGetterId;
|
||||
const Identifier *objcSetterId;
|
||||
const Identifier *objcReadwriteId;
|
||||
const Identifier *objcReadonlyId;
|
||||
const Identifier *objcAssignId;
|
||||
const Identifier *objcRetainId;
|
||||
const Identifier *objcCopyId;
|
||||
const Identifier *objcNonatomicId;
|
||||
};
|
||||
|
||||
Control::Control()
|
||||
@@ -587,13 +587,13 @@ DiagnosticClient *Control::diagnosticClient() const
|
||||
void Control::setDiagnosticClient(DiagnosticClient *diagnosticClient)
|
||||
{ d->diagnosticClient = diagnosticClient; }
|
||||
|
||||
Identifier *Control::findIdentifier(const char *chars, unsigned size) const
|
||||
const Identifier *Control::findIdentifier(const char *chars, unsigned size) const
|
||||
{ return d->identifiers.findLiteral(chars, size); }
|
||||
|
||||
Identifier *Control::findOrInsertIdentifier(const char *chars, unsigned size)
|
||||
const Identifier *Control::findOrInsertIdentifier(const char *chars, unsigned size)
|
||||
{ return d->identifiers.findOrInsertLiteral(chars, size); }
|
||||
|
||||
Identifier *Control::findOrInsertIdentifier(const char *chars)
|
||||
const Identifier *Control::findOrInsertIdentifier(const char *chars)
|
||||
{
|
||||
unsigned length = std::strlen(chars);
|
||||
return findOrInsertIdentifier(chars, length);
|
||||
@@ -617,36 +617,36 @@ Control::NumericLiteralIterator Control::firstNumericLiteral() const
|
||||
Control::NumericLiteralIterator Control::lastNumericLiteral() const
|
||||
{ return d->numericLiterals.end(); }
|
||||
|
||||
StringLiteral *Control::findOrInsertStringLiteral(const char *chars, unsigned size)
|
||||
const StringLiteral *Control::findOrInsertStringLiteral(const char *chars, unsigned size)
|
||||
{ return d->stringLiterals.findOrInsertLiteral(chars, size); }
|
||||
|
||||
StringLiteral *Control::findOrInsertStringLiteral(const char *chars)
|
||||
const StringLiteral *Control::findOrInsertStringLiteral(const char *chars)
|
||||
{
|
||||
unsigned length = std::strlen(chars);
|
||||
return findOrInsertStringLiteral(chars, length);
|
||||
}
|
||||
|
||||
NumericLiteral *Control::findOrInsertNumericLiteral(const char *chars, unsigned size)
|
||||
const NumericLiteral *Control::findOrInsertNumericLiteral(const char *chars, unsigned size)
|
||||
{ return d->numericLiterals.findOrInsertLiteral(chars, size); }
|
||||
|
||||
NumericLiteral *Control::findOrInsertNumericLiteral(const char *chars)
|
||||
const NumericLiteral *Control::findOrInsertNumericLiteral(const char *chars)
|
||||
{
|
||||
unsigned length = std::strlen(chars);
|
||||
return findOrInsertNumericLiteral(chars, length);
|
||||
}
|
||||
|
||||
NameId *Control::nameId(Identifier *id)
|
||||
NameId *Control::nameId(const Identifier *id)
|
||||
{ return d->findOrInsertNameId(id); }
|
||||
|
||||
TemplateNameId *Control::templateNameId(Identifier *id,
|
||||
FullySpecifiedType *const args,
|
||||
unsigned argv)
|
||||
TemplateNameId *Control::templateNameId(const Identifier *id,
|
||||
FullySpecifiedType *const args,
|
||||
unsigned argv)
|
||||
{
|
||||
std::vector<FullySpecifiedType> templateArguments(args, args + argv);
|
||||
return d->findOrInsertTemplateNameId(id, templateArguments);
|
||||
}
|
||||
|
||||
DestructorNameId *Control::destructorNameId(Identifier *id)
|
||||
DestructorNameId *Control::destructorNameId(const Identifier *id)
|
||||
{ return d->findOrInsertDestructorNameId(id); }
|
||||
|
||||
OperatorNameId *Control::operatorNameId(int kind)
|
||||
@@ -755,26 +755,26 @@ ObjCMethod *Control::newObjCMethod(unsigned sourceLocation, Name *name)
|
||||
ObjCPropertyDeclaration *Control::newObjCPropertyDeclaration(unsigned sourceLocation, Name *name)
|
||||
{ return d->newObjCPropertyDeclaration(sourceLocation, name); }
|
||||
|
||||
Identifier *Control::objcGetterId() const
|
||||
const Identifier *Control::objcGetterId() const
|
||||
{ return d->objcGetterId; }
|
||||
|
||||
Identifier *Control::objcSetterId() const
|
||||
const Identifier *Control::objcSetterId() const
|
||||
{ return d->objcSetterId; }
|
||||
|
||||
Identifier *Control::objcReadwriteId() const
|
||||
const Identifier *Control::objcReadwriteId() const
|
||||
{ return d->objcReadwriteId; }
|
||||
|
||||
Identifier *Control::objcReadonlyId() const
|
||||
const Identifier *Control::objcReadonlyId() const
|
||||
{ return d->objcReadonlyId; }
|
||||
|
||||
Identifier *Control::objcAssignId() const
|
||||
const Identifier *Control::objcAssignId() const
|
||||
{ return d->objcAssignId; }
|
||||
|
||||
Identifier *Control::objcRetainId() const
|
||||
const Identifier *Control::objcRetainId() const
|
||||
{ return d->objcRetainId; }
|
||||
|
||||
Identifier *Control::objcCopyId() const
|
||||
const Identifier *Control::objcCopyId() const
|
||||
{ return d->objcCopyId; }
|
||||
|
||||
Identifier *Control::objcNonatomicId() const
|
||||
const Identifier *Control::objcNonatomicId() const
|
||||
{ return d->objcNonatomicId; }
|
||||
|
@@ -66,15 +66,15 @@ public:
|
||||
void setDiagnosticClient(DiagnosticClient *diagnosticClient);
|
||||
|
||||
/// Returns the canonical name id.
|
||||
NameId *nameId(Identifier *id);
|
||||
NameId *nameId(const Identifier *id);
|
||||
|
||||
/// Returns the canonical template name id.
|
||||
TemplateNameId *templateNameId(Identifier *id,
|
||||
TemplateNameId *templateNameId(const Identifier *id,
|
||||
FullySpecifiedType *const args = 0,
|
||||
unsigned argc = 0);
|
||||
|
||||
/// Returns the canonical destructor name id.
|
||||
DestructorNameId *destructorNameId(Identifier *id);
|
||||
DestructorNameId *destructorNameId(const Identifier *id);
|
||||
|
||||
/// Returns the canonical operator name id.
|
||||
OperatorNameId *operatorNameId(int operatorId);
|
||||
@@ -171,19 +171,18 @@ public:
|
||||
ObjCPropertyDeclaration *newObjCPropertyDeclaration(unsigned sourceLocation, Name *name);
|
||||
|
||||
// Objective-C specific context keywords.
|
||||
Identifier *objcGetterId() const;
|
||||
Identifier *objcSetterId() const;
|
||||
Identifier *objcReadwriteId() const;
|
||||
Identifier *objcReadonlyId() const;
|
||||
Identifier *objcAssignId() const;
|
||||
Identifier *objcRetainId() const;
|
||||
Identifier *objcCopyId() const;
|
||||
Identifier *objcNonatomicId() const;
|
||||
const Identifier *objcGetterId() const;
|
||||
const Identifier *objcSetterId() const;
|
||||
const Identifier *objcReadwriteId() const;
|
||||
const Identifier *objcReadonlyId() const;
|
||||
const Identifier *objcAssignId() const;
|
||||
const Identifier *objcRetainId() const;
|
||||
const Identifier *objcCopyId() const;
|
||||
const Identifier *objcNonatomicId() const;
|
||||
|
||||
Identifier *findIdentifier(const char *chars, unsigned size) const;
|
||||
|
||||
Identifier *findOrInsertIdentifier(const char *chars, unsigned size);
|
||||
Identifier *findOrInsertIdentifier(const char *chars);
|
||||
const Identifier *findIdentifier(const char *chars, unsigned size) const;
|
||||
const Identifier *findOrInsertIdentifier(const char *chars, unsigned size);
|
||||
const Identifier *findOrInsertIdentifier(const char *chars);
|
||||
|
||||
typedef const Identifier *const *IdentifierIterator;
|
||||
typedef const StringLiteral *const *StringLiteralIterator;
|
||||
@@ -198,11 +197,11 @@ public:
|
||||
NumericLiteralIterator firstNumericLiteral() const;
|
||||
NumericLiteralIterator lastNumericLiteral() const;
|
||||
|
||||
StringLiteral *findOrInsertStringLiteral(const char *chars, unsigned size);
|
||||
StringLiteral *findOrInsertStringLiteral(const char *chars);
|
||||
const StringLiteral *findOrInsertStringLiteral(const char *chars, unsigned size);
|
||||
const StringLiteral *findOrInsertStringLiteral(const char *chars);
|
||||
|
||||
NumericLiteral *findOrInsertNumericLiteral(const char *chars, unsigned size);
|
||||
NumericLiteral *findOrInsertNumericLiteral(const char *chars);
|
||||
const NumericLiteral *findOrInsertNumericLiteral(const char *chars, unsigned size);
|
||||
const NumericLiteral *findOrInsertNumericLiteral(const char *chars);
|
||||
|
||||
private:
|
||||
class Data;
|
||||
|
@@ -71,7 +71,7 @@ public:
|
||||
virtual ~DiagnosticClient();
|
||||
|
||||
virtual void report(int level,
|
||||
StringLiteral *fileName,
|
||||
const StringLiteral *fileName,
|
||||
unsigned line, unsigned column,
|
||||
const char *format, va_list ap) = 0;
|
||||
};
|
||||
|
@@ -61,7 +61,7 @@ class LiteralTable
|
||||
void operator =(const LiteralTable &other);
|
||||
|
||||
public:
|
||||
typedef _Literal **iterator;
|
||||
typedef _Literal *const *iterator;
|
||||
|
||||
public:
|
||||
LiteralTable()
|
||||
@@ -74,14 +74,14 @@ public:
|
||||
|
||||
~LiteralTable()
|
||||
{
|
||||
if (_literals) {
|
||||
_Literal **lastLiteral = _literals + _literalCount + 1;
|
||||
for (_Literal **it = _literals; it != lastLiteral; ++it)
|
||||
delete *it;
|
||||
std::free(_literals);
|
||||
}
|
||||
if (_buckets)
|
||||
std::free(_buckets);
|
||||
if (_literals) {
|
||||
_Literal **lastLiteral = _literals + _literalCount + 1;
|
||||
for (_Literal **it = _literals; it != lastLiteral; ++it)
|
||||
delete *it;
|
||||
std::free(_literals);
|
||||
}
|
||||
if (_buckets)
|
||||
std::free(_buckets);
|
||||
}
|
||||
|
||||
bool empty() const
|
||||
@@ -90,7 +90,7 @@ public:
|
||||
unsigned size() const
|
||||
{ return _literalCount + 1; }
|
||||
|
||||
_Literal *at(unsigned index) const
|
||||
const _Literal *at(unsigned index) const
|
||||
{ return _literals[index]; }
|
||||
|
||||
iterator begin() const
|
||||
@@ -99,53 +99,53 @@ public:
|
||||
iterator end() const
|
||||
{ return _literals + _literalCount + 1; }
|
||||
|
||||
_Literal *findLiteral(const char *chars, unsigned size) const
|
||||
const _Literal *findLiteral(const char *chars, unsigned size) const
|
||||
{
|
||||
if (_buckets) {
|
||||
unsigned h = _Literal::hashCode(chars, size);
|
||||
_Literal *literal = _buckets[h % _allocatedBuckets];
|
||||
for (; literal; literal = static_cast<_Literal *>(literal->_next)) {
|
||||
if (literal->size() == size && ! std::strncmp(literal->chars(), chars, size))
|
||||
return literal;
|
||||
}
|
||||
}
|
||||
if (_buckets) {
|
||||
unsigned h = _Literal::hashCode(chars, size);
|
||||
_Literal *literal = _buckets[h % _allocatedBuckets];
|
||||
for (; literal; literal = static_cast<_Literal *>(literal->_next)) {
|
||||
if (literal->size() == size && ! std::strncmp(literal->chars(), chars, size))
|
||||
return literal;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
_Literal *findOrInsertLiteral(const char *chars, unsigned size)
|
||||
const _Literal *findOrInsertLiteral(const char *chars, unsigned size)
|
||||
{
|
||||
if (_buckets) {
|
||||
unsigned h = _Literal::hashCode(chars, size);
|
||||
_Literal *literal = _buckets[h % _allocatedBuckets];
|
||||
for (; literal; literal = static_cast<_Literal *>(literal->_next)) {
|
||||
if (literal->size() == size && ! std::strncmp(literal->chars(), chars, size))
|
||||
return literal;
|
||||
}
|
||||
}
|
||||
if (_buckets) {
|
||||
unsigned h = _Literal::hashCode(chars, size);
|
||||
_Literal *literal = _buckets[h % _allocatedBuckets];
|
||||
for (; literal; literal = static_cast<_Literal *>(literal->_next)) {
|
||||
if (literal->size() == size && ! std::strncmp(literal->chars(), chars, size))
|
||||
return literal;
|
||||
}
|
||||
}
|
||||
|
||||
_Literal *literal = new _Literal(chars, size);
|
||||
_Literal *literal = new _Literal(chars, size);
|
||||
|
||||
if (++_literalCount == _allocatedLiterals) {
|
||||
_allocatedLiterals <<= 1;
|
||||
if (++_literalCount == _allocatedLiterals) {
|
||||
_allocatedLiterals <<= 1;
|
||||
|
||||
if (! _allocatedLiterals)
|
||||
_allocatedLiterals = 256;
|
||||
if (! _allocatedLiterals)
|
||||
_allocatedLiterals = 256;
|
||||
|
||||
_literals = (_Literal **) std::realloc(_literals, sizeof(_Literal *) * _allocatedLiterals);
|
||||
}
|
||||
_literals = (_Literal **) std::realloc(_literals, sizeof(_Literal *) * _allocatedLiterals);
|
||||
}
|
||||
|
||||
_literals[_literalCount] = literal;
|
||||
_literals[_literalCount] = literal;
|
||||
|
||||
if (! _buckets || _literalCount >= _allocatedBuckets * .6)
|
||||
rehash();
|
||||
else {
|
||||
unsigned h = literal->hashCode() % _allocatedBuckets;
|
||||
literal->_next = _buckets[h];
|
||||
_buckets[h] = literal;
|
||||
}
|
||||
if (! _buckets || _literalCount >= _allocatedBuckets * .6)
|
||||
rehash();
|
||||
else {
|
||||
unsigned h = literal->hashCode() % _allocatedBuckets;
|
||||
literal->_next = _buckets[h];
|
||||
_buckets[h] = literal;
|
||||
}
|
||||
|
||||
return literal;
|
||||
return literal;
|
||||
}
|
||||
|
||||
protected:
|
||||
|
@@ -56,14 +56,11 @@ namespace CPlusPlus {
|
||||
|
||||
class CPLUSPLUS_EXPORT Name
|
||||
{
|
||||
Name(const Name &other);
|
||||
void operator =(const Name &other);
|
||||
|
||||
public:
|
||||
Name();
|
||||
virtual ~Name();
|
||||
|
||||
virtual Identifier *identifier() const = 0;
|
||||
virtual const Identifier *identifier() const = 0;
|
||||
|
||||
bool isNameId() const;
|
||||
bool isTemplateNameId() const;
|
||||
|
@@ -73,7 +73,7 @@ QualifiedNameId::~QualifiedNameId()
|
||||
void QualifiedNameId::accept0(NameVisitor *visitor)
|
||||
{ visitor->visit(this); }
|
||||
|
||||
Identifier *QualifiedNameId::identifier() const
|
||||
const Identifier *QualifiedNameId::identifier() const
|
||||
{
|
||||
if (Name *u = unqualifiedNameId())
|
||||
return u->identifier();
|
||||
@@ -122,7 +122,7 @@ bool QualifiedNameId::isEqualTo(const Name *other) const
|
||||
return true;
|
||||
}
|
||||
|
||||
NameId::NameId(Identifier *identifier)
|
||||
NameId::NameId(const Identifier *identifier)
|
||||
: _identifier(identifier)
|
||||
{ }
|
||||
|
||||
@@ -132,7 +132,7 @@ NameId::~NameId()
|
||||
void NameId::accept0(NameVisitor *visitor)
|
||||
{ visitor->visit(this); }
|
||||
|
||||
Identifier *NameId::identifier() const
|
||||
const Identifier *NameId::identifier() const
|
||||
{ return _identifier; }
|
||||
|
||||
bool NameId::isEqualTo(const Name *other) const
|
||||
@@ -140,12 +140,12 @@ bool NameId::isEqualTo(const Name *other) const
|
||||
const NameId *nameId = other->asNameId();
|
||||
if (! nameId)
|
||||
return false;
|
||||
Identifier *l = identifier();
|
||||
Identifier *r = nameId->identifier();
|
||||
const Identifier *l = identifier();
|
||||
const Identifier *r = nameId->identifier();
|
||||
return l->isEqualTo(r);
|
||||
}
|
||||
|
||||
DestructorNameId::DestructorNameId(Identifier *identifier)
|
||||
DestructorNameId::DestructorNameId(const Identifier *identifier)
|
||||
: _identifier(identifier)
|
||||
{ }
|
||||
|
||||
@@ -155,7 +155,7 @@ DestructorNameId::~DestructorNameId()
|
||||
void DestructorNameId::accept0(NameVisitor *visitor)
|
||||
{ visitor->visit(this); }
|
||||
|
||||
Identifier *DestructorNameId::identifier() const
|
||||
const Identifier *DestructorNameId::identifier() const
|
||||
{ return _identifier; }
|
||||
|
||||
bool DestructorNameId::isEqualTo(const Name *other) const
|
||||
@@ -163,12 +163,12 @@ bool DestructorNameId::isEqualTo(const Name *other) const
|
||||
const DestructorNameId *d = other->asDestructorNameId();
|
||||
if (! d)
|
||||
return false;
|
||||
Identifier *l = identifier();
|
||||
Identifier *r = d->identifier();
|
||||
const Identifier *l = identifier();
|
||||
const Identifier *r = d->identifier();
|
||||
return l->isEqualTo(r);
|
||||
}
|
||||
|
||||
TemplateNameId::TemplateNameId(Identifier *identifier,
|
||||
TemplateNameId::TemplateNameId(const Identifier *identifier,
|
||||
const FullySpecifiedType templateArguments[],
|
||||
unsigned templateArgumentCount)
|
||||
: _identifier(identifier),
|
||||
@@ -188,7 +188,7 @@ TemplateNameId::~TemplateNameId()
|
||||
void TemplateNameId::accept0(NameVisitor *visitor)
|
||||
{ visitor->visit(this); }
|
||||
|
||||
Identifier *TemplateNameId::identifier() const
|
||||
const Identifier *TemplateNameId::identifier() const
|
||||
{ return _identifier; }
|
||||
|
||||
unsigned TemplateNameId::templateArgumentCount() const
|
||||
@@ -205,8 +205,8 @@ bool TemplateNameId::isEqualTo(const Name *other) const
|
||||
const TemplateNameId *t = other->asTemplateNameId();
|
||||
if (! t)
|
||||
return false;
|
||||
Identifier *l = identifier();
|
||||
Identifier *r = t->identifier();
|
||||
const Identifier *l = identifier();
|
||||
const Identifier *r = t->identifier();
|
||||
if (! l->isEqualTo(r))
|
||||
return false;
|
||||
if (_templateArgumentCount != t->_templateArgumentCount)
|
||||
@@ -233,7 +233,7 @@ void OperatorNameId::accept0(NameVisitor *visitor)
|
||||
int OperatorNameId::kind() const
|
||||
{ return _kind; }
|
||||
|
||||
Identifier *OperatorNameId::identifier() const
|
||||
const Identifier *OperatorNameId::identifier() const
|
||||
{ return 0; }
|
||||
|
||||
bool OperatorNameId::isEqualTo(const Name *other) const
|
||||
@@ -257,7 +257,7 @@ void ConversionNameId::accept0(NameVisitor *visitor)
|
||||
FullySpecifiedType ConversionNameId::type() const
|
||||
{ return _type; }
|
||||
|
||||
Identifier *ConversionNameId::identifier() const
|
||||
const Identifier *ConversionNameId::identifier() const
|
||||
{ return 0; }
|
||||
|
||||
bool ConversionNameId::isEqualTo(const Name *other) const
|
||||
@@ -287,7 +287,7 @@ SelectorNameId::~SelectorNameId()
|
||||
void SelectorNameId::accept0(NameVisitor *visitor)
|
||||
{ visitor->visit(this); }
|
||||
|
||||
Identifier *SelectorNameId::identifier() const
|
||||
const Identifier *SelectorNameId::identifier() const
|
||||
{
|
||||
if (! _nameCount)
|
||||
return 0;
|
||||
|
@@ -63,7 +63,7 @@ public:
|
||||
bool isGlobal = false);
|
||||
virtual ~QualifiedNameId();
|
||||
|
||||
virtual Identifier *identifier() const;
|
||||
virtual const Identifier *identifier() const;
|
||||
|
||||
unsigned nameCount() const;
|
||||
Name *nameAt(unsigned index) const;
|
||||
@@ -92,10 +92,10 @@ private:
|
||||
class CPLUSPLUS_EXPORT NameId: public Name
|
||||
{
|
||||
public:
|
||||
NameId(Identifier *identifier);
|
||||
NameId(const Identifier *identifier);
|
||||
virtual ~NameId();
|
||||
|
||||
virtual Identifier *identifier() const;
|
||||
virtual const Identifier *identifier() const;
|
||||
|
||||
virtual bool isEqualTo(const Name *other) const;
|
||||
|
||||
@@ -109,16 +109,16 @@ protected:
|
||||
virtual void accept0(NameVisitor *visitor);
|
||||
|
||||
private:
|
||||
Identifier *_identifier;
|
||||
const Identifier *_identifier;
|
||||
};
|
||||
|
||||
class CPLUSPLUS_EXPORT DestructorNameId: public Name
|
||||
{
|
||||
public:
|
||||
DestructorNameId(Identifier *identifier);
|
||||
DestructorNameId(const Identifier *identifier);
|
||||
virtual ~DestructorNameId();
|
||||
|
||||
virtual Identifier *identifier() const;
|
||||
virtual const Identifier *identifier() const;
|
||||
|
||||
virtual bool isEqualTo(const Name *other) const;
|
||||
|
||||
@@ -132,18 +132,18 @@ protected:
|
||||
virtual void accept0(NameVisitor *visitor);
|
||||
|
||||
private:
|
||||
Identifier *_identifier;
|
||||
const Identifier *_identifier;
|
||||
};
|
||||
|
||||
class CPLUSPLUS_EXPORT TemplateNameId: public Name
|
||||
{
|
||||
public:
|
||||
TemplateNameId(Identifier *identifier,
|
||||
TemplateNameId(const Identifier *identifier,
|
||||
const FullySpecifiedType templateArguments[],
|
||||
unsigned templateArgumentCount);
|
||||
virtual ~TemplateNameId();
|
||||
|
||||
virtual Identifier *identifier() const;
|
||||
virtual const Identifier *identifier() const;
|
||||
|
||||
// ### find a better name
|
||||
unsigned templateArgumentCount() const;
|
||||
@@ -162,7 +162,7 @@ protected:
|
||||
virtual void accept0(NameVisitor *visitor);
|
||||
|
||||
private:
|
||||
Identifier *_identifier;
|
||||
const Identifier *_identifier;
|
||||
FullySpecifiedType *_templateArguments;
|
||||
unsigned _templateArgumentCount;
|
||||
};
|
||||
@@ -230,7 +230,7 @@ public:
|
||||
|
||||
int kind() const;
|
||||
|
||||
virtual Identifier *identifier() const;
|
||||
virtual const Identifier *identifier() const;
|
||||
virtual bool isEqualTo(const Name *other) const;
|
||||
|
||||
virtual const OperatorNameId *asOperatorNameId() const
|
||||
@@ -254,7 +254,7 @@ public:
|
||||
|
||||
FullySpecifiedType type() const;
|
||||
|
||||
virtual Identifier *identifier() const;
|
||||
virtual const Identifier *identifier() const;
|
||||
virtual bool isEqualTo(const Name *other) const;
|
||||
|
||||
virtual const ConversionNameId *asConversionNameId() const
|
||||
@@ -278,7 +278,7 @@ public:
|
||||
bool hasArguments);
|
||||
virtual ~SelectorNameId();
|
||||
|
||||
virtual Identifier *identifier() const;
|
||||
virtual const Identifier *identifier() const;
|
||||
|
||||
unsigned nameCount() const;
|
||||
Name *nameAt(unsigned index) const;
|
||||
|
@@ -4981,7 +4981,7 @@ bool Parser::parseObjCPropertyAttribute(ObjCPropertyAttributeAST *&node)
|
||||
|
||||
node = new (_pool) ObjCPropertyAttributeAST;
|
||||
|
||||
Identifier *id = tok().identifier;
|
||||
const Identifier *id = tok().identifier;
|
||||
const int k = classifyObjectiveCTypeQualifiers(id->chars(), id->size());
|
||||
switch (k) {
|
||||
case Token_copy:
|
||||
@@ -5079,7 +5079,7 @@ bool Parser::parseObjCTypeQualifiers(unsigned &type_qualifier)
|
||||
if (LA() != T_IDENTIFIER)
|
||||
return false;
|
||||
|
||||
Identifier *id = tok().identifier;
|
||||
const Identifier *id = tok().identifier;
|
||||
const int k = classifyObjectiveCTypeQualifiers(id->chars(), id->size());
|
||||
if (k == Token_identifier)
|
||||
return false;
|
||||
@@ -5092,7 +5092,7 @@ bool Parser::peekAtObjCContextKeyword(int kind)
|
||||
if (LA() != T_IDENTIFIER)
|
||||
return false;
|
||||
|
||||
Identifier *id = tok().identifier;
|
||||
const Identifier *id = tok().identifier;
|
||||
const int k = classifyObjectiveCTypeQualifiers(id->chars(), id->size());
|
||||
return k == kind;
|
||||
}
|
||||
|
@@ -212,14 +212,14 @@ Symbol *Scope::lookat(Name *name) const
|
||||
else if (OperatorNameId *opId = name->asOperatorNameId())
|
||||
return lookat(opId->kind());
|
||||
|
||||
else if (Identifier *id = name->identifier())
|
||||
else if (const Identifier *id = name->identifier())
|
||||
return lookat(id);
|
||||
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
Symbol *Scope::lookat(Identifier *id) const
|
||||
Symbol *Scope::lookat(const Identifier *id) const
|
||||
{
|
||||
if (! _hash || ! id)
|
||||
return 0;
|
||||
|
@@ -130,7 +130,7 @@ public:
|
||||
iterator lastSymbol() const;
|
||||
|
||||
Symbol *lookat(Name *name) const;
|
||||
Symbol *lookat(Identifier *id) const;
|
||||
Symbol *lookat(const Identifier *id) const;
|
||||
Symbol *lookat(int operatorId) const;
|
||||
|
||||
private:
|
||||
|
@@ -232,7 +232,7 @@ void Symbol::setSourceLocation(unsigned sourceLocation)
|
||||
unsigned Symbol::line() const
|
||||
{
|
||||
unsigned line = 0, column = 0;
|
||||
StringLiteral *fileId = 0;
|
||||
const StringLiteral *fileId = 0;
|
||||
translationUnit()->getPosition(_sourceOffset, &line, &column, &fileId);
|
||||
return line;
|
||||
}
|
||||
@@ -240,26 +240,26 @@ unsigned Symbol::line() const
|
||||
unsigned Symbol::column() const
|
||||
{
|
||||
unsigned line = 0, column = 0;
|
||||
StringLiteral *fileId = 0;
|
||||
const StringLiteral *fileId = 0;
|
||||
translationUnit()->getPosition(_sourceOffset, &line, &column, &fileId);
|
||||
return column;
|
||||
}
|
||||
|
||||
StringLiteral *Symbol::fileId() const
|
||||
const StringLiteral *Symbol::fileId() const
|
||||
{
|
||||
unsigned line = 0, column = 0;
|
||||
StringLiteral *fileId = 0;
|
||||
const StringLiteral *fileId = 0;
|
||||
translationUnit()->getPosition(_sourceOffset, &line, &column, &fileId);
|
||||
return fileId;
|
||||
}
|
||||
|
||||
void Symbol::getPosition(unsigned *line, unsigned *column, StringLiteral **fileId) const
|
||||
void Symbol::getPosition(unsigned *line, unsigned *column, const StringLiteral **fileId) const
|
||||
{ translationUnit()->getPosition(_sourceOffset, line, column, fileId); }
|
||||
|
||||
void Symbol::getStartPosition(unsigned *line, unsigned *column, StringLiteral **fileId) const
|
||||
void Symbol::getStartPosition(unsigned *line, unsigned *column, const StringLiteral **fileId) const
|
||||
{ translationUnit()->getPosition(_startOffset, line, column, fileId); }
|
||||
|
||||
void Symbol::getEndPosition(unsigned *line, unsigned *column, StringLiteral **fileId) const
|
||||
void Symbol::getEndPosition(unsigned *line, unsigned *column, const StringLiteral **fileId) const
|
||||
{ translationUnit()->getPosition(_endOffset, line, column, fileId); }
|
||||
|
||||
const char *Symbol::fileName() const
|
||||
@@ -302,7 +302,7 @@ void Symbol::setName(Name *name)
|
||||
}
|
||||
}
|
||||
|
||||
Identifier *Symbol::identifier() const
|
||||
const Identifier *Symbol::identifier() const
|
||||
{
|
||||
if (_name)
|
||||
return _name->identifier();
|
||||
|
@@ -102,7 +102,7 @@ public:
|
||||
unsigned column() const;
|
||||
|
||||
/// Returns this Symbol's file name.
|
||||
StringLiteral *fileId() const;
|
||||
const StringLiteral *fileId() const;
|
||||
|
||||
/// Returns this Symbol's file name.
|
||||
const char *fileName() const;
|
||||
@@ -116,9 +116,9 @@ public:
|
||||
unsigned endOffset() const;
|
||||
void setEndOffset(unsigned offset);
|
||||
|
||||
void getPosition(unsigned *line, unsigned *column = 0, StringLiteral **fileId = 0) const;
|
||||
void getStartPosition(unsigned *line, unsigned *column = 0, StringLiteral **fileId = 0) const;
|
||||
void getEndPosition(unsigned *line, unsigned *column = 0, StringLiteral **fileId = 0) const;
|
||||
void getPosition(unsigned *line, unsigned *column = 0, const StringLiteral **fileId = 0) const;
|
||||
void getStartPosition(unsigned *line, unsigned *column = 0, const StringLiteral **fileId = 0) const;
|
||||
void getEndPosition(unsigned *line, unsigned *column = 0, const StringLiteral **fileId = 0) const;
|
||||
|
||||
/// Returns this Symbol's name.
|
||||
Name *name() const;
|
||||
@@ -127,7 +127,7 @@ public:
|
||||
void setName(Name *name); // ### dangerous
|
||||
|
||||
/// Returns this Symbol's (optional) identifier
|
||||
Identifier *identifier() const;
|
||||
const Identifier *identifier() const;
|
||||
|
||||
/// Returns this Symbol's storage class specifier.
|
||||
int storage() const;
|
||||
|
@@ -335,10 +335,10 @@ public:
|
||||
|
||||
union {
|
||||
void *ptr;
|
||||
Literal *literal;
|
||||
NumericLiteral *number;
|
||||
StringLiteral *string;
|
||||
Identifier *identifier;
|
||||
const Literal *literal;
|
||||
const NumericLiteral *number;
|
||||
const StringLiteral *string;
|
||||
const Identifier *identifier;
|
||||
unsigned close_brace;
|
||||
unsigned lineno;
|
||||
};
|
||||
|
@@ -60,7 +60,7 @@
|
||||
|
||||
using namespace CPlusPlus;
|
||||
|
||||
TranslationUnit::TranslationUnit(Control *control, StringLiteral *fileId)
|
||||
TranslationUnit::TranslationUnit(Control *control, const StringLiteral *fileId)
|
||||
: _control(control),
|
||||
_fileId(fileId),
|
||||
_firstSourceChar(0),
|
||||
@@ -96,7 +96,7 @@ void TranslationUnit::setObjCEnabled(bool onoff)
|
||||
Control *TranslationUnit::control() const
|
||||
{ return _control; }
|
||||
|
||||
StringLiteral *TranslationUnit::fileId() const
|
||||
const StringLiteral *TranslationUnit::fileId() const
|
||||
{ return _fileId; }
|
||||
|
||||
const char *TranslationUnit::fileName() const
|
||||
@@ -137,16 +137,16 @@ const char *TranslationUnit::spell(unsigned index) const
|
||||
return _tokens->at(index).spell();
|
||||
}
|
||||
|
||||
Identifier *TranslationUnit::identifier(unsigned index) const
|
||||
const Identifier *TranslationUnit::identifier(unsigned index) const
|
||||
{ return _tokens->at(index).identifier; }
|
||||
|
||||
Literal *TranslationUnit::literal(unsigned index) const
|
||||
const Literal *TranslationUnit::literal(unsigned index) const
|
||||
{ return _tokens->at(index).literal; }
|
||||
|
||||
StringLiteral *TranslationUnit::stringLiteral(unsigned index) const
|
||||
const StringLiteral *TranslationUnit::stringLiteral(unsigned index) const
|
||||
{ return _tokens->at(index).string; }
|
||||
|
||||
NumericLiteral *TranslationUnit::numericLiteral(unsigned index) const
|
||||
const NumericLiteral *TranslationUnit::numericLiteral(unsigned index) const
|
||||
{ return _tokens->at(index).number; }
|
||||
|
||||
unsigned TranslationUnit::matchingBrace(unsigned index) const
|
||||
@@ -181,8 +181,8 @@ void TranslationUnit::tokenize()
|
||||
pushLineOffset(0);
|
||||
pushPreprocessorLine(0, 1, fileId());
|
||||
|
||||
Identifier *lineId = control()->findOrInsertIdentifier("line");
|
||||
Identifier *genId = control()->findOrInsertIdentifier("gen");
|
||||
const Identifier *lineId = control()->findOrInsertIdentifier("line");
|
||||
const Identifier *genId = control()->findOrInsertIdentifier("gen");
|
||||
|
||||
bool generated = false;
|
||||
Token tk;
|
||||
@@ -211,8 +211,8 @@ void TranslationUnit::tokenize()
|
||||
unsigned line = (unsigned) strtoul(tk.spell(), 0, 0);
|
||||
lex(&tk);
|
||||
if (! tk.f.newline && tk.is(T_STRING_LITERAL)) {
|
||||
StringLiteral *fileName = control()->findOrInsertStringLiteral(tk.string->chars(),
|
||||
tk.string->size());
|
||||
const StringLiteral *fileName = control()->findOrInsertStringLiteral(tk.string->chars(),
|
||||
tk.string->size());
|
||||
pushPreprocessorLine(offset, line, fileName);
|
||||
lex(&tk);
|
||||
}
|
||||
@@ -303,7 +303,7 @@ void TranslationUnit::pushLineOffset(unsigned offset)
|
||||
|
||||
void TranslationUnit::pushPreprocessorLine(unsigned offset,
|
||||
unsigned line,
|
||||
StringLiteral *fileName)
|
||||
const StringLiteral *fileName)
|
||||
{ _ppLines.push_back(PPLine(offset, line, fileName)); }
|
||||
|
||||
unsigned TranslationUnit::findLineNumber(unsigned offset) const
|
||||
@@ -339,23 +339,23 @@ unsigned TranslationUnit::findColumnNumber(unsigned offset, unsigned lineNumber)
|
||||
void TranslationUnit::getTokenPosition(unsigned index,
|
||||
unsigned *line,
|
||||
unsigned *column,
|
||||
StringLiteral **fileName) const
|
||||
const StringLiteral **fileName) const
|
||||
{ return getPosition(tokenAt(index).offset, line, column, fileName); }
|
||||
|
||||
void TranslationUnit::getTokenStartPosition(unsigned index, unsigned *line,
|
||||
unsigned *column,
|
||||
StringLiteral **fileName) const
|
||||
const StringLiteral **fileName) const
|
||||
{ return getPosition(tokenAt(index).begin(), line, column, fileName); }
|
||||
|
||||
void TranslationUnit::getTokenEndPosition(unsigned index, unsigned *line,
|
||||
unsigned *column,
|
||||
StringLiteral **fileName) const
|
||||
const StringLiteral **fileName) const
|
||||
{ return getPosition(tokenAt(index).end(), line, column, fileName); }
|
||||
|
||||
void TranslationUnit::getPosition(unsigned tokenOffset,
|
||||
unsigned *line,
|
||||
unsigned *column,
|
||||
StringLiteral **fileName) const
|
||||
const StringLiteral **fileName) const
|
||||
{
|
||||
unsigned lineNumber = findLineNumber(tokenOffset);
|
||||
unsigned columnNumber = findColumnNumber(tokenOffset, lineNumber);
|
||||
@@ -389,7 +389,7 @@ void TranslationUnit::warning(unsigned index, const char *format, ...)
|
||||
index = std::min(index, tokenCount() - 1);
|
||||
|
||||
unsigned line = 0, column = 0;
|
||||
StringLiteral *fileName = 0;
|
||||
const StringLiteral *fileName = 0;
|
||||
getTokenPosition(index, &line, &column, &fileName);
|
||||
|
||||
if (DiagnosticClient *client = control()->diagnosticClient()) {
|
||||
@@ -420,7 +420,7 @@ void TranslationUnit::error(unsigned index, const char *format, ...)
|
||||
index = std::min(index, tokenCount() - 1);
|
||||
|
||||
unsigned line = 0, column = 0;
|
||||
StringLiteral *fileName = 0;
|
||||
const StringLiteral *fileName = 0;
|
||||
getTokenPosition(index, &line, &column, &fileName);
|
||||
|
||||
if (DiagnosticClient *client = control()->diagnosticClient()) {
|
||||
@@ -451,7 +451,7 @@ void TranslationUnit::fatal(unsigned index, const char *format, ...)
|
||||
index = std::min(index, tokenCount() - 1);
|
||||
|
||||
unsigned line = 0, column = 0;
|
||||
StringLiteral *fileName = 0;
|
||||
const StringLiteral *fileName = 0;
|
||||
getTokenPosition(index, &line, &column, &fileName);
|
||||
|
||||
if (DiagnosticClient *client = control()->diagnosticClient()) {
|
||||
|
@@ -65,12 +65,12 @@ class CPLUSPLUS_EXPORT TranslationUnit
|
||||
void operator =(const TranslationUnit &other);
|
||||
|
||||
public:
|
||||
TranslationUnit(Control *control, StringLiteral *fileId);
|
||||
TranslationUnit(Control *control, const StringLiteral *fileId);
|
||||
~TranslationUnit();
|
||||
|
||||
Control *control() const;
|
||||
|
||||
StringLiteral *fileId() const;
|
||||
const StringLiteral *fileId() const;
|
||||
const char *fileName() const;
|
||||
unsigned fileNameLength() const;
|
||||
|
||||
@@ -86,10 +86,10 @@ public:
|
||||
const char *spell(unsigned index) const;
|
||||
|
||||
unsigned matchingBrace(unsigned index) const;
|
||||
Identifier *identifier(unsigned index) const;
|
||||
Literal *literal(unsigned index) const;
|
||||
StringLiteral *stringLiteral(unsigned index) const;
|
||||
NumericLiteral *numericLiteral(unsigned index) const;
|
||||
const Identifier *identifier(unsigned index) const;
|
||||
const Literal *literal(unsigned index) const;
|
||||
const StringLiteral *stringLiteral(unsigned index) const;
|
||||
const NumericLiteral *numericLiteral(unsigned index) const;
|
||||
|
||||
MemoryPool *memoryPool() const;
|
||||
AST *ast() const;
|
||||
@@ -129,26 +129,26 @@ public:
|
||||
|
||||
void getTokenStartPosition(unsigned index, unsigned *line,
|
||||
unsigned *column = 0,
|
||||
StringLiteral **fileName = 0) const;
|
||||
const StringLiteral **fileName = 0) const;
|
||||
|
||||
void getTokenEndPosition(unsigned index, unsigned *line,
|
||||
unsigned *column = 0,
|
||||
StringLiteral **fileName = 0) const;
|
||||
const StringLiteral **fileName = 0) const;
|
||||
|
||||
void getPosition(unsigned offset,
|
||||
unsigned *line,
|
||||
unsigned *column = 0,
|
||||
StringLiteral **fileName = 0) const;
|
||||
const StringLiteral **fileName = 0) const;
|
||||
|
||||
void getTokenPosition(unsigned index,
|
||||
unsigned *line,
|
||||
unsigned *column = 0,
|
||||
StringLiteral **fileName = 0) const;
|
||||
const StringLiteral **fileName = 0) const;
|
||||
|
||||
void pushLineOffset(unsigned offset);
|
||||
void pushPreprocessorLine(unsigned offset,
|
||||
unsigned line,
|
||||
StringLiteral *fileName);
|
||||
const StringLiteral *fileName);
|
||||
|
||||
unsigned findPreviousLineOffset(unsigned tokenIndex) const;
|
||||
|
||||
@@ -156,11 +156,11 @@ public:
|
||||
struct PPLine {
|
||||
unsigned offset;
|
||||
unsigned line;
|
||||
StringLiteral *fileName;
|
||||
const StringLiteral *fileName;
|
||||
|
||||
PPLine(unsigned offset = 0,
|
||||
unsigned line = 0,
|
||||
StringLiteral *fileName = 0)
|
||||
const StringLiteral *fileName = 0)
|
||||
: offset(offset), line(line), fileName(fileName)
|
||||
{ }
|
||||
|
||||
@@ -181,7 +181,7 @@ private:
|
||||
void showErrorLine(unsigned index, unsigned column, FILE *out);
|
||||
|
||||
Control *_control;
|
||||
StringLiteral *_fileId;
|
||||
const StringLiteral *_fileId;
|
||||
const char *_firstSourceChar;
|
||||
const char *_lastSourceChar;
|
||||
Array<Token, 8> *_tokens;
|
||||
|
Reference in New Issue
Block a user