https://github.com/llvm/llvm-project/commit/05843dc6ab97a00cbde7aa4f08bf3692eb83109d
introduces a regression: deserialization a function crashes if it has a switch
and a lambda with a switch (see the test case).
In this case the AST contains the exact same SwitchStmt both in the lambda's
CXXMethodDecl and as a child of the LambdaExpr:
-LambdaExpr 0x55fc0fb0b4a0 <col:12, line:22:3> |-CXXRecordDecl 0x55fc0fb0afc8 <line:19:12> col:12 implicit class definition | |-CXXMethodDecl 0x55fc0fb0b108 <col:14, line:22:3> line:19:12 constexpr operator() 'auto () const -> void' inline | | `-CompoundStmt 0x55fc0fb0b2b0 <col:16, line:22:3> | | `-SwitchStmt 0x55fc0fb0b208 <line:20:5, line:21:12> `-CompoundStmt 0x55fc0fb0b2b0 <col:16, line:22:3> `-SwitchStmt 0x55fc0fb0b208 <line:20:5, line:21:12>
During the serialization, each SwitchCase gets an id that is unique in a function.
Durint the deserialization, we fail to properly clear the existing ids, thus we receive the
Assertion `(*CurrSwitchCaseStmts)[ID] == nullptr && "Already have a SwitchCase with this ID"' failed
This patch introduces a solution which removes the enforcment of unique ids per function.
We track the ids and make them unique per PCH.