[cfe-commits] r39475 - /cfe/cfe/trunk/AST/StmtPrinter.cpp

clattner at cs.uiuc.edu clattner at cs.uiuc.edu
Wed Jul 11 09:44:47 PDT 2007


Author: clattner
Date: Wed Jul 11 11:44:47 2007
New Revision: 39475

URL: http://llvm.org/viewvc/llvm-project?rev=39475&view=rev
Log:
In the yet-another-crazy-idea department, we now print the actual *value* of
integer constants, whoa! :)

Modified:
    cfe/cfe/trunk/AST/StmtPrinter.cpp

Modified: cfe/cfe/trunk/AST/StmtPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/AST/StmtPrinter.cpp?rev=39475&r1=39474&r2=39475&view=diff

==============================================================================
--- cfe/cfe/trunk/AST/StmtPrinter.cpp (original)
+++ cfe/cfe/trunk/AST/StmtPrinter.cpp Wed Jul 11 11:44:47 2007
@@ -252,12 +252,23 @@
 }
 
 void StmtPrinter::VisitIntegerLiteral(IntegerLiteral *Node) {
-  // FIXME: print value.
-  OS << "1";
+  bool isSigned = Node->getType()->isSignedIntegerType();
+  OS << Node->getValue().toString(10, isSigned);
+  
+  // Emit suffixes.  Integer literals are always a builtin integer type.
+  switch (cast<BuiltinType>(Node->getType().getCanonicalType())->getKind()) {
+  default: assert(0 && "Unexpected type for integer literal!");
+  case BuiltinType::Int:       break; // no suffix.
+  case BuiltinType::UInt:      OS << 'U'; break;
+  case BuiltinType::Long:      OS << 'L'; break;
+  case BuiltinType::ULong:     OS << "UL"; break;
+  case BuiltinType::LongLong:  OS << "LL"; break;
+  case BuiltinType::ULongLong: OS << "ULL"; break;
+  }
 }
 void StmtPrinter::VisitFloatingLiteral(FloatingLiteral *Node) {
   // FIXME: print value.
-  OS << "1.0";
+  OS << "~1.0~";
 }
 void StmtPrinter::VisitStringLiteral(StringLiteral *Str) {
   if (Str->isWide()) OS << 'L';





More information about the cfe-commits mailing list