From c3390c044764944b60582142758909be063e29b1 Mon Sep 17 00:00:00 2001 From: Jordan Rose Date: Fri, 20 Dec 2013 01:26:47 +0000 Subject: [PATCH] Serialize source range info for TypeTraitExpr. This caused some crazy crashes involving std::unordered_map being deserialized from a PCH file and then template instantiation requiring an explicit instantiation location; unfortunately I don't really know how to come up with a minimal test case. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@197764 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Serialization/ASTReaderStmt.cpp | 5 ++++- lib/Serialization/ASTWriterStmt.cpp | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/Serialization/ASTReaderStmt.cpp b/lib/Serialization/ASTReaderStmt.cpp index cce3fb17ae..993330c7b2 100644 --- a/lib/Serialization/ASTReaderStmt.cpp +++ b/lib/Serialization/ASTReaderStmt.cpp @@ -1499,7 +1499,10 @@ void ASTStmtReader::VisitTypeTraitExpr(TypeTraitExpr *E) { E->TypeTraitExprBits.NumArgs = Record[Idx++]; E->TypeTraitExprBits.Kind = Record[Idx++]; E->TypeTraitExprBits.Value = Record[Idx++]; - + SourceRange Range = ReadSourceRange(Record, Idx); + E->Loc = Range.getBegin(); + E->RParenLoc = Range.getEnd(); + TypeSourceInfo **Args = E->getTypeSourceInfos(); for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I) Args[I] = GetTypeSourceInfo(Record, Idx); diff --git a/lib/Serialization/ASTWriterStmt.cpp b/lib/Serialization/ASTWriterStmt.cpp index c5c65ef908..a38a620854 100644 --- a/lib/Serialization/ASTWriterStmt.cpp +++ b/lib/Serialization/ASTWriterStmt.cpp @@ -1500,6 +1500,7 @@ void ASTStmtWriter::VisitTypeTraitExpr(TypeTraitExpr *E) { Record.push_back(E->TypeTraitExprBits.NumArgs); Record.push_back(E->TypeTraitExprBits.Kind); // FIXME: Stable encoding Record.push_back(E->TypeTraitExprBits.Value); + Writer.AddSourceRange(E->getSourceRange(), Record); for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I) Writer.AddTypeSourceInfo(E->getArg(I), Record); Code = serialization::EXPR_TYPE_TRAIT; -- 2.40.0