"Codegen for Character Literals and Conditional Operator

Both in one patch, and the test case that Chris didn't commit last
time is in there too...

I'll split the patch up if somebody wants it split."

Patch by Keith Bauer.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39796 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/AST/StmtPrinter.cpp b/AST/StmtPrinter.cpp
index 08dec3c..948b20f 100644
--- a/AST/StmtPrinter.cpp
+++ b/AST/StmtPrinter.cpp
@@ -17,6 +17,7 @@
 #include "clang/Lex/IdentifierTable.h"
 #include "llvm/Support/Compiler.h"
 #include <iostream>
+#include <iomanip>
 using namespace clang;
 
 //===----------------------------------------------------------------------===//
@@ -291,8 +292,14 @@
 }
 
 void StmtPrinter::VisitCharacterLiteral(CharacterLiteral *Node) {
-  // FIXME: print value.
-  OS << "x";
+  unsigned value = Node->getValue();
+  if (isprint(value)) {
+    OS << "'" << (char)value << "'";
+  } else {
+    // FIXME something to indicate this is a character literal?
+    OS << std::hex << std::setiosflags(std::ios_base::showbase) << value
+       << std::dec << std::resetiosflags(std::ios_base::showbase);
+  }
 }
 
 void StmtPrinter::VisitIntegerLiteral(IntegerLiteral *Node) {