diff options
author | Stephan Tolksdorf <st@quanttec.com> | 2014-03-15 10:23:27 +0000 |
---|---|---|
committer | Stephan Tolksdorf <st@quanttec.com> | 2014-03-15 10:23:27 +0000 |
commit | e96f8b3774a873e27056c5e98d26dedfb93530cf (patch) | |
tree | a6b1059d4ee41d1b5fb0a3650add6d7c8b00a525 /clang/lib/Serialization | |
parent | 8cef8867eee4846a75a83152e6fe16ad4c5e7c99 (diff) | |
download | bcm5719-llvm-e96f8b3774a873e27056c5e98d26dedfb93530cf.tar.gz bcm5719-llvm-e96f8b3774a873e27056c5e98d26dedfb93530cf.zip |
Fix PR18806: Canonicalize the replacement type when deserializing a SubstTemplateTypeParmType
What's going on in the test case (without the patch applied) is this:
When the header is parsed, decltype(B()) is canonicalized to decltype(Y()),
because that was the first parsed equivalent decltype expression. Hence, the
TemplateSpecializationType for Id<decltype(B())> ends up with
SubstTemplateTypeParmType(T, decltype(Y())) as the AliasedType member.
When the PCH file is included and the AST reader reads Id<decltype(B())>, it
sees decltype(B()) before decltype(Y()). So, this time decltype(B()) ends up
being the canonical type for both decltypes, which leads to an assert violation
when the reader calls getSubstTemplateTypeParmType with the non-canonical
decltype(Y()) as the replacement type.
Reviewers: rsmith
Reviewed By: rsmith
CC: cfe-commits, aemerson
Differential Revision: http://llvm-reviews.chandlerc.com/D3073
llvm-svn: 204005
Diffstat (limited to 'clang/lib/Serialization')
-rw-r--r-- | clang/lib/Serialization/ASTReader.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp index 7781a7d1b05..a0ee3d37c5c 100644 --- a/clang/lib/Serialization/ASTReader.cpp +++ b/clang/lib/Serialization/ASTReader.cpp @@ -5203,9 +5203,9 @@ QualType ASTReader::readTypeRecord(unsigned Index) { unsigned Idx = 0; QualType Parm = readType(*Loc.F, Record, Idx); QualType Replacement = readType(*Loc.F, Record, Idx); - return - Context.getSubstTemplateTypeParmType(cast<TemplateTypeParmType>(Parm), - Replacement); + return Context.getSubstTemplateTypeParmType( + cast<TemplateTypeParmType>(Parm), + Context.getCanonicalType(Replacement)); } case TYPE_SUBST_TEMPLATE_TYPE_PARM_PACK: { |