diff --git a/lldb/include/lldb/Symbol/Declaration.h b/lldb/include/lldb/Core/Declaration.h rename from lldb/include/lldb/Symbol/Declaration.h rename to lldb/include/lldb/Core/Declaration.h --- a/lldb/include/lldb/Symbol/Declaration.h +++ b/lldb/include/lldb/Core/Declaration.h @@ -14,7 +14,7 @@ namespace lldb_private { -/// \class Declaration Declaration.h "lldb/Symbol/Declaration.h" +/// \class Declaration Declaration.h "lldb/Core/Declaration.h" /// A class that describes the declaration location of a /// lldb object. /// @@ -24,14 +24,7 @@ class Declaration { public: /// Default constructor. - Declaration() - : m_file(), m_line(0) -#ifdef LLDB_ENABLE_DECLARATION_COLUMNS - , - m_column(0) -#endif - { - } + Declaration() : m_file(), m_line(0), m_column(LLDB_INVALID_COLUMN_NUMBER) {} /// Construct with file specification, and optional line and column. /// @@ -46,23 +39,13 @@ /// \param[in] column /// The column number that describes where this was declared. /// Set to zero if there is no column number information. - Declaration(const FileSpec &file_spec, uint32_t line = 0, uint32_t column = 0) - : m_file(file_spec), m_line(line) -#ifdef LLDB_ENABLE_DECLARATION_COLUMNS - , - m_column(column) -#endif - { - } + Declaration(const FileSpec &file_spec, uint32_t line = 0, + uint16_t column = LLDB_INVALID_COLUMN_NUMBER) + : m_file(file_spec), m_line(line), m_column(column) {} /// Construct with a pointer to another Declaration object. Declaration(const Declaration *decl_ptr) - : m_file(), m_line(0) -#ifdef LLDB_ENABLE_DECLARATION_COLUMNS - , - m_column(0) -#endif - { + : m_file(), m_line(0), m_column(LLDB_INVALID_COLUMN_NUMBER) { if (decl_ptr) *this = *decl_ptr; } @@ -74,9 +57,7 @@ void Clear() { m_file.Clear(); m_line = 0; -#ifdef LLDB_ENABLE_DECLARATION_COLUMNS m_column = 0; -#endif } /// Compare two declaration objects. @@ -118,18 +99,6 @@ void Dump(Stream *s, bool show_fullpaths) const; bool DumpStopContext(Stream *s, bool show_fullpaths) const; - /// Get accessor for the declaration column number. - /// - /// \return - /// Non-zero indicates a valid column number, zero indicates no - /// column information is available. - uint32_t GetColumn() const { -#ifdef LLDB_ENABLE_DECLARATION_COLUMNS - return m_column; -#else - return 0; -#endif - } /// Get accessor for file specification. /// @@ -150,7 +119,32 @@ /// line information is available. uint32_t GetLine() const { return m_line; } - bool IsValid() const { return m_file && m_line != 0; } + /// Get accessor for the declaration column number. + /// + /// \return + /// Non-zero indicates a valid column number, zero indicates no + /// column information is available. + uint16_t GetColumn() const { return m_column; } + + /// Convert to boolean operator. + /// + /// This allows code to check a Declaration object to see if it + /// contains anything valid using code such as: + /// + /// \code + /// Declaration decl(...); + /// if (decl) + /// { ... + /// \endcode + /// + /// \return + /// A \b true if both the file_spec and the line are valid, + /// \b false otherwise. + explicit operator bool() const { return IsValid(); } + + bool IsValid() const { + return m_file && m_line != 0 && m_line != LLDB_INVALID_LINE_NUMBER; + } /// Get the memory cost of this object. /// @@ -162,17 +156,6 @@ /// \see ConstString::StaticMemorySize () size_t MemorySize() const; - /// Set accessor for the declaration column number. - /// - /// \param[in] column - /// Non-zero indicates a valid column number, zero indicates no - /// column information is available. - void SetColumn(uint32_t column) { -#ifdef LLDB_ENABLE_DECLARATION_COLUMNS - m_column = col; -#endif - } - /// Set accessor for the declaration file specification. /// /// \param[in] file_spec @@ -186,16 +169,23 @@ /// line information is available. void SetLine(uint32_t line) { m_line = line; } + /// Set accessor for the declaration column number. + /// + /// \param[in] column + /// Non-zero indicates a valid column number, zero indicates no + /// column information is available. + void SetColumn(uint16_t column) { m_column = column; } + protected: - /// Member variables. - FileSpec m_file; ///< The file specification that points to the - ///< source file where the declaration occurred. - uint32_t m_line; ///< Non-zero values indicates a valid line number, - ///< zero indicates no line number information is available. -#ifdef LLDB_ENABLE_DECLARATION_COLUMNS - uint32_t m_column; ///< Non-zero values indicates a valid column number, - ///< zero indicates no column information is available. -#endif + /// The file specification that points to the source file where the + /// declaration occurred. + FileSpec m_file; + /// Non-zero values indicates a valid line number, zero indicates no line + /// number information is available. + uint32_t m_line; + /// Non-zero values indicates a valid column number, zero indicates no column + /// information is available. + uint16_t m_column; }; bool operator==(const Declaration &lhs, const Declaration &rhs); diff --git a/lldb/include/lldb/Symbol/Function.h b/lldb/include/lldb/Symbol/Function.h --- a/lldb/include/lldb/Symbol/Function.h +++ b/lldb/include/lldb/Symbol/Function.h @@ -10,10 +10,10 @@ #define LLDB_SYMBOL_FUNCTION_H #include "lldb/Core/AddressRange.h" +#include "lldb/Core/Declaration.h" #include "lldb/Core/Mangled.h" #include "lldb/Expression/DWARFExpression.h" #include "lldb/Symbol/Block.h" -#include "lldb/Symbol/Declaration.h" #include "lldb/Utility/UserID.h" #include "llvm/ADT/ArrayRef.h" diff --git a/lldb/include/lldb/Symbol/Type.h b/lldb/include/lldb/Symbol/Type.h --- a/lldb/include/lldb/Symbol/Type.h +++ b/lldb/include/lldb/Symbol/Type.h @@ -9,9 +9,9 @@ #ifndef LLDB_SYMBOL_TYPE_H #define LLDB_SYMBOL_TYPE_H +#include "lldb/Core/Declaration.h" #include "lldb/Symbol/CompilerDecl.h" #include "lldb/Symbol/CompilerType.h" -#include "lldb/Symbol/Declaration.h" #include "lldb/Utility/ConstString.h" #include "lldb/Utility/UserID.h" #include "lldb/lldb-private.h" diff --git a/lldb/include/lldb/Symbol/Variable.h b/lldb/include/lldb/Symbol/Variable.h --- a/lldb/include/lldb/Symbol/Variable.h +++ b/lldb/include/lldb/Symbol/Variable.h @@ -9,9 +9,9 @@ #ifndef LLDB_SYMBOL_VARIABLE_H #define LLDB_SYMBOL_VARIABLE_H +#include "lldb/Core/Declaration.h" #include "lldb/Core/Mangled.h" #include "lldb/Expression/DWARFExpression.h" -#include "lldb/Symbol/Declaration.h" #include "lldb/Utility/CompletionRequest.h" #include "lldb/Utility/RangeMap.h" #include "lldb/Utility/UserID.h" diff --git a/lldb/source/API/SBDeclaration.cpp b/lldb/source/API/SBDeclaration.cpp --- a/lldb/source/API/SBDeclaration.cpp +++ b/lldb/source/API/SBDeclaration.cpp @@ -10,8 +10,8 @@ #include "SBReproducerPrivate.h" #include "Utils.h" #include "lldb/API/SBStream.h" +#include "lldb/Core/Declaration.h" #include "lldb/Host/PosixApi.h" -#include "lldb/Symbol/Declaration.h" #include "lldb/Utility/Stream.h" #include diff --git a/lldb/source/API/SBValue.cpp b/lldb/source/API/SBValue.cpp --- a/lldb/source/API/SBValue.cpp +++ b/lldb/source/API/SBValue.cpp @@ -17,6 +17,7 @@ #include "lldb/API/SBTypeSynthetic.h" #include "lldb/Breakpoint/Watchpoint.h" +#include "lldb/Core/Declaration.h" #include "lldb/Core/Module.h" #include "lldb/Core/Section.h" #include "lldb/Core/StreamFile.h" @@ -25,7 +26,6 @@ #include "lldb/Core/ValueObjectConstResult.h" #include "lldb/DataFormatters/DataVisualization.h" #include "lldb/Symbol/Block.h" -#include "lldb/Symbol/Declaration.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Symbol/Type.h" #include "lldb/Symbol/Variable.h" diff --git a/lldb/source/Core/Address.cpp b/lldb/source/Core/Address.cpp --- a/lldb/source/Core/Address.cpp +++ b/lldb/source/Core/Address.cpp @@ -7,12 +7,12 @@ //===----------------------------------------------------------------------===// #include "lldb/Core/Address.h" +#include "lldb/Core/Declaration.h" #include "lldb/Core/DumpDataExtractor.h" #include "lldb/Core/Module.h" #include "lldb/Core/ModuleList.h" #include "lldb/Core/Section.h" #include "lldb/Symbol/Block.h" -#include "lldb/Symbol/Declaration.h" #include "lldb/Symbol/LineEntry.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Symbol/Symbol.h" diff --git a/lldb/source/Core/CMakeLists.txt b/lldb/source/Core/CMakeLists.txt --- a/lldb/source/Core/CMakeLists.txt +++ b/lldb/source/Core/CMakeLists.txt @@ -26,6 +26,7 @@ AddressResolverFileLine.cpp Communication.cpp Debugger.cpp + Declaration.cpp Disassembler.cpp DumpDataExtractor.cpp DumpRegisterValue.cpp diff --git a/lldb/source/Symbol/Declaration.cpp b/lldb/source/Core/Declaration.cpp rename from lldb/source/Symbol/Declaration.cpp rename to lldb/source/Core/Declaration.cpp --- a/lldb/source/Symbol/Declaration.cpp +++ b/lldb/source/Core/Declaration.cpp @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// -#include "lldb/Symbol/Declaration.h" +#include "lldb/Core/Declaration.h" #include "lldb/Utility/Stream.h" using namespace lldb_private; @@ -20,22 +20,15 @@ *s << m_file.GetFilename(); if (m_line > 0) s->Printf(":%u", m_line); -#ifdef LLDB_ENABLE_DECLARATION_COLUMNS - if (m_column > 0) + if (m_column != LLDB_INVALID_COLUMN_NUMBER) s->Printf(":%u", m_column); -#endif } else { if (m_line > 0) { s->Printf(", line = %u", m_line); -#ifdef LLDB_ENABLE_DECLARATION_COLUMNS - if (m_column > 0) + if (m_column != LLDB_INVALID_COLUMN_NUMBER) s->Printf(":%u", m_column); -#endif - } -#ifdef LLDB_ENABLE_DECLARATION_COLUMNS - else if (m_column > 0) + } else if (m_column != LLDB_INVALID_COLUMN_NUMBER) s->Printf(", column = %u", m_column); -#endif } } @@ -48,17 +41,13 @@ if (m_line > 0) s->Printf(":%u", m_line); -#ifdef LLDB_ENABLE_DECLARATION_COLUMNS - if (m_column > 0) + if (m_column != LLDB_INVALID_COLUMN_NUMBER) s->Printf(":%u", m_column); -#endif return true; } else if (m_line > 0) { s->Printf(" line %u", m_line); -#ifdef LLDB_ENABLE_DECLARATION_COLUMNS - if (m_column > 0) + if (m_column != LLDB_INVALID_COLUMN_NUMBER) s->Printf(":%u", m_column); -#endif return true; } return false; @@ -74,12 +63,10 @@ return -1; else if (a.m_line > b.m_line) return 1; -#ifdef LLDB_ENABLE_DECLARATION_COLUMNS if (a.m_column < b.m_column) return -1; else if (a.m_column > b.m_column) return 1; -#endif return 0; } @@ -89,10 +76,8 @@ } bool lldb_private::operator==(const Declaration &lhs, const Declaration &rhs) { -#ifdef LLDB_ENABLE_DECLARATION_COLUMNS if (lhs.GetColumn() != rhs.GetColumn()) return false; -#else + return lhs.GetLine() == rhs.GetLine() && lhs.GetFile() == rhs.GetFile(); -#endif } diff --git a/lldb/source/Core/ValueObject.cpp b/lldb/source/Core/ValueObject.cpp --- a/lldb/source/Core/ValueObject.cpp +++ b/lldb/source/Core/ValueObject.cpp @@ -9,6 +9,7 @@ #include "lldb/Core/ValueObject.h" #include "lldb/Core/Address.h" +#include "lldb/Core/Declaration.h" #include "lldb/Core/Module.h" #include "lldb/Core/ValueObjectCast.h" #include "lldb/Core/ValueObjectChild.h" @@ -27,7 +28,6 @@ #include "lldb/Host/Config.h" #include "lldb/Symbol/CompileUnit.h" #include "lldb/Symbol/CompilerType.h" -#include "lldb/Symbol/Declaration.h" #include "lldb/Symbol/SymbolContext.h" #include "lldb/Symbol/Type.h" #include "lldb/Symbol/Variable.h" diff --git a/lldb/source/Core/ValueObjectVariable.cpp b/lldb/source/Core/ValueObjectVariable.cpp --- a/lldb/source/Core/ValueObjectVariable.cpp +++ b/lldb/source/Core/ValueObjectVariable.cpp @@ -10,10 +10,10 @@ #include "lldb/Core/Address.h" #include "lldb/Core/AddressRange.h" +#include "lldb/Core/Declaration.h" #include "lldb/Core/Module.h" #include "lldb/Core/Value.h" #include "lldb/Expression/DWARFExpression.h" -#include "lldb/Symbol/Declaration.h" #include "lldb/Symbol/Function.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Symbol/SymbolContext.h" diff --git a/lldb/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.h b/lldb/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.h --- a/lldb/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.h @@ -14,7 +14,7 @@ #include "llvm/ADT/DenseMap.h" #include "DWARFDIE.h" -#include "lldb/Symbol/Declaration.h" +#include "lldb/Core/Declaration.h" class UniqueDWARFASTType { public: diff --git a/lldb/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.cpp b/lldb/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.cpp --- a/lldb/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.cpp @@ -8,7 +8,7 @@ #include "UniqueDWARFASTType.h" -#include "lldb/Symbol/Declaration.h" +#include "lldb/Core/Declaration.h" bool UniqueDWARFASTTypeList::Find(const DWARFDIE &die, const lldb_private::Declaration &decl, diff --git a/lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp b/lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp --- a/lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp +++ b/lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp @@ -17,8 +17,8 @@ #include "Plugins/ExpressionParser/Clang/ClangASTMetadata.h" #include "Plugins/ExpressionParser/Clang/ClangUtil.h" #include "Plugins/TypeSystem/Clang/TypeSystemClang.h" +#include "lldb/Core/Declaration.h" #include "lldb/Core/Module.h" -#include "lldb/Symbol/Declaration.h" #include "lldb/Symbol/SymbolFile.h" #include "lldb/Symbol/TypeMap.h" #include "lldb/Symbol/TypeSystem.h" diff --git a/lldb/source/Symbol/CMakeLists.txt b/lldb/source/Symbol/CMakeLists.txt --- a/lldb/source/Symbol/CMakeLists.txt +++ b/lldb/source/Symbol/CMakeLists.txt @@ -14,7 +14,6 @@ CompilerType.cpp DWARFCallFrameInfo.cpp DebugMacros.cpp - Declaration.cpp DeclVendor.cpp FuncUnwinders.cpp Function.cpp diff --git a/lldb/unittests/Symbol/TestClangASTImporter.cpp b/lldb/unittests/Symbol/TestClangASTImporter.cpp --- a/lldb/unittests/Symbol/TestClangASTImporter.cpp +++ b/lldb/unittests/Symbol/TestClangASTImporter.cpp @@ -14,9 +14,9 @@ #include "Plugins/TypeSystem/Clang/TypeSystemClang.h" #include "TestingSupport/SubsystemRAII.h" #include "TestingSupport/Symbol/ClangTestUtils.h" +#include "lldb/Core/Declaration.h" #include "lldb/Host/FileSystem.h" #include "lldb/Host/HostInfo.h" -#include "lldb/Symbol/Declaration.h" #include "clang/AST/DeclCXX.h" using namespace clang; diff --git a/lldb/unittests/Symbol/TestTypeSystemClang.cpp b/lldb/unittests/Symbol/TestTypeSystemClang.cpp --- a/lldb/unittests/Symbol/TestTypeSystemClang.cpp +++ b/lldb/unittests/Symbol/TestTypeSystemClang.cpp @@ -10,9 +10,9 @@ #include "Plugins/TypeSystem/Clang/TypeSystemClang.h" #include "TestingSupport/SubsystemRAII.h" #include "TestingSupport/Symbol/ClangTestUtils.h" +#include "lldb/Core/Declaration.h" #include "lldb/Host/FileSystem.h" #include "lldb/Host/HostInfo.h" -#include "lldb/Symbol/Declaration.h" #include "clang/AST/DeclCXX.h" #include "clang/AST/DeclObjC.h" #include "clang/AST/ExprCXX.h"