diff options
author | Douglas Gregor <dgregor@apple.com> | 2012-01-14 15:55:47 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2012-01-14 15:55:47 +0000 |
commit | 0bc8a21dba8731f186ee78607a5876c220f620e3 (patch) | |
tree | 36240b4771c1868fbb159a30c7b3bd63e9f959c7 /clang/lib/Serialization | |
parent | 9abeca16e5b0a02647f0dbe175f144ee24f2da6c (diff) | |
download | bcm5719-llvm-0bc8a21dba8731f186ee78607a5876c220f620e3.tar.gz bcm5719-llvm-0bc8a21dba8731f186ee78607a5876c220f620e3.zip |
Introduce Decl::getPreviousDecl() and Decl::getMostRecentDecl(),
virtual functions that provide previous/most recent redeclaration
information for any declaration. Use this to eliminate the redundant,
less efficient getPreviousDecl() functions.
llvm-svn: 148184
Diffstat (limited to 'clang/lib/Serialization')
-rw-r--r-- | clang/lib/Serialization/ASTReaderDecl.cpp | 44 |
1 files changed, 2 insertions, 42 deletions
diff --git a/clang/lib/Serialization/ASTReaderDecl.cpp b/clang/lib/Serialization/ASTReaderDecl.cpp index 21a0fb06a9c..94c3ef0a58d 100644 --- a/clang/lib/Serialization/ASTReaderDecl.cpp +++ b/clang/lib/Serialization/ASTReaderDecl.cpp @@ -2211,46 +2211,6 @@ namespace { }; } -/// \brief Retrieve the previous declaration to D. -static Decl *getPreviousDecl(Decl *D) { - if (TagDecl *TD = dyn_cast<TagDecl>(D)) - return TD->getPreviousDeclaration(); - if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) - return FD->getPreviousDeclaration(); - if (VarDecl *VD = dyn_cast<VarDecl>(D)) - return VD->getPreviousDeclaration(); - if (TypedefNameDecl *TD = dyn_cast<TypedefNameDecl>(D)) - return TD->getPreviousDeclaration(); - if (ObjCInterfaceDecl *ID = dyn_cast<ObjCInterfaceDecl>(D)) - return ID->getPreviousDeclaration(); - if (ObjCProtocolDecl *PD = dyn_cast<ObjCProtocolDecl>(D)) - return PD->getPreviousDeclaration(); - if (NamespaceDecl *ND = dyn_cast<NamespaceDecl>(D)) - return ND->getPreviousDeclaration(); - - return cast<RedeclarableTemplateDecl>(D)->getPreviousDeclaration(); -} - -/// \brief Retrieve the most recent declaration of D. -static Decl *getMostRecentDecl(Decl *D) { - if (TagDecl *TD = dyn_cast<TagDecl>(D)) - return TD->getMostRecentDeclaration(); - if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) - return FD->getMostRecentDeclaration(); - if (VarDecl *VD = dyn_cast<VarDecl>(D)) - return VD->getMostRecentDeclaration(); - if (TypedefNameDecl *TD = dyn_cast<TypedefNameDecl>(D)) - return TD->getMostRecentDeclaration(); - if (ObjCInterfaceDecl *ID = dyn_cast<ObjCInterfaceDecl>(D)) - return ID->getMostRecentDeclaration(); - if (ObjCProtocolDecl *PD = dyn_cast<ObjCProtocolDecl>(D)) - return PD->getMostRecentDeclaration(); - if (NamespaceDecl *ND = dyn_cast<NamespaceDecl>(D)) - return ND->getMostRecentDeclaration(); - - return cast<RedeclarableTemplateDecl>(D)->getMostRecentDeclaration(); -} - void ASTReader::loadPendingDeclChain(serialization::GlobalDeclID ID) { Decl *D = GetDecl(ID); Decl *CanonDecl = D->getCanonicalDecl(); @@ -2276,11 +2236,11 @@ void ASTReader::loadPendingDeclChain(serialization::GlobalDeclID ID) { return; // Capture all of the parsed declarations and put them at the end. - Decl *MostRecent = getMostRecentDecl(CanonDecl); + Decl *MostRecent = CanonDecl->getMostRecentDecl(); Decl *FirstParsed = MostRecent; if (CanonDecl != MostRecent && !MostRecent->isFromASTFile()) { Decl *Current = MostRecent; - while (Decl *Prev = getPreviousDecl(Current)) { + while (Decl *Prev = Current->getPreviousDecl()) { if (Prev == CanonDecl) break; |