pass designators into sema.  This completes parser-level designator
support as far as I know.

llvm-svn: 58217
diff --git a/clang/Driver/PrintParserCallbacks.cpp b/clang/Driver/PrintParserCallbacks.cpp
index b616268..94cc0e2 100644
--- a/clang/Driver/PrintParserCallbacks.cpp
+++ b/clang/Driver/PrintParserCallbacks.cpp
@@ -485,6 +485,7 @@
     }
     virtual ExprResult ActOnInitList(SourceLocation LParenLoc,
                                      ExprTy **InitList, unsigned NumInit,
+                                     InitListDesignations &Designators,
                                      SourceLocation RParenLoc) {
       llvm::cout << __FUNCTION__ << "\n";
       return 0;
diff --git a/clang/include/clang/Parse/Action.h b/clang/include/clang/Parse/Action.h
index 7e71c9a..63f5be7 100644
--- a/clang/include/clang/Parse/Action.h
+++ b/clang/include/clang/Parse/Action.h
@@ -459,6 +459,7 @@
   }
   virtual ExprResult ActOnInitList(SourceLocation LParenLoc,
                                    ExprTy **InitList, unsigned NumInit,
+                                   InitListDesignations &Designators,
                                    SourceLocation RParenLoc) {
     return 0;
   }
diff --git a/clang/include/clang/Parse/Designator.h b/clang/include/clang/Parse/Designator.h
index 5abf70d..6a5cff6 100644
--- a/clang/include/clang/Parse/Designator.h
+++ b/clang/include/clang/Parse/Designator.h
@@ -208,6 +208,19 @@
     return Designations.back();
   }
   
+  /// getDesignationForInitializer - If there is a designator for the specified
+  /// initializer, return it, otherwise return null.
+  const Designation *getDesignationForInitializer(unsigned Idx) const {
+    // The common case is no designators.
+    if (!hasAnyDesignators()) return 0;
+    
+    // FIXME: This should do a binary search, not a linear one.
+    for (unsigned i = 0, e = Designations.size(); i != e; ++i)
+      if (Designations[i].InitIndex == Idx)
+        return &Designations[i];
+    return 0;
+  }
+  
 };
 
 } // end namespace clang
diff --git a/clang/lib/Parse/ParseInit.cpp b/clang/lib/Parse/ParseInit.cpp
index 655d8e7..82a33c2 100644
--- a/clang/lib/Parse/ParseInit.cpp
+++ b/clang/lib/Parse/ParseInit.cpp
@@ -236,14 +236,6 @@
 Parser::ExprResult Parser::ParseBraceInitializer() {
   SourceLocation LBraceLoc = ConsumeBrace();
   
-  // We support empty initializers, but tell the user that they aren't using
-  // C99-clean code.
-  if (Tok.is(tok::r_brace)) {
-    Diag(LBraceLoc, diag::ext_gnu_empty_initializer);
-    // Match the '}'.
-    return Actions.ActOnInitList(LBraceLoc, 0, 0, ConsumeBrace());
-  }
-  
   /// InitExprs - This is the actual list of expressions contained in the
   /// initializer.
   llvm::SmallVector<ExprTy*, 8> InitExprs;
@@ -252,6 +244,15 @@
   /// was specified for it, if any.
   InitListDesignations InitExprDesignations(Actions);
 
+  // We support empty initializers, but tell the user that they aren't using
+  // C99-clean code.
+  if (Tok.is(tok::r_brace)) {
+    Diag(LBraceLoc, diag::ext_gnu_empty_initializer);
+    // Match the '}'.
+    return Actions.ActOnInitList(LBraceLoc, 0, 0, InitExprDesignations,
+                                 ConsumeBrace());
+  }
+  
   bool InitExprsOk = true;
   
   while (1) {
@@ -293,8 +294,8 @@
     if (Tok.is(tok::r_brace)) break;
   }
   if (InitExprsOk && Tok.is(tok::r_brace))
-    return Actions.ActOnInitList(LBraceLoc, &InitExprs[0], InitExprs.size(), 
-                                 ConsumeBrace());
+    return Actions.ActOnInitList(LBraceLoc, &InitExprs[0], InitExprs.size(),
+                                 InitExprDesignations, ConsumeBrace());
   
   // On error, delete any parsed subexpressions.
   for (unsigned i = 0, e = InitExprs.size(); i != e; ++i)
diff --git a/clang/lib/Sema/Sema.h b/clang/lib/Sema/Sema.h
index ef34a10..c68776a 100644
--- a/clang/lib/Sema/Sema.h
+++ b/clang/lib/Sema/Sema.h
@@ -614,6 +614,7 @@
   
   virtual ExprResult ActOnInitList(SourceLocation LParenLoc, 
                                    ExprTy **InitList, unsigned NumInit,
+                                   InitListDesignations &Designators,
                                    SourceLocation RParenLoc);
                                    
   virtual ExprResult ActOnBinOp(SourceLocation TokLoc, tok::TokenKind Kind,
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 13b3959..fee9456 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -1247,11 +1247,13 @@
     if (CheckForConstantInitializer(literalExpr, literalType))
       return true;
   }
-  return new CompoundLiteralExpr(LParenLoc, literalType, literalExpr, isFileScope);
+  return new CompoundLiteralExpr(LParenLoc, literalType, literalExpr,
+                                 isFileScope);
 }
 
 Action::ExprResult Sema::
 ActOnInitList(SourceLocation LBraceLoc, ExprTy **initlist, unsigned NumInit,
+              InitListDesignations &Designators,
               SourceLocation RBraceLoc) {
   Expr **InitList = reinterpret_cast<Expr**>(initlist);