CLANG_STMT_RESULT lldb_private::ClangStmtVisitor::VisitFloatingLiteral (clang::FloatingLiteral *Node) { DEBUG_PRINTF("%s\n", __PRETTY_FUNCTION__); const llvm::APFloat &ap_float = Node->getValue(); // Put the length of the float in bytes into a single byte llvm::APInt ap_int(ap_float.bitcastToAPInt()); const unsigned byte_size = ap_int.getBitWidth() / CHAR_BIT; if (byte_size == sizeof(float)) { if (sizeof(float) == 4) { m_stream.PutHex8(DW_OP_APPLE_constf); m_stream.PutHex8 (byte_size); m_stream.PutHex32 (ap_int.getLimitedValue()); return; } else if (sizeof(float) == 8) { m_stream.PutHex8(DW_OP_APPLE_constf); m_stream.PutHex8 (byte_size); m_stream.PutHex64 (ap_int.getLimitedValue()); return; } } else if (byte_size == sizeof(double)) { if (sizeof(double) == 4) { m_stream.PutHex8(DW_OP_APPLE_constf); m_stream.PutHex8 (byte_size); m_stream.PutHex32 (ap_int.getLimitedValue()); return; } else if (sizeof(double) == 8) { m_stream.PutHex8(DW_OP_APPLE_constf); m_stream.PutHex8 (byte_size); m_stream.PutHex64 (ap_int.getLimitedValue()); return; } } else if (byte_size == sizeof(long double)) { if (sizeof(long double) == 8) { m_stream.PutHex8(DW_OP_APPLE_constf); m_stream.PutHex8 (byte_size); m_stream.PutHex64 (ap_int.getLimitedValue()); return; } } // TODO: eventually support float constants of all sizes using // APFloat as the class. m_stream.PutHex8(DW_OP_APPLE_error); }
/* * Decode a "percent" prototype character. * A prototype string may include various "percent" escapes; * that is, a percent sign followed by a single letter. * Here we decode that letter and take the appropriate action, * usually by appending something to the message being built. */ static void protochar(int c, int where) { off_t pos; off_t len; int n; off_t linenum; off_t last_linenum; IFILE h; #undef PAGE_NUM #define PAGE_NUM(linenum) ((((linenum) - 1) / (sc_height - 1)) + 1) switch (c) { case 'b': /* Current byte offset */ pos = curr_byte(where); if (pos != -1) ap_pos(pos); else ap_quest(); break; case 'c': ap_int(hshift); break; case 'd': /* Current page number */ linenum = currline(where); if (linenum > 0 && sc_height > 1) ap_pos(PAGE_NUM(linenum)); else ap_quest(); break; case 'D': /* Final page number */ /* Find the page number of the last byte in the file (len-1). */ len = ch_length(); if (len == -1) { ap_quest(); } else if (len == 0) { /* An empty file has no pages. */ ap_pos(0); } else { linenum = find_linenum(len - 1); if (linenum <= 0) ap_quest(); else ap_pos(PAGE_NUM(linenum)); } break; case 'E': /* Editor name */ ap_str(editor); break; case 'f': /* File name */ ap_str(get_filename(curr_ifile)); break; case 'F': /* Last component of file name */ ap_str(last_component(get_filename(curr_ifile))); break; case 'i': /* Index into list of files */ if (ntags()) ap_int(curr_tag()); else ap_int(get_index(curr_ifile)); break; case 'l': /* Current line number */ linenum = currline(where); if (linenum != 0) ap_pos(linenum); else ap_quest(); break; case 'L': /* Final line number */ len = ch_length(); if (len == -1 || len == ch_zero() || (linenum = find_linenum(len)) <= 0) ap_quest(); else ap_pos(linenum-1); break; case 'm': /* Number of files */ n = ntags(); if (n) ap_int(n); else ap_int(nifile()); break; case 'p': /* Percent into file (bytes) */ pos = curr_byte(where); len = ch_length(); if (pos != -1 && len > 0) ap_int(percentage(pos, len)); else ap_quest(); break; case 'P': /* Percent into file (lines) */ linenum = currline(where); if (linenum == 0 || (len = ch_length()) == -1 || len == ch_zero() || (last_linenum = find_linenum(len)) <= 0) ap_quest(); else ap_int(percentage(linenum, last_linenum)); break; case 's': /* Size of file */ case 'B': len = ch_length(); if (len != -1) ap_pos(len); else ap_quest(); break; case 't': /* Truncate trailing spaces in the message */ while (mp > message && mp[-1] == ' ') mp--; *mp = '\0'; break; case 'T': /* Type of list */ if (ntags()) ap_str("tag"); else ap_str("file"); break; case 'x': /* Name of next file */ h = next_ifile(curr_ifile); if (h != NULL) ap_str(get_filename(h)); else ap_quest(); break; } }