Introduce FunctionDecl::getFirstDeclaration() and VarDecl::getFirstDeclaration().
For multiple redeclarations they return the first one. llvm-svn: 75602
This commit is contained in:
parent
d49e8dd759
commit
ef17c07bf6
|
@ -413,6 +413,10 @@ public:
|
||||||
PreviousDeclaration = PrevDecl;
|
PreviousDeclaration = PrevDecl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// \brief For multiple redeclarations returns the first one, otherwise
|
||||||
|
/// returns itself.
|
||||||
|
const VarDecl *getFirstDeclaration() const;
|
||||||
|
|
||||||
virtual Decl *getPrimaryDecl() const;
|
virtual Decl *getPrimaryDecl() const;
|
||||||
|
|
||||||
/// hasLocalStorage - Returns true if a variable with function scope
|
/// hasLocalStorage - Returns true if a variable with function scope
|
||||||
|
@ -811,6 +815,10 @@ public:
|
||||||
return PreviousDeclaration;
|
return PreviousDeclaration;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// \brief For multiple redeclarations returns the first one, otherwise
|
||||||
|
/// returns itself.
|
||||||
|
const FunctionDecl *getFirstDeclaration() const;
|
||||||
|
|
||||||
void setPreviousDeclaration(FunctionDecl * PrevDecl);
|
void setPreviousDeclaration(FunctionDecl * PrevDecl);
|
||||||
|
|
||||||
virtual Decl *getPrimaryDecl() const;
|
virtual Decl *getPrimaryDecl() const;
|
||||||
|
|
|
@ -358,12 +358,16 @@ const Expr *VarDecl::getDefinition(const VarDecl *&Def) const {
|
||||||
return Def? Def->getInit() : 0;
|
return Def? Def->getInit() : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Decl *VarDecl::getPrimaryDecl() const {
|
const VarDecl *VarDecl::getFirstDeclaration() const {
|
||||||
const VarDecl *Prim = this;
|
const VarDecl *First = this;
|
||||||
while (Prim->getPreviousDeclaration())
|
while (First->getPreviousDeclaration())
|
||||||
Prim = Prim->getPreviousDeclaration();
|
First = First->getPreviousDeclaration();
|
||||||
|
|
||||||
return const_cast<VarDecl *>(Prim);
|
return First;
|
||||||
|
}
|
||||||
|
|
||||||
|
Decl *VarDecl::getPrimaryDecl() const {
|
||||||
|
return const_cast<VarDecl *>(getFirstDeclaration());
|
||||||
}
|
}
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
@ -577,12 +581,16 @@ FunctionDecl::setPreviousDeclaration(FunctionDecl *PrevDecl) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Decl *FunctionDecl::getPrimaryDecl() const {
|
const FunctionDecl *FunctionDecl::getFirstDeclaration() const {
|
||||||
const FunctionDecl *Prim = this;
|
const FunctionDecl *First = this;
|
||||||
while (Prim->getPreviousDeclaration())
|
while (First->getPreviousDeclaration())
|
||||||
Prim = Prim->getPreviousDeclaration();
|
First = First->getPreviousDeclaration();
|
||||||
|
|
||||||
return const_cast<FunctionDecl *>(Prim);
|
return First;
|
||||||
|
}
|
||||||
|
|
||||||
|
Decl *FunctionDecl::getPrimaryDecl() const {
|
||||||
|
return const_cast<FunctionDecl *>(getFirstDeclaration());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// getOverloadedOperator - Which C++ overloaded operator this
|
/// getOverloadedOperator - Which C++ overloaded operator this
|
||||||
|
|
Loading…
Reference in New Issue