diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2010-10-28 09:29:32 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2010-10-28 09:29:32 +0000 |
commit | e09a275444576deb2c8d9e2255554242f65d7c00 (patch) | |
tree | 7c68aea119d866765f2da4d5bafa2f8a4b0dd899 | |
parent | 95c225de9fa3d79f70ef5008c0279580a7d9dcad (diff) |
Switch case IDs conflict between chained PCHs; since there is no need to be global, make them local to a decl.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@117540 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/clang/Serialization/ASTReader.h | 2 | ||||
-rw-r--r-- | include/clang/Serialization/ASTWriter.h | 2 | ||||
-rw-r--r-- | lib/Serialization/ASTReader.cpp | 7 | ||||
-rw-r--r-- | lib/Serialization/ASTWriterDecl.cpp | 3 | ||||
-rw-r--r-- | lib/Serialization/ASTWriterStmt.cpp | 4 |
5 files changed, 18 insertions, 0 deletions
diff --git a/include/clang/Serialization/ASTReader.h b/include/clang/Serialization/ASTReader.h index abe84cac28..2217cc7eb8 100644 --- a/include/clang/Serialization/ASTReader.h +++ b/include/clang/Serialization/ASTReader.h @@ -1162,6 +1162,8 @@ public: /// deserialized and has the given ID. void RecordLabelStmt(LabelStmt *S, unsigned ID); + void ClearSwitchCaseIDs(); + /// \brief Set the label of the given statement to the label /// identified by ID. /// diff --git a/include/clang/Serialization/ASTWriter.h b/include/clang/Serialization/ASTWriter.h index 99f3ece3dd..1d905ddfaa 100644 --- a/include/clang/Serialization/ASTWriter.h +++ b/include/clang/Serialization/ASTWriter.h @@ -484,6 +484,8 @@ public: /// \brief Retrieve the ID for the given switch-case statement. unsigned getSwitchCaseID(SwitchCase *S); + void ClearSwitchCaseIDs(); + /// \brief Retrieve the ID for the given label statement, which may /// or may not have been emitted yet. unsigned GetLabelID(LabelStmt *S); diff --git a/lib/Serialization/ASTReader.cpp b/lib/Serialization/ASTReader.cpp index f09873a070..6497b78772 100644 --- a/lib/Serialization/ASTReader.cpp +++ b/lib/Serialization/ASTReader.cpp @@ -3284,6 +3284,9 @@ Decl *ASTReader::GetDecl(DeclID ID) { /// source each time it is called, and is meant to be used via a /// LazyOffsetPtr (which is used by Decls for the body of functions, etc). Stmt *ASTReader::GetExternalDeclStmt(uint64_t Offset) { + // Switch case IDs are per Decl. + ClearSwitchCaseIDs(); + // Offset here is a global offset across the entire chain. for (unsigned I = 0, N = Chain.size(); I != N; ++I) { PerFileData &F = *Chain[N - I - 1]; @@ -4252,6 +4255,10 @@ SwitchCase *ASTReader::getSwitchCaseWithID(unsigned ID) { return SwitchCaseStmts[ID]; } +void ASTReader::ClearSwitchCaseIDs() { + SwitchCaseStmts.clear(); +} + /// \brief Record that the given label statement has been /// deserialized and has the given ID. void ASTReader::RecordLabelStmt(LabelStmt *S, unsigned ID) { diff --git a/lib/Serialization/ASTWriterDecl.cpp b/lib/Serialization/ASTWriterDecl.cpp index 3c6dd9bbc2..37c7765dc8 100644 --- a/lib/Serialization/ASTWriterDecl.cpp +++ b/lib/Serialization/ASTWriterDecl.cpp @@ -1128,6 +1128,9 @@ static bool isRequiredDecl(const Decl *D, ASTContext &Context) { } void ASTWriter::WriteDecl(ASTContext &Context, Decl *D) { + // Switch case IDs are per Decl. + ClearSwitchCaseIDs(); + RecordData Record; ASTDeclWriter W(*this, Context, Record); diff --git a/lib/Serialization/ASTWriterStmt.cpp b/lib/Serialization/ASTWriterStmt.cpp index 33b70e98c0..fc8e9e0e59 100644 --- a/lib/Serialization/ASTWriterStmt.cpp +++ b/lib/Serialization/ASTWriterStmt.cpp @@ -1311,6 +1311,10 @@ unsigned ASTWriter::getSwitchCaseID(SwitchCase *S) { return SwitchCaseIDs[S]; } +void ASTWriter::ClearSwitchCaseIDs() { + SwitchCaseIDs.clear(); +} + /// \brief Retrieve the ID for the given label statement, which may /// or may not have been emitted yet. unsigned ASTWriter::GetLabelID(LabelStmt *S) { |