[PATCH] C99 partial re-initialization behavior (DR-253)

Yunzhong Gao Yunzhong_Gao at playstation.sony.com
Mon Mar 9 22:48:33 PDT 2015


Hi Richard,
Here is an updated patch based on your suggestion earlier. We discussed this
briefly during the social, but for the record, I tried several different representations
for the vector of "updater" expressions and settled on using an InitListExpr for now.
Using an InitListExpr avoids having to decode a DesignatedInitExpr in
the CodeGen phase, and also allows merging multiple DesignatedInitExpr into
a common data structure, which then allows better diagnostics. The problem of
having to leave "holes" in an InitListExpr (to account for fields that are initialized by
the "base" expression and not to be overwritten by zeros) is solved by inserting a
new type of NoInitExpr as placeholders into these "holes."

There are two new functions in lib/AST/StmtProfile.cpp which I had to add in
order to build clang, but for which I am having trouble writing coverage tests. I
left a FIXME note there for now.

Feedback and advice are greatly appreciated,

- Gao


http://reviews.llvm.org/D5789

Files:
  include/clang/AST/DataRecursiveASTVisitor.h
  include/clang/AST/Expr.h
  include/clang/AST/RecursiveASTVisitor.h
  include/clang/Basic/StmtNodes.td
  include/clang/Serialization/ASTBitCodes.h
  lib/AST/Expr.cpp
  lib/AST/ExprClassification.cpp
  lib/AST/ExprConstant.cpp
  lib/AST/ItaniumMangle.cpp
  lib/AST/StmtPrinter.cpp
  lib/AST/StmtProfile.cpp
  lib/CodeGen/CGExprAgg.cpp
  lib/CodeGen/CGExprCXX.cpp
  lib/Sema/SemaExceptionSpec.cpp
  lib/Sema/SemaInit.cpp
  lib/Sema/TreeTransform.h
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriter.cpp
  lib/Serialization/ASTWriterStmt.cpp
  lib/StaticAnalyzer/Core/ExprEngine.cpp
  test/Analysis/designated-initializer.c
  test/CodeGen/Inputs/stdio.h
  test/CodeGen/partial-reinitialization1.c
  test/CodeGen/partial-reinitialization2.c
  test/PCH/designated-init.c.h
  test/Sema/designated-initializers.c
  tools/libclang/CXCursor.cpp

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D5789.21546.patch
Type: text/x-patch
Size: 53238 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150310/16d36505/attachment.bin>


More information about the cfe-commits mailing list