Skip to content
Snippets Groups Projects
Commit 15641165 authored by Roberto Raggi's avatar Roberto Raggi
Browse files

Removed deprecated (and unsafe) methods.

parent 618f03e4
No related branches found
No related tags found
No related merge requests found
...@@ -206,7 +206,7 @@ bool CheckDeclaration::visit(SimpleDeclarationAST *ast) ...@@ -206,7 +206,7 @@ bool CheckDeclaration::visit(SimpleDeclarationAST *ast)
Function *fun = 0; Function *fun = 0;
if (declTy && 0 != (fun = declTy->asFunctionType())) { if (declTy && 0 != (fun = declTy->asFunctionType())) {
fun->setSourceLocation(location); fun->setSourceLocation(location, translationUnit());
fun->setScope(_scope); fun->setScope(_scope);
fun->setName(name); fun->setName(name);
fun->setMethodKey(semantic()->currentMethodKey()); fun->setMethodKey(semantic()->currentMethodKey());
...@@ -341,7 +341,7 @@ bool CheckDeclaration::visit(FunctionDefinitionAST *ast) ...@@ -341,7 +341,7 @@ bool CheckDeclaration::visit(FunctionDefinitionAST *ast)
fun->setStartOffset(tokenAt(ast->firstToken()).offset); fun->setStartOffset(tokenAt(ast->firstToken()).offset);
fun->setEndOffset(tokenAt(ast->lastToken()).offset); fun->setEndOffset(tokenAt(ast->lastToken()).offset);
if (ast->declarator) if (ast->declarator)
fun->setSourceLocation(ast->declarator->firstToken()); fun->setSourceLocation(ast->declarator->firstToken(), translationUnit());
fun->setName(name); fun->setName(name);
fun->setTemplateParameters(_templateParameters); fun->setTemplateParameters(_templateParameters);
fun->setVisibility(semantic()->currentVisibility()); fun->setVisibility(semantic()->currentVisibility());
......
...@@ -161,10 +161,7 @@ private: ...@@ -161,10 +161,7 @@ private:
}; };
Symbol::Symbol(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name) Symbol::Symbol(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name)
: _control(0), : _startOffset(0),
_sourceLocation(sourceLocation),
_sourceOffset(0),
_startOffset(0),
_endOffset(0), _endOffset(0),
_name(0), _name(0),
_hashCode(0), _hashCode(0),
...@@ -175,23 +172,13 @@ Symbol::Symbol(TranslationUnit *translationUnit, unsigned sourceLocation, const ...@@ -175,23 +172,13 @@ Symbol::Symbol(TranslationUnit *translationUnit, unsigned sourceLocation, const
_next(0), _next(0),
_isGenerated(false) _isGenerated(false)
{ {
if (translationUnit) { setSourceLocation(sourceLocation, translationUnit);
_control = translationUnit->control();
setSourceLocation(sourceLocation);
}
setName(name); setName(name);
} }
Symbol::~Symbol() Symbol::~Symbol()
{ } { }
Control *Symbol::control() const
{ return _control; }
TranslationUnit *Symbol::translationUnit() const
{ return _control->translationUnit(); }
void Symbol::visitSymbol(SymbolVisitor *visitor) void Symbol::visitSymbol(SymbolVisitor *visitor)
{ {
if (visitor->preVisit(this)) if (visitor->preVisit(this))
...@@ -210,9 +197,6 @@ void Symbol::visitSymbol(Symbol *symbol, SymbolVisitor *visitor) ...@@ -210,9 +197,6 @@ void Symbol::visitSymbol(Symbol *symbol, SymbolVisitor *visitor)
unsigned Symbol::sourceLocation() const unsigned Symbol::sourceLocation() const
{ return _sourceLocation; } { return _sourceLocation; }
unsigned Symbol::sourceOffset() const
{ return _sourceOffset; }
bool Symbol::isGenerated() const bool Symbol::isGenerated() const
{ return _isGenerated; } { return _isGenerated; }
...@@ -222,62 +206,38 @@ bool Symbol::isDeprecated() const ...@@ -222,62 +206,38 @@ bool Symbol::isDeprecated() const
void Symbol::setDeprecated(bool isDeprecated) void Symbol::setDeprecated(bool isDeprecated)
{ _isDeprecated = isDeprecated; } { _isDeprecated = isDeprecated; }
void Symbol::setSourceLocation(unsigned sourceLocation) void Symbol::setSourceLocation(unsigned sourceLocation, TranslationUnit *translationUnit)
{ {
_sourceLocation = sourceLocation; _sourceLocation = sourceLocation;
unsigned offset = 0;
if (! _sourceLocation) { if (! _sourceLocation) {
_isGenerated = false; _isGenerated = false;
_sourceOffset = 0;
} else {
TranslationUnit *unit = translationUnit();
const Token &tk = unit->tokenAt(sourceLocation);
} else {
const Token &tk = translationUnit->tokenAt(sourceLocation);
_isGenerated = tk.f.generated; _isGenerated = tk.f.generated;
_sourceOffset = tk.offset; offset = tk.offset;
} }
translationUnit->getPosition(offset, &_line, &_column, &_fileId);
} }
unsigned Symbol::line() const unsigned Symbol::line() const
{ {
assert(_sourceOffset != 0); return _line;
unsigned line = 0, column = 0;
const StringLiteral *fileId = 0;
translationUnit()->getPosition(_sourceOffset, &line, &column, &fileId);
return line;
} }
unsigned Symbol::column() const unsigned Symbol::column() const
{ {
assert(_sourceOffset != 0); return _column;
unsigned line = 0, column = 0;
const StringLiteral *fileId = 0;
translationUnit()->getPosition(_sourceOffset, &line, &column, &fileId);
return column;
} }
const StringLiteral *Symbol::fileId() const const StringLiteral *Symbol::fileId() const
{ {
assert(_sourceOffset != 0); return _fileId;
unsigned line = 0, column = 0;
const StringLiteral *fileId = 0;
translationUnit()->getPosition(_sourceOffset, &line, &column, &fileId);
return fileId;
} }
void Symbol::getPosition(unsigned *line, unsigned *column, const StringLiteral **fileId) const
{ translationUnit()->getPosition(_sourceOffset, line, column, fileId); }
void Symbol::getStartPosition(unsigned *line, unsigned *column, const StringLiteral **fileId) const
{ translationUnit()->getPosition(_startOffset, line, column, fileId); }
void Symbol::getEndPosition(unsigned *line, unsigned *column, const StringLiteral **fileId) const
{ translationUnit()->getPosition(_endOffset, line, column, fileId); }
const char *Symbol::fileName() const const char *Symbol::fileName() const
{ return fileId()->chars(); } { return fileId()->chars(); }
...@@ -511,9 +471,7 @@ bool Symbol::isObjCPropertyDeclaration() const ...@@ -511,9 +471,7 @@ bool Symbol::isObjCPropertyDeclaration() const
void Symbol::copy(Symbol *other) void Symbol::copy(Symbol *other)
{ {
_control = other->_control;
_sourceLocation = other->_sourceLocation; _sourceLocation = other->_sourceLocation;
_sourceOffset = other->_sourceOffset;
_startOffset = other->_startOffset; _startOffset = other->_startOffset;
_endOffset = other->_endOffset; _endOffset = other->_endOffset;
_name = other->_name; _name = other->_name;
...@@ -523,6 +481,9 @@ void Symbol::copy(Symbol *other) ...@@ -523,6 +481,9 @@ void Symbol::copy(Symbol *other)
_scope = other->_scope; _scope = other->_scope;
_index = other->_index; _index = other->_index;
_next = other->_next; _next = other->_next;
_fileId = other->_fileId;
_line = other->_line;
_column = other->_column;
_isGenerated = other->_isGenerated; _isGenerated = other->_isGenerated;
_isDeprecated = other->_isDeprecated; _isDeprecated = other->_isDeprecated;
......
...@@ -90,9 +90,6 @@ public: ...@@ -90,9 +90,6 @@ public:
/// Returns this Symbol's source location. /// Returns this Symbol's source location.
unsigned sourceLocation() const; unsigned sourceLocation() const;
/// Returns this Symbol's source offset.
unsigned sourceOffset() const;
/// Returns this Symbol's line number. /// Returns this Symbol's line number.
unsigned line() const; unsigned line() const;
...@@ -114,10 +111,6 @@ public: ...@@ -114,10 +111,6 @@ public:
unsigned endOffset() const; unsigned endOffset() const;
void setEndOffset(unsigned offset); void setEndOffset(unsigned offset);
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. /// Returns this Symbol's name.
const Name *name() const; const Name *name() const;
...@@ -312,7 +305,7 @@ public: ...@@ -312,7 +305,7 @@ public:
Scope *enclosingBlockScope() const; Scope *enclosingBlockScope() const;
void setScope(Scope *scope); // ### make me private void setScope(Scope *scope); // ### make me private
void setSourceLocation(unsigned sourceLocation); // ### make me private void setSourceLocation(unsigned sourceLocation, TranslationUnit *translationUnit); // ### make me private
void visitSymbol(SymbolVisitor *visitor); void visitSymbol(SymbolVisitor *visitor);
static void visitSymbol(Symbol *symbol, SymbolVisitor *visitor); static void visitSymbol(Symbol *symbol, SymbolVisitor *visitor);
...@@ -322,16 +315,8 @@ public: ...@@ -322,16 +315,8 @@ public:
protected: protected:
virtual void visitSymbol0(SymbolVisitor *visitor) = 0; virtual void visitSymbol0(SymbolVisitor *visitor) = 0;
/// Returns this Symbol's Control object.
Control *control() const;
/// Returns this Symbol's TranslationUnit.
TranslationUnit *translationUnit() const;
private: private:
Control *_control;
unsigned _sourceLocation; unsigned _sourceLocation;
unsigned _sourceOffset;
unsigned _startOffset; unsigned _startOffset;
unsigned _endOffset; unsigned _endOffset;
const Name *_name; const Name *_name;
...@@ -341,6 +326,9 @@ private: ...@@ -341,6 +326,9 @@ private:
Scope *_scope; Scope *_scope;
unsigned _index; unsigned _index;
Symbol *_next; Symbol *_next;
const StringLiteral *_fileId;
unsigned _line;
unsigned _column;
bool _isGenerated: 1; bool _isGenerated: 1;
bool _isDeprecated: 1; bool _isDeprecated: 1;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment