]> granicus.if.org Git - clang/commitdiff
Switch case IDs conflict between chained PCHs; since there is no need to be global...
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Thu, 28 Oct 2010 09:29:32 +0000 (09:29 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Thu, 28 Oct 2010 09:29:32 +0000 (09:29 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@117540 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Serialization/ASTReader.h
include/clang/Serialization/ASTWriter.h
lib/Serialization/ASTReader.cpp
lib/Serialization/ASTWriterDecl.cpp
lib/Serialization/ASTWriterStmt.cpp

index abe84cac280b4a4112817d3e276994c53274114a..2217cc7eb86aa9c7e3f3e04eedbd88b11bd67f35 100644 (file)
@@ -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.
   ///
index 99f3ece3ddd92d34f62d7cd83ec7f735ffab9f16..1d905ddfaa424e31701f8aa7d04596966eba1128 100644 (file)
@@ -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);
index f09873a07072f01dfd466180dcd18b5339ff426c..6497b7877256ccb8f7a912b12d55f439555fa99f 100644 (file)
@@ -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) {
index 3c6dd9bbc2095d51ea2557724fa9d760dd332fa1..37c7765dc893c75a5442f3dc1c1ebe0a76e77c12 100644 (file)
@@ -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);
 
index 33b70e98c06d35f55cdf951ac72e1444706c5cf1..fc8e9e0e595da41e445f43898eb488e6c64858cb 100644 (file)
@@ -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) {