[PATCH] D24807: [Serialization] ArrayTypeTraitExpr: serialize sub-expression to avoid keeping it undefined

Aleksei Sidorin via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 21 09:35:00 PDT 2016


a.sidorin created this revision.
a.sidorin added reviewers: aaron.ballman, doug.gregor.
a.sidorin added a subscriber: cfe-commits.

I have encountered a segfault when I tried to get sub-expression of serialized ArrayTypeTraitExpr. The fix is simple but I have no idea about nice test. Maybe you have any suggestions?

https://reviews.llvm.org/D24807

Files:
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriterStmt.cpp

Index: lib/Serialization/ASTWriterStmt.cpp
===================================================================
--- lib/Serialization/ASTWriterStmt.cpp
+++ lib/Serialization/ASTWriterStmt.cpp
@@ -1576,6 +1576,7 @@
   Record.push_back(E->getValue());
   Record.AddSourceRange(E->getSourceRange());
   Record.AddTypeSourceInfo(E->getQueriedTypeSourceInfo());
+  Record.AddStmt(E->getDimensionExpression());
   Code = serialization::EXPR_ARRAY_TYPE_TRAIT;
 }
 
Index: lib/Serialization/ASTReaderStmt.cpp
===================================================================
--- lib/Serialization/ASTReaderStmt.cpp
+++ lib/Serialization/ASTReaderStmt.cpp
@@ -1575,6 +1575,7 @@
   E->Loc = Range.getBegin();
   E->RParen = Range.getEnd();
   E->QueriedType = GetTypeSourceInfo(Record, Idx);
+  E->Dimension = Reader.ReadSubExpr();
 }
 
 void ASTStmtReader::VisitExpressionTraitExpr(ExpressionTraitExpr *E) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D24807.72074.patch
Type: text/x-patch
Size: 900 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160921/474904af/attachment.bin>


More information about the cfe-commits mailing list