diff options
Diffstat (limited to 'clang/lib/Serialization/ASTReaderDecl.cpp')
| -rw-r--r-- | clang/lib/Serialization/ASTReaderDecl.cpp | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/clang/lib/Serialization/ASTReaderDecl.cpp b/clang/lib/Serialization/ASTReaderDecl.cpp index 146065866b0..4ae67a04e78 100644 --- a/clang/lib/Serialization/ASTReaderDecl.cpp +++ b/clang/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 |

