]> granicus.if.org Git - clang/commit
Represent C++ direct initializers as ParenListExprs before semantic analysis
authorSebastian Redl <sebastian.redl@getdesigned.at>
Sat, 11 Feb 2012 23:51:47 +0000 (23:51 +0000)
committerSebastian Redl <sebastian.redl@getdesigned.at>
Sat, 11 Feb 2012 23:51:47 +0000 (23:51 +0000)
commit5b9cc5df25c2198f270dd1d5c438fdce70d4051d
tree8d2c36bd9fe0e47cc5ce4e5a2fd02d8dd0e31f7f
parentecfcd5655758955d8958dc2a7a7b2c8eff2395b7
Represent C++ direct initializers as ParenListExprs before semantic analysis
instead of having a special-purpose function.

- ActOnCXXDirectInitializer, which was mostly duplication of
  AddInitializerToDecl (leading e.g. to PR10620, which Eli fixed a few days
  ago), is dropped completely.
- MultiInitializer, which was an ugly hack I added, is dropped again.
- We now have the infrastructure in place to distinguish between
  int x = {1};
  int x({1});
  int x{1};
-- VarDecl now has getInitStyle(), which indicates which of the above was used.
-- CXXConstructExpr now has a flag to indicate that it represents list-
   initialization, although this is not yet used.
- InstantiateInitializer was renamed to SubstInitializer and simplified.
- ActOnParenOrParenListExpr has been replaced by ActOnParenListExpr, which
  always produces a ParenListExpr. Placed that so far failed to convert that
  back to a ParenExpr containing comma operators have been fixed. I'm pretty
  sure I could have made a crashing test case before this.

The end result is a (I hope) considerably cleaner design of initializers.
More importantly, the fact that I can now distinguish between the various
initialization kinds means that I can get the tricky generalized initializer
test cases Johannes Schaub supplied to work. (This is not yet done.)

This commit passed self-host, with the resulting compiler passing the tests. I
hope it doesn't break more complicated code. It's a pretty big change, but one
that I feel is necessary.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150318 91177308-0d34-0410-b5e6-96231b3b80d8
27 files changed:
include/clang/AST/Decl.h
include/clang/AST/Expr.h
include/clang/AST/ExprCXX.h
include/clang/Sema/Initialization.h
include/clang/Sema/MultiInitializer.h [deleted file]
include/clang/Sema/Sema.h
lib/AST/DeclPrinter.cpp
lib/AST/DumpXML.cpp
lib/AST/Expr.cpp
lib/AST/ExprCXX.cpp
lib/CodeGen/CGObjC.cpp
lib/Parse/ParseDecl.cpp
lib/Parse/ParseExpr.cpp
lib/Sema/CMakeLists.txt
lib/Sema/MultiInitializer.cpp [deleted file]
lib/Sema/SemaDecl.cpp
lib/Sema/SemaDeclCXX.cpp
lib/Sema/SemaExpr.cpp
lib/Sema/SemaInit.cpp
lib/Sema/SemaTemplateInstantiate.cpp
lib/Sema/SemaTemplateInstantiateDecl.cpp
lib/Sema/TreeTransform.h
lib/Serialization/ASTReaderDecl.cpp
lib/Serialization/ASTWriterDecl.cpp
test/CXX/temp/temp.decls/temp.variadic/p5.cpp
test/Sema/paren-list-expr-type.cpp [deleted file]
test/SemaTemplate/nested-incomplete-class.cpp [new file with mode: 0644]