summaryrefslogtreecommitdiffstats
path: root/clang/lib/Frontend/PCHWriterDecl.cpp
diff options
context:
space:
mode:
authorSebastian Redl <sebastian.redl@getdesigned.at>2010-08-13 00:28:03 +0000
committerSebastian Redl <sebastian.redl@getdesigned.at>2010-08-13 00:28:03 +0000
commite7c1fe6ab7c1d9d26abde49dcf52b8ccc53e914c (patch)
tree6a1fd774a5d288c39333ff6c209e3c3e5df12dcb /clang/lib/Frontend/PCHWriterDecl.cpp
parentf7f020bb2afe2943f2f351c5d5e91f5587aa7661 (diff)
downloadbcm5719-llvm-e7c1fe6ab7c1d9d26abde49dcf52b8ccc53e914c.tar.gz
bcm5719-llvm-e7c1fe6ab7c1d9d26abde49dcf52b8ccc53e914c.zip
Instead of modifying the ObjC AST to not modify existing declarations, teach chained PCH to overwrite declarations from earlier PCH files in dependent ones. Tell Sema to note when it changes AST nodes so that they have to be reserialized. Finally, the ObjCProtocolDecls created in forward decls, like the ObjCInterfaceDecls in @class forward decls, are not lexically part of the decl context; only the definition is.
llvm-svn: 110989
Diffstat (limited to 'clang/lib/Frontend/PCHWriterDecl.cpp')
-rw-r--r--clang/lib/Frontend/PCHWriterDecl.cpp32
1 files changed, 19 insertions, 13 deletions
diff --git a/clang/lib/Frontend/PCHWriterDecl.cpp b/clang/lib/Frontend/PCHWriterDecl.cpp
index 13e5239fe78..9893d254e9e 100644
--- a/clang/lib/Frontend/PCHWriterDecl.cpp
+++ b/clang/lib/Frontend/PCHWriterDecl.cpp
@@ -1126,18 +1126,24 @@ void PCHWriter::WriteDecl(ASTContext &Context, Decl *D) {
}
// Determine the ID for this declaration
- pch::DeclID &ID = DeclIDs[D];
- if (ID == 0)
- ID = NextDeclID++;
-
- unsigned Index = ID - FirstDeclID;
-
- // Record the offset for this declaration
- if (DeclOffsets.size() == Index)
- DeclOffsets.push_back(Stream.GetCurrentBitNo());
- else if (DeclOffsets.size() < Index) {
- DeclOffsets.resize(Index+1);
- DeclOffsets[Index] = Stream.GetCurrentBitNo();
+ pch::DeclID &IDR = DeclIDs[D];
+ if (IDR == 0)
+ IDR = NextDeclID++;
+ pch::DeclID ID = IDR;
+
+ if (ID < FirstDeclID) {
+ // We're replacing a decl in a previous file.
+ ReplacedDecls.push_back(std::make_pair(ID, Stream.GetCurrentBitNo()));
+ } else {
+ unsigned Index = ID - FirstDeclID;
+
+ // Record the offset for this declaration
+ if (DeclOffsets.size() == Index)
+ DeclOffsets.push_back(Stream.GetCurrentBitNo());
+ else if (DeclOffsets.size() < Index) {
+ DeclOffsets.resize(Index+1);
+ DeclOffsets[Index] = Stream.GetCurrentBitNo();
+ }
}
// Build and emit a record for this declaration
@@ -1164,5 +1170,5 @@ void PCHWriter::WriteDecl(ASTContext &Context, Decl *D) {
//
// FIXME: This should be renamed, the predicate is much more complicated.
if (isRequiredDecl(D, Context))
- ExternalDefinitions.push_back(Index + 1);
+ ExternalDefinitions.push_back(ID);
}
OpenPOWER on IntegriCloud