]> CyberLeo.Net >> Repos - FreeBSD/releng/9.0.git/blob - contrib/llvm/tools/clang/include/clang/Sema/MultiInitializer.h
Copy stable/9 to releng/9.0 as part of the FreeBSD 9.0-RELEASE release
[FreeBSD/releng/9.0.git] / contrib / llvm / tools / clang / include / clang / Sema / MultiInitializer.h
1 //===--- MultiInitializer.h - Initializer expression group ------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file defines the MultiInitializer class, which can represent a list
11 // initializer or a parentheses-wrapped group of expressions in a C++ member
12 // initializer.
13 //
14 //===----------------------------------------------------------------------===//
15
16 #ifndef LLVM_CLANG_SEMA_MULTIINITIALIZER_H
17 #define LLVM_CLANG_SEMA_MULTIINITIALIZER_H
18
19 #include "clang/Sema/Ownership.h"
20 #include "clang/Basic/SourceLocation.h"
21 #include "llvm/ADT/PointerUnion.h"
22
23 namespace clang {
24   class ASTContext;
25   class Expr;
26   class InitializationKind;
27   class InitializedEntity;
28   class InitListExpr;
29   class Sema;
30
31 class MultiInitializer {
32   llvm::PointerUnion<Expr*, Expr**> InitListOrExpressions;
33   unsigned NumInitializers;
34   SourceLocation LParenLoc;
35   SourceLocation RParenLoc;
36
37   InitListExpr *getInitList() const;
38   Expr **getExpressions() const { return InitListOrExpressions.get<Expr**>(); }
39
40 public:
41   MultiInitializer(Expr* InitList)
42     : InitListOrExpressions(InitList)
43   {}
44
45   MultiInitializer(SourceLocation LParenLoc, Expr **Exprs, unsigned NumInits,
46                    SourceLocation RParenLoc)
47     : InitListOrExpressions(Exprs), NumInitializers(NumInits),
48     LParenLoc(LParenLoc), RParenLoc(RParenLoc)
49   {}
50
51   bool isInitializerList() const { return InitListOrExpressions.is<Expr*>(); }
52
53   SourceLocation getStartLoc() const;
54   SourceLocation getEndLoc() const;
55
56   typedef Expr **iterator;
57   iterator begin() const;
58   iterator end() const;
59
60   bool isTypeDependent() const;
61
62   bool DiagnoseUnexpandedParameterPack(Sema &SemaRef) const;
63
64   // Return the InitListExpr or create a ParenListExpr.
65   Expr *CreateInitExpr(ASTContext &Ctx, QualType T) const;
66
67   ExprResult PerformInit(Sema &SemaRef, InitializedEntity Entity,
68                          InitializationKind Kind) const;
69 };
70 }
71
72 #endif