convert the rest of the stderr users in codegen to use diagnostics.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@44503 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/CodeGen/CGBuiltin.cpp b/CodeGen/CGBuiltin.cpp
index 52a41d8..a1d5af1 100644
--- a/CodeGen/CGBuiltin.cpp
+++ b/CodeGen/CGBuiltin.cpp
@@ -29,8 +29,7 @@
     if (getContext().BuiltinInfo.isLibFunction(BuiltinID))
       return EmitCallExpr(CGM.getBuiltinLibFunction(BuiltinID), E);
     
-    fprintf(stderr, "Unimplemented builtin!!\n");
-    E->dump(getContext().SourceMgr);
+    WarnUnsupported(E, "builtin function");
 
     // Unknown builtin, for now just dump it out and return undef.
     if (hasAggregateLLVMType(E->getType()))
diff --git a/CodeGen/CGExpr.cpp b/CodeGen/CGExpr.cpp
index a4aa6db..93f3d71 100644
--- a/CodeGen/CGExpr.cpp
+++ b/CodeGen/CGExpr.cpp
@@ -82,8 +82,7 @@
 LValue CodeGenFunction::EmitLValue(const Expr *E) {
   switch (E->getStmtClass()) {
   default: {
-    fprintf(stderr, "Unimplemented lvalue expr!\n");
-    E->dump(getContext().SourceMgr);
+    WarnUnsupported(E, "l-value expression");
     llvm::Type *Ty = llvm::PointerType::get(ConvertType(E->getType()));
     return LValue::MakeAddr(llvm::UndefValue::get(Ty));
   }
diff --git a/CodeGen/CGExprAgg.cpp b/CodeGen/CGExprAgg.cpp
index 7646081..b0e360f 100644
--- a/CodeGen/CGExprAgg.cpp
+++ b/CodeGen/CGExprAgg.cpp
@@ -54,8 +54,7 @@
   //===--------------------------------------------------------------------===//
   
   void VisitStmt(Stmt *S) {
-    fprintf(stderr, "Unimplemented agg expr!\n");
-    S->dump(CGF.getContext().SourceMgr);
+    CGF.WarnUnsupported(S, "aggregate expression");
   }
   void VisitParenExpr(ParenExpr *PE) { Visit(PE->getSubExpr()); }
 
@@ -152,8 +151,7 @@
 }
 
 void AggExprEmitter::VisitBinaryOperator(const BinaryOperator *E) {
-  fprintf(stderr, "Unimplemented aggregate binary expr!\n");
-  E->dump(CGF.getContext().SourceMgr);
+  CGF.WarnUnsupported(E, "aggregate binary expression");
 }
 
 void AggExprEmitter::VisitBinAssign(const BinaryOperator *E) {
@@ -201,9 +199,7 @@
   unsigned NumInitElements = E->getNumInits();
 
   if (!E->getType()->isArrayType()) {
-    fprintf(stderr, "Unimplemented  aggregate expr! ");
-    fprintf(stderr, "Only Array initializers are implemneted\n");
-    E->dump(CGF.getContext().SourceMgr);
+    CGF.WarnUnsupported(E, "aggregate init-list expression");
     return;
   }
 
diff --git a/CodeGen/CGExprComplex.cpp b/CodeGen/CGExprComplex.cpp
index 085e837..3368c28 100644
--- a/CodeGen/CGExprComplex.cpp
+++ b/CodeGen/CGExprComplex.cpp
@@ -232,8 +232,7 @@
 //===----------------------------------------------------------------------===//
 
 ComplexPairTy ComplexExprEmitter::VisitExpr(Expr *E) {
-  fprintf(stderr, "Unimplemented complex expr!\n");
-  E->dump(CGF.getContext().SourceMgr);
+  CGF.WarnUnsupported(E, "complex expression");
   const llvm::Type *EltTy = 
     CGF.ConvertType(E->getType()->getAsComplexType()->getElementType());
   llvm::Value *U = llvm::UndefValue::get(EltTy);
diff --git a/CodeGen/CGExprScalar.cpp b/CodeGen/CGExprScalar.cpp
index 37389dc..ab61aac 100644
--- a/CodeGen/CGExprScalar.cpp
+++ b/CodeGen/CGExprScalar.cpp
@@ -396,8 +396,7 @@
 //===----------------------------------------------------------------------===//
 
 Value *ScalarExprEmitter::VisitExpr(Expr *E) {
-  fprintf(stderr, "Unimplemented scalar expr!\n");
-  E->dump(CGF.getContext().SourceMgr);
+  CGF.WarnUnsupported(E, "scalar expression");
   if (E->getType()->isVoidType())
     return 0;
   return llvm::UndefValue::get(CGF.ConvertType(E->getType()));
diff --git a/CodeGen/CGStmt.cpp b/CodeGen/CGStmt.cpp
index 40cdcd3..63fdf05 100644
--- a/CodeGen/CGStmt.cpp
+++ b/CodeGen/CGStmt.cpp
@@ -38,7 +38,7 @@
       else
         EmitAggExpr(E, 0, false);
     } else {
-      WarnUnsupported(S);
+      WarnUnsupported(S, "statement");
     }
     break;
   case Stmt::NullStmtClass: break;
diff --git a/CodeGen/CodeGenFunction.cpp b/CodeGen/CodeGenFunction.cpp
index db5072b..0da5fcd 100644
--- a/CodeGen/CodeGenFunction.cpp
+++ b/CodeGen/CodeGenFunction.cpp
@@ -147,10 +147,11 @@
 
 /// WarnUnsupported - Print out a warning that codegen doesn't support the
 /// specified stmt yet.
-void CodeGenFunction::WarnUnsupported(const Stmt *S) {
+void CodeGenFunction::WarnUnsupported(const Stmt *S, const char *Type) {
   unsigned DiagID = CGM.getDiags().getCustomDiagID(Diagnostic::Warning, 
-                                                   "cannot codegen this yet");
+                                                  "cannot codegen this %0 yet");
   SourceRange Range = S->getSourceRange();
-  CGM.getDiags().Report(S->getLocStart(), DiagID, 0, 0, &Range, 1);
+  std::string Msg = Type;
+  CGM.getDiags().Report(S->getLocStart(), DiagID, &Msg, 1, &Range, 1);
 }
 
diff --git a/CodeGen/CodeGenFunction.h b/CodeGen/CodeGenFunction.h
index 2fd8063..0c66b50 100644
--- a/CodeGen/CodeGenFunction.h
+++ b/CodeGen/CodeGenFunction.h
@@ -272,7 +272,7 @@
   
   /// WarnUnsupported - Print out a warning that codegen doesn't support the
   /// specified stmt yet.
-  void WarnUnsupported(const Stmt *S);
+  void WarnUnsupported(const Stmt *S, const char *Type);
 
   //===--------------------------------------------------------------------===//
   //                                  Helpers