diff options
author | Douglas Gregor <dgregor@apple.com> | 2013-01-21 16:16:40 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2013-01-21 16:16:40 +0000 |
commit | 9cfdc03fe7abab2f413bb7fdc59e9be15c382a74 (patch) | |
tree | 5a1d9a5b18931fc718395a03c8fe57b3aa5e5878 /lib/Serialization/ASTReaderDecl.cpp | |
parent | 5a04f9fc2b000da98fd903c8156034304bdadb2f (diff) |
When deserializing a declaration, don't look for redeclarations if its
kind indicates that it can never be redeclared. Good for a 1% speedup,
and redeclaration searching drops off the profile.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173054 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Serialization/ASTReaderDecl.cpp')
-rw-r--r-- | lib/Serialization/ASTReaderDecl.cpp | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/lib/Serialization/ASTReaderDecl.cpp b/lib/Serialization/ASTReaderDecl.cpp index 146065866b..4ae67a04e7 100644 --- a/lib/Serialization/ASTReaderDecl.cpp +++ b/lib/Serialization/ASTReaderDecl.cpp @@ -116,29 +116,25 @@ namespace clang { ASTReader &Reader; GlobalDeclID FirstID; mutable bool Owning; + Decl::Kind DeclKind; void operator=(RedeclarableResult &) LLVM_DELETED_FUNCTION; public: - RedeclarableResult(ASTReader &Reader, GlobalDeclID FirstID) - : Reader(Reader), FirstID(FirstID), Owning(true) { } + RedeclarableResult(ASTReader &Reader, GlobalDeclID FirstID, + Decl::Kind DeclKind) + : Reader(Reader), FirstID(FirstID), Owning(true), DeclKind(DeclKind) { } RedeclarableResult(const RedeclarableResult &Other) - : Reader(Other.Reader), FirstID(Other.FirstID), Owning(Other.Owning) + : Reader(Other.Reader), FirstID(Other.FirstID), Owning(Other.Owning) , + DeclKind(Other.DeclKind) { Other.Owning = false; } ~RedeclarableResult() { - // FIXME: We want to suppress this when the declaration is local to - // a function, since there's no reason to search other AST files - // for redeclarations (they can't exist). However, this is hard to - // do locally because the declaration hasn't necessarily loaded its - // declaration context yet. Also, local externs still have the function - // as their (semantic) declaration context, which is wrong and would - // break this optimize. - - if (FirstID && Owning && Reader.PendingDeclChainsKnown.insert(FirstID)) + if (FirstID && Owning && isRedeclarableDeclKind(DeclKind) && + Reader.PendingDeclChainsKnown.insert(FirstID)) Reader.PendingDeclChains.push_back(FirstID); } @@ -151,7 +147,7 @@ namespace clang { Owning = false; } }; - + /// \brief Class used to capture the result of searching for an existing /// declaration of a specific kind and name, along with the ability /// to update the place where this result was found (the declaration @@ -1562,7 +1558,8 @@ ASTDeclReader::VisitRedeclarable(Redeclarable<T> *D) { // The result structure takes care to note that we need to load the // other declaration chains for this ID. - return RedeclarableResult(Reader, FirstDeclID); + return RedeclarableResult(Reader, FirstDeclID, + static_cast<T *>(D)->getKind()); } /// \brief Attempts to merge the given declaration (D) with another declaration |