diff options
Diffstat (limited to 'clang/lib/Serialization/ASTWriterDecl.cpp')
-rw-r--r-- | clang/lib/Serialization/ASTWriterDecl.cpp | 42 |
1 files changed, 14 insertions, 28 deletions
diff --git a/clang/lib/Serialization/ASTWriterDecl.cpp b/clang/lib/Serialization/ASTWriterDecl.cpp index 7523736..77e8952 100644 --- a/clang/lib/Serialization/ASTWriterDecl.cpp +++ b/clang/lib/Serialization/ASTWriterDecl.cpp @@ -2158,7 +2158,7 @@ void ASTWriter::WriteDecl(ASTContext &Context, Decl *D) { ID = IDR; - bool isReplacingADecl = ID < FirstDeclID; + assert(ID >= FirstDeclID && "invalid decl ID"); // If this declaration is also a DeclContext, write blocks for the // declarations that lexically stored inside its context and those @@ -2169,14 +2169,6 @@ void ASTWriter::WriteDecl(ASTContext &Context, Decl *D) { uint64_t VisibleOffset = 0; DeclContext *DC = dyn_cast<DeclContext>(D); if (DC) { - if (isReplacingADecl) { - // It is replacing a decl from a chained PCH; make sure that the - // DeclContext is fully loaded. - if (DC->hasExternalLexicalStorage()) - DC->LoadLexicalDeclsFromExternalStorage(); - if (DC->hasExternalVisibleStorage()) - Chain->completeVisibleDeclsMap(DC); - } LexicalOffset = WriteDeclContextLexicalBlock(Context, DC); VisibleOffset = WriteDeclContextVisibleBlock(Context, DC); } @@ -2188,28 +2180,22 @@ void ASTWriter::WriteDecl(ASTContext &Context, Decl *D) { W.Visit(D); if (DC) W.VisitDeclContext(DC, LexicalOffset, VisibleOffset); - if (isReplacingADecl) { - // We're replacing a decl in a previous file. - ReplacedDecls.push_back(ReplacedDeclInfo(ID, Stream.GetCurrentBitNo(), - D->getLocation())); - } else { - unsigned Index = ID - FirstDeclID; - - // Record the offset for this declaration - SourceLocation Loc = D->getLocation(); - if (DeclOffsets.size() == Index) - DeclOffsets.push_back(DeclOffset(Loc, Stream.GetCurrentBitNo())); - else if (DeclOffsets.size() < Index) { - DeclOffsets.resize(Index+1); - DeclOffsets[Index].setLocation(Loc); - DeclOffsets[Index].BitOffset = Stream.GetCurrentBitNo(); - } + unsigned Index = ID - FirstDeclID; - SourceManager &SM = Context.getSourceManager(); - if (Loc.isValid() && SM.isLocalSourceLocation(Loc)) - associateDeclWithFile(D, ID); + // Record the offset for this declaration + SourceLocation Loc = D->getLocation(); + if (DeclOffsets.size() == Index) + DeclOffsets.push_back(DeclOffset(Loc, Stream.GetCurrentBitNo())); + else if (DeclOffsets.size() < Index) { + DeclOffsets.resize(Index+1); + DeclOffsets[Index].setLocation(Loc); + DeclOffsets[Index].BitOffset = Stream.GetCurrentBitNo(); } + SourceManager &SM = Context.getSourceManager(); + if (Loc.isValid() && SM.isLocalSourceLocation(Loc)) + associateDeclWithFile(D, ID); + if (!W.Code) llvm::report_fatal_error(StringRef("unexpected declaration kind '") + D->getDeclKindName() + "'"); |