1ac7ddfbfSEd Maste //===-- Declaration.cpp -----------------------------------------*- C++ -*-===// 2ac7ddfbfSEd Maste // 3ac7ddfbfSEd Maste // The LLVM Compiler Infrastructure 4ac7ddfbfSEd Maste // 5ac7ddfbfSEd Maste // This file is distributed under the University of Illinois Open Source 6ac7ddfbfSEd Maste // License. See LICENSE.TXT for details. 7ac7ddfbfSEd Maste // 8ac7ddfbfSEd Maste //===----------------------------------------------------------------------===// 9ac7ddfbfSEd Maste 10ac7ddfbfSEd Maste #include "lldb/Symbol/Declaration.h" 11ac7ddfbfSEd Maste #include "lldb/Core/Stream.h" 12ac7ddfbfSEd Maste 13ac7ddfbfSEd Maste using namespace lldb_private; 14ac7ddfbfSEd Maste 15ac7ddfbfSEd Maste void 16ac7ddfbfSEd Maste Declaration::Dump(Stream *s, bool show_fullpaths) const 17ac7ddfbfSEd Maste { 18ac7ddfbfSEd Maste if (m_file) 19ac7ddfbfSEd Maste { 20ac7ddfbfSEd Maste *s << ", decl = "; 21ac7ddfbfSEd Maste if (show_fullpaths) 22ac7ddfbfSEd Maste *s << m_file; 23ac7ddfbfSEd Maste else 24ac7ddfbfSEd Maste *s << m_file.GetFilename(); 25ac7ddfbfSEd Maste if (m_line > 0) 26ac7ddfbfSEd Maste s->Printf(":%u", m_line); 27ac7ddfbfSEd Maste #ifdef LLDB_ENABLE_DECLARATION_COLUMNS 28ac7ddfbfSEd Maste if (m_column > 0) 29ac7ddfbfSEd Maste s->Printf(":%u", m_column); 30ac7ddfbfSEd Maste #endif 31ac7ddfbfSEd Maste } 32ac7ddfbfSEd Maste else 33ac7ddfbfSEd Maste { 34ac7ddfbfSEd Maste if (m_line > 0) 35ac7ddfbfSEd Maste { 36ac7ddfbfSEd Maste s->Printf(", line = %u", m_line); 37ac7ddfbfSEd Maste #ifdef LLDB_ENABLE_DECLARATION_COLUMNS 38ac7ddfbfSEd Maste if (m_column > 0) 39ac7ddfbfSEd Maste s->Printf(":%u", m_column); 40ac7ddfbfSEd Maste #endif 41ac7ddfbfSEd Maste } 42ac7ddfbfSEd Maste #ifdef LLDB_ENABLE_DECLARATION_COLUMNS 43ac7ddfbfSEd Maste else if (m_column > 0) 44ac7ddfbfSEd Maste s->Printf(", column = %u", m_column); 45ac7ddfbfSEd Maste #endif 46ac7ddfbfSEd Maste } 47ac7ddfbfSEd Maste } 48ac7ddfbfSEd Maste 49ac7ddfbfSEd Maste bool 50ac7ddfbfSEd Maste Declaration::DumpStopContext (Stream *s, bool show_fullpaths) const 51ac7ddfbfSEd Maste { 52ac7ddfbfSEd Maste if (m_file) 53ac7ddfbfSEd Maste { 54ac7ddfbfSEd Maste if (show_fullpaths || s->GetVerbose()) 55ac7ddfbfSEd Maste *s << m_file; 56ac7ddfbfSEd Maste else 57ac7ddfbfSEd Maste m_file.GetFilename().Dump(s); 58ac7ddfbfSEd Maste 59ac7ddfbfSEd Maste if (m_line > 0) 60ac7ddfbfSEd Maste s->Printf(":%u", m_line); 61ac7ddfbfSEd Maste #ifdef LLDB_ENABLE_DECLARATION_COLUMNS 62ac7ddfbfSEd Maste if (m_column > 0) 63ac7ddfbfSEd Maste s->Printf(":%u", m_column); 64ac7ddfbfSEd Maste #endif 65ac7ddfbfSEd Maste return true; 66ac7ddfbfSEd Maste } 67ac7ddfbfSEd Maste else if (m_line > 0) 68ac7ddfbfSEd Maste { 69ac7ddfbfSEd Maste s->Printf(" line %u", m_line); 70ac7ddfbfSEd Maste #ifdef LLDB_ENABLE_DECLARATION_COLUMNS 71ac7ddfbfSEd Maste if (m_column > 0) 72ac7ddfbfSEd Maste s->Printf(":%u", m_column); 73ac7ddfbfSEd Maste #endif 74ac7ddfbfSEd Maste return true; 75ac7ddfbfSEd Maste } 76ac7ddfbfSEd Maste return false; 77ac7ddfbfSEd Maste } 78ac7ddfbfSEd Maste 79ac7ddfbfSEd Maste size_t 80ac7ddfbfSEd Maste Declaration::MemorySize() const 81ac7ddfbfSEd Maste { 82ac7ddfbfSEd Maste return sizeof(Declaration); 83ac7ddfbfSEd Maste } 84ac7ddfbfSEd Maste 85ac7ddfbfSEd Maste int 86ac7ddfbfSEd Maste Declaration::Compare(const Declaration& a, const Declaration& b) 87ac7ddfbfSEd Maste { 88ac7ddfbfSEd Maste int result = FileSpec::Compare(a.m_file, b.m_file, true); 89ac7ddfbfSEd Maste if (result) 90ac7ddfbfSEd Maste return result; 91ac7ddfbfSEd Maste if (a.m_line < b.m_line) 92ac7ddfbfSEd Maste return -1; 93ac7ddfbfSEd Maste else if (a.m_line > b.m_line) 94ac7ddfbfSEd Maste return 1; 95ac7ddfbfSEd Maste #ifdef LLDB_ENABLE_DECLARATION_COLUMNS 96ac7ddfbfSEd Maste if (a.m_column < b.m_column) 97ac7ddfbfSEd Maste return -1; 98ac7ddfbfSEd Maste else if (a.m_column > b.m_column) 99ac7ddfbfSEd Maste return 1; 100ac7ddfbfSEd Maste #endif 101ac7ddfbfSEd Maste return 0; 102ac7ddfbfSEd Maste } 103ac7ddfbfSEd Maste 104ac7ddfbfSEd Maste bool 105ac7ddfbfSEd Maste lldb_private::operator == (const Declaration &lhs, const Declaration &rhs) 106ac7ddfbfSEd Maste { 107ac7ddfbfSEd Maste #ifdef LLDB_ENABLE_DECLARATION_COLUMNS 108ac7ddfbfSEd Maste if (lhs.GetColumn () == rhs.GetColumn ()) 109ac7ddfbfSEd Maste if (lhs.GetLine () == rhs.GetLine ()) 110ac7ddfbfSEd Maste return lhs.GetFile() == rhs.GetFile(); 111ac7ddfbfSEd Maste #else 112ac7ddfbfSEd Maste if (lhs.GetLine () == rhs.GetLine ()) 113ac7ddfbfSEd Maste return lhs.GetFile() == rhs.GetFile(); 114ac7ddfbfSEd Maste #endif 115ac7ddfbfSEd Maste return false; 116ac7ddfbfSEd Maste } 117ac7ddfbfSEd Maste 118