summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/shared/cplusplus/CheckDeclaration.cpp14
-rw-r--r--src/shared/cplusplus/Scope.cpp16
-rw-r--r--src/shared/cplusplus/Scope.h11
-rw-r--r--src/shared/cplusplus/Symbol.cpp18
-rw-r--r--src/shared/cplusplus/Symbol.h8
-rw-r--r--src/shared/cplusplus/Symbols.cpp12
-rw-r--r--src/shared/cplusplus/Symbols.h8
7 files changed, 49 insertions, 38 deletions
diff --git a/src/shared/cplusplus/CheckDeclaration.cpp b/src/shared/cplusplus/CheckDeclaration.cpp
index d3f914a3e8..3cf8040e39 100644
--- a/src/shared/cplusplus/CheckDeclaration.cpp
+++ b/src/shared/cplusplus/CheckDeclaration.cpp
@@ -230,8 +230,6 @@ bool CheckDeclaration::visit(SimpleDeclarationAST *ast)
}
Declaration *symbol = control()->newDeclaration(location, name);
- symbol->setStartOffset(tokenAt(ast->firstToken()).offset);
- symbol->setEndOffset(tokenAt(ast->lastToken() - 1).end());
symbol->setType(declTy);
if (declTy.isDeprecated())
@@ -321,8 +319,6 @@ bool CheckDeclaration::visit(ExceptionDeclarationAST *ast)
}
Declaration *symbol = control()->newDeclaration(location, name);
- symbol->setStartOffset(tokenAt(ast->firstToken()).offset);
- symbol->setEndOffset(tokenAt(ast->lastToken() - 1).end());
symbol->setType(declTy);
_scope->enterSymbol(symbol);
@@ -444,8 +440,6 @@ bool CheckDeclaration::visit(NamespaceAliasDefinitionAST *ast)
NamespaceAlias *namespaceAlias = control()->newNamespaceAlias(sourceLocation, name);
namespaceAlias->setNamespaceName(namespaceName);
- namespaceAlias->setStartOffset(tokenAt(ast->firstToken()).offset);
- namespaceAlias->setEndOffset(tokenAt(ast->lastToken() - 1).end());
//ast->symbol = namespaceAlias;
_scope->enterSymbol(namespaceAlias);
@@ -578,8 +572,6 @@ bool CheckDeclaration::visit(ObjCProtocolForwardDeclarationAST *ast)
const Name *protocolName = semantic()->check(it->value, _scope);
ObjCForwardProtocolDeclaration *fwdProtocol = control()->newObjCForwardProtocolDeclaration(sourceLocation, protocolName);
- fwdProtocol->setStartOffset(tokenAt(ast->firstToken()).offset);
- fwdProtocol->setEndOffset(tokenAt(ast->lastToken() - 1).end());
_scope->enterSymbol(fwdProtocol);
@@ -639,8 +631,6 @@ bool CheckDeclaration::visit(ObjCClassForwardDeclarationAST *ast)
const Name *className = semantic()->check(it->value, _scope);
ObjCForwardClassDeclaration *fwdClass = control()->newObjCForwardClassDeclaration(sourceLocation, className);
- fwdClass->setStartOffset(tokenAt(ast->firstToken()).offset);
- fwdClass->setEndOffset(tokenAt(ast->lastToken() - 1).end());
_scope->enterSymbol(fwdClass);
@@ -726,6 +716,8 @@ bool CheckDeclaration::visit(ObjCMethodDeclarationAST *ast)
Symbol *symbol;
if (ast->function_body) {
symbol = methodTy;
+ methodTy->setStartOffset(tokenAt(ast->firstToken()).offset);
+ methodTy->setEndOffset(tokenAt(ast->lastToken() - 1).end());
} else {
Declaration *decl = control()->newDeclaration(selector->firstToken(), methodTy->name());
decl->setType(methodTy);
@@ -733,8 +725,6 @@ bool CheckDeclaration::visit(ObjCMethodDeclarationAST *ast)
symbol->setStorage(methodTy->storage());
}
- symbol->setStartOffset(tokenAt(ast->firstToken()).offset);
- symbol->setEndOffset(tokenAt(ast->lastToken() - 1).end());
symbol->setVisibility(semantic()->currentObjCVisibility());
if (ty.isDeprecated())
symbol->setDeprecated(true);
diff --git a/src/shared/cplusplus/Scope.cpp b/src/shared/cplusplus/Scope.cpp
index 22eddedd41..de0f147eb3 100644
--- a/src/shared/cplusplus/Scope.cpp
+++ b/src/shared/cplusplus/Scope.cpp
@@ -61,7 +61,9 @@ Scope::Scope(ScopedSymbol *owner)
_allocatedSymbols(0),
_symbolCount(-1),
_hash(0),
- _hashSize(0)
+ _hashSize(0),
+ _startOffset(0),
+ _endOffset(0)
{ }
Scope::~Scope()
@@ -333,4 +335,16 @@ Scope::iterator Scope::firstSymbol() const
Scope::iterator Scope::lastSymbol() const
{ return _symbols + _symbolCount + 1; }
+unsigned Scope::startOffset() const
+{ return _startOffset; }
+
+void Scope::setStartOffset(unsigned offset)
+{ _startOffset = offset; }
+
+unsigned Scope::endOffset() const
+{ return _endOffset; }
+
+void Scope::setEndOffset(unsigned offset)
+{ _endOffset = offset; }
+
diff --git a/src/shared/cplusplus/Scope.h b/src/shared/cplusplus/Scope.h
index 7ad6ecf232..09eded9907 100644
--- a/src/shared/cplusplus/Scope.h
+++ b/src/shared/cplusplus/Scope.h
@@ -142,6 +142,14 @@ public:
Symbol *lookat(const Identifier *id) const;
Symbol *lookat(int operatorId) const;
+ /// Set the start offset of the scope
+ unsigned startOffset() const;
+ void setStartOffset(unsigned offset);
+
+ /// Set the end offset of the scope
+ unsigned endOffset() const;
+ void setEndOffset(unsigned offset);
+
private:
/// Returns the hash value for the given Symbol.
unsigned hashValue(Symbol *symbol) const;
@@ -160,6 +168,9 @@ private:
Symbol **_hash;
int _hashSize;
+
+ unsigned _startOffset;
+ unsigned _endOffset;
};
} // end of namespace CPlusPlus
diff --git a/src/shared/cplusplus/Symbol.cpp b/src/shared/cplusplus/Symbol.cpp
index af168982da..7262522a11 100644
--- a/src/shared/cplusplus/Symbol.cpp
+++ b/src/shared/cplusplus/Symbol.cpp
@@ -111,9 +111,7 @@ private:
};
Symbol::Symbol(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name)
- : _startOffset(0),
- _endOffset(0),
- _name(0),
+ : _name(0),
_hashCode(0),
_storage(Symbol::NoStorage),
_visibility(Symbol::Public),
@@ -201,18 +199,6 @@ const char *Symbol::fileName() const
unsigned Symbol::fileNameLength() const
{ return fileId()->size(); }
-unsigned Symbol::startOffset() const
-{ return _startOffset; }
-
-void Symbol::setStartOffset(unsigned offset)
-{ _startOffset = offset; }
-
-unsigned Symbol::endOffset() const
-{ return _endOffset; }
-
-void Symbol::setEndOffset(unsigned offset)
-{ _endOffset = offset; }
-
const Name *Symbol::identity() const
{
if (! _name)
@@ -433,8 +419,6 @@ bool Symbol::isObjCPropertyDeclaration() const
void Symbol::copy(Symbol *other)
{
_sourceLocation = other->_sourceLocation;
- _startOffset = other->_startOffset;
- _endOffset = other->_endOffset;
_name = other->_name;
_hashCode = other->_hashCode;
_storage = other->_storage;
diff --git a/src/shared/cplusplus/Symbol.h b/src/shared/cplusplus/Symbol.h
index c6ce1a6402..ee32779c94 100644
--- a/src/shared/cplusplus/Symbol.h
+++ b/src/shared/cplusplus/Symbol.h
@@ -105,12 +105,6 @@ public:
/// Returns this Symbol's file name length.
unsigned fileNameLength() const;
- unsigned startOffset() const;
- void setStartOffset(unsigned offset);
-
- unsigned endOffset() const;
- void setEndOffset(unsigned offset);
-
/// Returns this Symbol's name.
const Name *name() const;
@@ -320,8 +314,6 @@ protected:
private:
unsigned _sourceLocation;
- unsigned _startOffset;
- unsigned _endOffset;
const Name *_name;
unsigned _hashCode;
int _storage;
diff --git a/src/shared/cplusplus/Symbols.cpp b/src/shared/cplusplus/Symbols.cpp
index e82a60ae19..5d64149360 100644
--- a/src/shared/cplusplus/Symbols.cpp
+++ b/src/shared/cplusplus/Symbols.cpp
@@ -427,6 +427,18 @@ Scope *ScopedSymbol::members() const
void ScopedSymbol::addMember(Symbol *member)
{ _members->enterSymbol(member); }
+unsigned ScopedSymbol::startOffset() const
+{ return _members->startOffset(); }
+
+void ScopedSymbol::setStartOffset(unsigned offset)
+{ _members->setStartOffset(offset); }
+
+unsigned ScopedSymbol::endOffset() const
+{ return _members->endOffset(); }
+
+void ScopedSymbol::setEndOffset(unsigned offset)
+{ _members->setEndOffset(offset); }
+
Block::Block(TranslationUnit *translationUnit, unsigned sourceLocation)
: ScopedSymbol(translationUnit, sourceLocation, /*name = */ 0)
{ }
diff --git a/src/shared/cplusplus/Symbols.h b/src/shared/cplusplus/Symbols.h
index 2a90fd0cc0..05a1241ec4 100644
--- a/src/shared/cplusplus/Symbols.h
+++ b/src/shared/cplusplus/Symbols.h
@@ -234,6 +234,14 @@ public:
virtual ScopedSymbol *asScopedSymbol()
{ return this; }
+ /// Set the start offset of the scope for this symbol
+ unsigned startOffset() const;
+ void setStartOffset(unsigned offset);
+
+ /// Set the end offset of the scope for this symbol
+ unsigned endOffset() const;
+ void setEndOffset(unsigned offset);
+
private:
Scope *_members;
};