forked from OSchip/llvm-project
Implement FunctionDecl::getDefinition() to be consistent with
VarDecl, TagDecl, EnumDecl, RecordDecl, CXXRecordDecl. Use getDefinition in two locations to make the code more readable. llvm-svn: 275303
This commit is contained in:
parent
eff2aa70fc
commit
18c3d0674e
|
@ -1780,6 +1780,17 @@ public:
|
|||
return isDefined(Definition);
|
||||
}
|
||||
|
||||
/// \brief Get the definition for this declaration.
|
||||
FunctionDecl *getDefinition() {
|
||||
const FunctionDecl *Definition;
|
||||
if (isDefined(Definition))
|
||||
return const_cast<FunctionDecl *>(Definition);
|
||||
return nullptr;
|
||||
}
|
||||
const FunctionDecl *getDefinition() const {
|
||||
return const_cast<FunctionDecl *>(this)->getDefinition();
|
||||
}
|
||||
|
||||
/// getBody - Retrieve the body (definition) of the function. The
|
||||
/// function body might be in any of the (re-)declarations of this
|
||||
/// function. The variant that accepts a FunctionDecl pointer will
|
||||
|
|
|
@ -2327,11 +2327,8 @@ static const Decl *getDefinition(const Decl *D) {
|
|||
return Def;
|
||||
return VD->getActingDefinition();
|
||||
}
|
||||
if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
|
||||
const FunctionDecl* Def;
|
||||
if (FD->isDefined(Def))
|
||||
return Def;
|
||||
}
|
||||
if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D))
|
||||
return FD->getDefinition();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
|
|
@ -4936,8 +4936,8 @@ void Sema::diagnoseTypo(const TypoCorrection &Correction,
|
|||
static NamedDecl *getDefinitionToImport(NamedDecl *D) {
|
||||
if (VarDecl *VD = dyn_cast<VarDecl>(D))
|
||||
return VD->getDefinition();
|
||||
if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D))
|
||||
return FD->isDefined(FD) ? const_cast<FunctionDecl*>(FD) : nullptr;
|
||||
if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D))
|
||||
return FD->getDefinition();
|
||||
if (TagDecl *TD = dyn_cast<TagDecl>(D))
|
||||
return TD->getDefinition();
|
||||
if (ObjCInterfaceDecl *ID = dyn_cast<ObjCInterfaceDecl>(D))
|
||||
|
|
Loading…
Reference in New Issue