Author: eugenezelenko Date: Wed Oct 28 17:11:25 2015 New Revision: 251561 URL: http://llvm.org/viewvc/llvm-project?rev=251561&view=rev Log: Fix Clang-tidy modernize-use-nullptr warnings in remaining files in include/lldb/Core; other minor fixes.
Modified: lldb/trunk/include/lldb/Core/STLUtils.h lldb/trunk/include/lldb/Core/SourceManager.h lldb/trunk/include/lldb/Core/Stream.h lldb/trunk/include/lldb/Core/StringList.h lldb/trunk/include/lldb/Core/StructuredData.h lldb/trunk/include/lldb/Core/Timer.h lldb/trunk/include/lldb/Core/UUID.h lldb/trunk/include/lldb/Core/UniqueCStringMap.h lldb/trunk/include/lldb/Core/Value.h lldb/trunk/include/lldb/Core/ValueObject.h lldb/trunk/include/lldb/Core/ValueObjectCast.h lldb/trunk/include/lldb/Core/ValueObjectConstResult.h lldb/trunk/include/lldb/Core/ValueObjectConstResultImpl.h lldb/trunk/include/lldb/Core/ValueObjectDynamicValue.h lldb/trunk/include/lldb/Core/ValueObjectSyntheticFilter.h Modified: lldb/trunk/include/lldb/Core/STLUtils.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/STLUtils.h?rev=251561&r1=251560&r2=251561&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/STLUtils.h (original) +++ lldb/trunk/include/lldb/Core/STLUtils.h Wed Oct 28 17:11:25 2015 @@ -9,14 +9,18 @@ #ifndef liblldb_STLUtils_h_ #define liblldb_STLUtils_h_ -#if defined(__cplusplus) +// C Includes #include <string.h> +// C++ Includes #include <map> #include <ostream> #include <vector> +// Other libraries and framework includes +// Project includes + //---------------------------------------------------------------------- // C string less than compare function object //---------------------------------------------------------------------- @@ -28,7 +32,6 @@ struct CStringCompareFunctionObject } }; - //---------------------------------------------------------------------- // C string equality function object (binary predicate). //---------------------------------------------------------------------- @@ -40,7 +43,6 @@ struct CStringEqualBinaryPredicate } }; - //---------------------------------------------------------------------- // Templated type for finding an entry in a std::map<F,S> whose value // is equal to something @@ -48,21 +50,26 @@ struct CStringEqualBinaryPredicate template <class F, class S> class ValueEquals { -private: - S second_value; - public: ValueEquals (const S& val) : second_value(val) {} + // Compare the second item bool operator() (std::pair<const F, S> elem) { return elem.second == second_value; } + +private: + S second_value; }; template <class T> -inline void PrintAllCollectionElements (std::ostream &s, const T& coll, const char* header_cstr=NULL, const char* separator_cstr=" ") +inline void +PrintAllCollectionElements(std::ostream &s, + const T& coll, + const char* header_cstr = nullptr, + const char* separator_cstr = " ") { typename T::const_iterator pos; @@ -88,7 +95,4 @@ struct for_each_cplusplus_delete typedef std::vector<std::string> STLStringArray; typedef std::vector<const char *> CStringArray; - - -#endif // #if defined(__cplusplus) -#endif // liblldb_STLUtils_h_ +#endif // liblldb_STLUtils_h_ Modified: lldb/trunk/include/lldb/Core/SourceManager.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/SourceManager.h?rev=251561&r1=251560&r2=251561&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/SourceManager.h (original) +++ lldb/trunk/include/lldb/Core/SourceManager.h Wed Oct 28 17:11:25 2015 @@ -13,6 +13,7 @@ // C Includes // C++ Includes #include <map> +#include <memory> #include <vector> // Other libraries and framework includes @@ -26,12 +27,11 @@ class SourceManager { public: #ifndef SWIG - class File { - friend bool operator== (const SourceManager::File &lhs, const SourceManager::File &rhs); + friend bool operator== (const SourceManager::File &lhs, const SourceManager::File &rhs); + public: - File (const FileSpec &file_spec, Target *target); ~File(); @@ -83,7 +83,6 @@ public: GetNumLines (); protected: - bool CalculateLineOffsets (uint32_t line = UINT32_MAX); @@ -95,20 +94,18 @@ public: typedef std::vector<uint32_t> LineOffsets; LineOffsets m_offsets; }; - #endif // SWIG typedef std::shared_ptr<File> FileSP; #ifndef SWIG - // The SourceFileCache class separates the source manager from the cache of source files, so the // cache can be stored in the Debugger, but the source managers can be per target. class SourceFileCache { public: - SourceFileCache () {} - ~SourceFileCache() {} + SourceFileCache() = default; + ~SourceFileCache() = default; void AddSourceFile (const FileSP &file_sp); FileSP FindSourceFile (const FileSpec &file_spec) const; @@ -117,8 +114,7 @@ public: typedef std::map <FileSpec, FileSP> FileCache; FileCache m_file_cache; }; -#endif - +#endif // SWIG //------------------------------------------------------------------ // Constructors and Destructors @@ -130,7 +126,6 @@ public: ~SourceManager(); - FileSP GetLastFile () { @@ -138,28 +133,28 @@ public: } size_t - DisplaySourceLinesWithLineNumbers (const FileSpec &file, - uint32_t line, - uint32_t context_before, - uint32_t context_after, - const char* current_line_cstr, - Stream *s, - const SymbolContextList *bp_locs = NULL); + DisplaySourceLinesWithLineNumbers(const FileSpec &file, + uint32_t line, + uint32_t context_before, + uint32_t context_after, + const char* current_line_cstr, + Stream *s, + const SymbolContextList *bp_locs = nullptr); // This variant uses the last file we visited. size_t - DisplaySourceLinesWithLineNumbersUsingLastFile (uint32_t start_line, - uint32_t count, - uint32_t curr_line, - const char* current_line_cstr, - Stream *s, - const SymbolContextList *bp_locs = NULL); + DisplaySourceLinesWithLineNumbersUsingLastFile(uint32_t start_line, + uint32_t count, + uint32_t curr_line, + const char* current_line_cstr, + Stream *s, + const SymbolContextList *bp_locs = nullptr); size_t - DisplayMoreWithLineNumbers (Stream *s, - uint32_t count, - bool reverse, - const SymbolContextList *bp_locs = NULL); + DisplayMoreWithLineNumbers(Stream *s, + uint32_t count, + bool reverse, + const SymbolContextList *bp_locs = nullptr); bool SetDefaultFileAndLine (const FileSpec &file_spec, uint32_t line); @@ -170,7 +165,7 @@ public: bool DefaultFileAndLineSet () { - return (m_last_file_sp.get() != NULL); + return (m_last_file_sp.get() != nullptr); } void @@ -184,10 +179,6 @@ public: GetFile (const FileSpec &file_spec); protected: - - //------------------------------------------------------------------ - // Classes that inherit from SourceManager can see and modify these - //------------------------------------------------------------------ FileSP m_last_file_sp; uint32_t m_last_line; uint32_t m_last_count; @@ -196,13 +187,11 @@ protected: lldb::DebuggerWP m_debugger_wp; private: - //------------------------------------------------------------------ - // For SourceManager only - //------------------------------------------------------------------ DISALLOW_COPY_AND_ASSIGN (SourceManager); }; bool operator== (const SourceManager::File &lhs, const SourceManager::File &rhs); + } // namespace lldb_private -#endif // liblldb_SourceManager_h_ +#endif // liblldb_SourceManager_h_ Modified: lldb/trunk/include/lldb/Core/Stream.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Stream.h?rev=251561&r1=251560&r2=251561&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/Stream.h (original) +++ lldb/trunk/include/lldb/Core/Stream.h Wed Oct 28 17:11:25 2015 @@ -9,11 +9,15 @@ #ifndef liblldb_Stream_h_ #define liblldb_Stream_h_ -#if defined(__cplusplus) +// C Includes +#include <stdarg.h> + +// C++ Includes +// Other libraries and framework includes +// Project includes #include "lldb/lldb-private.h" #include "lldb/Core/Flags.h" -#include <stdarg.h> namespace lldb_private { @@ -353,13 +357,13 @@ public: /// Size in bytes of the address, used for formatting. /// /// @param[in] prefix - /// A prefix C string. If NULL, no prefix will be output. + /// A prefix C string. If nullptr, no prefix will be output. /// /// @param[in] suffix - /// A suffix C string. If NULL, no suffix will be output. + /// A suffix C string. If nullptr, no suffix will be output. //------------------------------------------------------------------ void - Address (uint64_t addr, uint32_t addr_size, const char *prefix = NULL, const char *suffix = NULL); + Address(uint64_t addr, uint32_t addr_size, const char *prefix = nullptr, const char *suffix = nullptr); //------------------------------------------------------------------ /// Output an address range to this stream. @@ -377,13 +381,13 @@ public: /// Size in bytes of the address, used for formatting. /// /// @param[in] prefix - /// A prefix C string. If NULL, no prefix will be output. + /// A prefix C string. If nullptr, no prefix will be output. /// /// @param[in] suffix - /// A suffix C string. If NULL, no suffix will be output. + /// A suffix C string. If nullptr, no suffix will be output. //------------------------------------------------------------------ void - AddressRange(uint64_t lo_addr, uint64_t hi_addr, uint32_t addr_size, const char *prefix = NULL, const char *suffix = NULL); + AddressRange(uint64_t lo_addr, uint64_t hi_addr, uint32_t addr_size, const char *prefix = nullptr, const char *suffix = nullptr); //------------------------------------------------------------------ /// Output a C string to the stream. @@ -475,11 +479,11 @@ public: /// print an optional string following the indentation spaces. /// /// @param[in] s - /// A C string to print following the indentation. If NULL, just + /// A C string to print following the indentation. If nullptr, just /// output the indentation characters. //------------------------------------------------------------------ size_t - Indent(const char *s = NULL); + Indent(const char *s = nullptr); //------------------------------------------------------------------ /// Decrement the current indentation level. @@ -607,6 +611,4 @@ protected: } // namespace lldb_private -#endif // #if defined(__cplusplus) #endif // liblldb_Stream_h_ - Modified: lldb/trunk/include/lldb/Core/StringList.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/StringList.h?rev=251561&r1=251560&r2=251561&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/StringList.h (original) +++ lldb/trunk/include/lldb/Core/StringList.h Wed Oct 28 17:11:25 2015 @@ -10,18 +10,24 @@ #ifndef liblldb_StringList_h_ #define liblldb_StringList_h_ +// C Includes #include <stdint.h> -#include "lldb/Core/STLUtils.h" -#include "lldb/lldb-forward.h" +// C++ Includes +#include <string> + +// Other libraries and framework includes #include "llvm/ADT/StringRef.h" +// Project includes +#include "lldb/lldb-forward.h" +#include "lldb/Core/STLUtils.h" + namespace lldb_private { class StringList { public: - StringList (); StringList (const char *str); @@ -120,7 +126,7 @@ public: SplitIntoLines (const char *lines, size_t len); std::string - CopyList(const char* item_preamble = NULL, + CopyList(const char* item_preamble = nullptr, const char* items_sep = "\n") const; StringList& @@ -142,7 +148,6 @@ public: size_t &exact_matches_idx) const; private: - STLStringArray m_strings; }; Modified: lldb/trunk/include/lldb/Core/StructuredData.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/StructuredData.h?rev=251561&r1=251560&r2=251561&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/StructuredData.h (original) +++ lldb/trunk/include/lldb/Core/StructuredData.h Wed Oct 28 17:11:25 2015 @@ -12,16 +12,16 @@ // C Includes // C++ Includes - #include <functional> #include <map> +#include <memory> #include <string> #include <utility> #include <vector> +// Other libraries and framework includes #include "llvm/ADT/StringRef.h" -// Other libraries and framework includes // Project includes #include "lldb/lldb-defines.h" #include "lldb/Core/ConstString.h" @@ -47,7 +47,6 @@ namespace lldb_private { class StructuredData { public: - class Object; class Array; class Integer; @@ -89,9 +88,7 @@ public: { } - virtual ~Object () - { - } + virtual ~Object() = default; virtual bool IsValid() const @@ -120,80 +117,62 @@ public: Array * GetAsArray () { - if (m_type == Type::eTypeArray) - return (Array *)this; - return NULL; + return ((m_type == Type::eTypeArray) ? static_cast<Array *>(this) : nullptr); } Dictionary * GetAsDictionary () { - if (m_type == Type::eTypeDictionary) - return (Dictionary *)this; - return NULL; + return ((m_type == Type::eTypeDictionary) ? static_cast<Dictionary *>(this) : nullptr); } Integer * GetAsInteger () { - if (m_type == Type::eTypeInteger) - return (Integer *)this; - return NULL; + return ((m_type == Type::eTypeInteger) ? static_cast<Integer *>(this) : nullptr); } uint64_t GetIntegerValue (uint64_t fail_value = 0) { Integer *integer = GetAsInteger (); - if (integer) - return integer->GetValue(); - return fail_value; + return ((integer != nullptr) ? integer->GetValue() : fail_value); } Float * GetAsFloat () { - if (m_type == Type::eTypeFloat) - return (Float *)this; - return NULL; + return ((m_type == Type::eTypeFloat) ? static_cast<Float *>(this) : nullptr); } double GetFloatValue (double fail_value = 0.0) { Float *f = GetAsFloat (); - if (f) - return f->GetValue(); - return fail_value; + return ((f != nullptr) ? f->GetValue() : fail_value); } Boolean * GetAsBoolean () { - if (m_type == Type::eTypeBoolean) - return (Boolean *)this; - return NULL; + return ((m_type == Type::eTypeBoolean) ? static_cast<Boolean *>(this) : nullptr); } bool GetBooleanValue (bool fail_value = false) { Boolean *b = GetAsBoolean (); - if (b) - return b->GetValue(); - return fail_value; + return ((b != nullptr) ? b->GetValue() : fail_value); } String * GetAsString () { - if (m_type == Type::eTypeString) - return (String *)this; - return NULL; + return ((m_type == Type::eTypeString) ? static_cast<String *>(this) : nullptr); } std::string - GetStringValue(const char *fail_value = NULL) + GetStringValue(const char *fail_value = nullptr) { String *s = GetAsString (); if (s) @@ -208,9 +187,7 @@ public: Generic * GetAsGeneric() { - if (m_type == Type::eTypeGeneric) - return (Generic *)this; - return NULL; + return ((m_type == Type::eTypeGeneric) ? static_cast<Generic *>(this) : nullptr); } ObjectSP @@ -233,9 +210,7 @@ public: { } - ~Array() override - { - } + ~Array() override = default; bool ForEach (std::function <bool(Object* object)> const &foreach_callback) const @@ -382,9 +357,7 @@ public: { } - ~Integer() override - { - } + ~Integer() override = default; void SetValue (uint64_t value) @@ -413,9 +386,7 @@ public: { } - ~Float() override - { - } + ~Float() override = default; void SetValue (double value) @@ -444,9 +415,7 @@ public: { } - ~Boolean() override - { - } + ~Boolean() override = default; void SetValue (bool value) @@ -469,7 +438,7 @@ public: class String : public Object { public: - String (const char *cstr = NULL) : + String(const char *cstr = nullptr) : Object (Type::eTypeString), m_value () { @@ -517,9 +486,7 @@ public: { } - ~Dictionary() override - { - } + ~Dictionary() override = default; size_t GetSize() const @@ -723,9 +690,7 @@ public: { } - ~Null() override - { - } + ~Null() override = default; bool IsValid() const override @@ -734,13 +699,11 @@ public: } void Dump(Stream &s) const override; - - protected: }; class Generic : public Object { - public: + public: explicit Generic(void *object = nullptr) : Object (Type::eTypeGeneric), m_object (object) @@ -767,13 +730,13 @@ public: void Dump(Stream &s) const override; - private: + private: void *m_object; }; static ObjectSP ParseJSON (std::string json_text); -}; // class StructuredData +}; } // namespace lldb_private Modified: lldb/trunk/include/lldb/Core/Timer.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Timer.h?rev=251561&r1=251560&r2=251561&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/Timer.h (original) +++ lldb/trunk/include/lldb/Core/Timer.h Wed Oct 28 17:11:25 2015 @@ -9,15 +9,17 @@ #ifndef liblldb_Timer_h_ #define liblldb_Timer_h_ -#if defined(__cplusplus) +// C Includes #include <stdarg.h> #include <stdio.h> +// C++ Includes #include <atomic> #include <mutex> -#include <string> +// Other libraries and framework includes +// Project includes #include "lldb/lldb-private.h" #include "lldb/Host/TimeValue.h" @@ -38,9 +40,6 @@ namespace lldb_private { class Timer { public: - static void - Initialize (); - //-------------------------------------------------------------- /// Default constructor. //-------------------------------------------------------------- @@ -51,6 +50,9 @@ public: //-------------------------------------------------------------- ~Timer(); + static void + Initialize (); + void Dump (); @@ -67,7 +69,6 @@ public: ResetCategoryTimes (); protected: - void ChildStarted (const TimeValue& time); @@ -80,9 +81,6 @@ protected: uint64_t GetTimerElapsedNanoSeconds(); - //-------------------------------------------------------------- - /// Member variables - //-------------------------------------------------------------- const char *m_category; TimeValue m_total_start; TimeValue m_timer_start; @@ -106,10 +104,8 @@ public: m_start (TimeValue::Now()) { } - - ~IntervalTimer() - { - } + + ~IntervalTimer() = default; uint64_t GetElapsedNanoSeconds() const @@ -128,7 +124,7 @@ public: { TimeValue now (TimeValue::Now()); const uint64_t elapsed_nsec = now - m_start; - const char *unit = NULL; + const char *unit = nullptr; float elapsed_value; if (elapsed_nsec < 1000) { @@ -157,11 +153,11 @@ public: va_end (args); return result; } + protected: TimeValue m_start; }; } // namespace lldb_private -#endif // #if defined(__cplusplus) -#endif // #ifndef liblldb_Timer_h_ +#endif // liblldb_Timer_h_ Modified: lldb/trunk/include/lldb/Core/UUID.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/UUID.h?rev=251561&r1=251560&r2=251561&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/UUID.h (original) +++ lldb/trunk/include/lldb/Core/UUID.h Wed Oct 28 17:11:25 2015 @@ -16,7 +16,6 @@ // Other libraries and framework includes // Project includes - #include "lldb/lldb-private.h" namespace lldb_private { @@ -58,7 +57,7 @@ public: SetBytes (const void *uuid_bytes, uint32_t num_uuid_bytes = 16); std::string - GetAsString (const char *separator = NULL) const; + GetAsString(const char *separator = nullptr) const; size_t SetFromCString (const char *c_str, uint32_t num_uuid_bytes = 16); @@ -80,7 +79,7 @@ public: /// decoded UUID. /// /// @param[out] end - /// If \a end is not NULL, it will be filled in with the a + /// If \a end is not nullptr, it will be filled in with the a /// pointer to the character after the last successfully decoded /// byte. /// Modified: lldb/trunk/include/lldb/Core/UniqueCStringMap.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/UniqueCStringMap.h?rev=251561&r1=251560&r2=251561&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/UniqueCStringMap.h (original) +++ lldb/trunk/include/lldb/Core/UniqueCStringMap.h Wed Oct 28 17:11:25 2015 @@ -9,18 +9,18 @@ #ifndef liblldb_UniqueCStringMap_h_ #define liblldb_UniqueCStringMap_h_ -#if defined(__cplusplus) -#include <assert.h> +// C Includes +// C++ Includes #include <algorithm> #include <vector> +// Other libraries and framework includes +// Project includes #include "lldb/Core/RegularExpression.h" namespace lldb_private { - - //---------------------------------------------------------------------- // Templatized uniqued string map. // @@ -37,7 +37,7 @@ public: struct Entry { Entry () : - cstring(NULL), + cstring(nullptr), value() { } @@ -146,9 +146,7 @@ public: const char * GetCStringAtIndex (uint32_t idx) const { - if (idx < m_map.size()) - return m_map[idx].cstring; - return NULL; + return ((idx < m_map.size()) ? m_map[idx].cstring : nullptr); } //------------------------------------------------------------------ @@ -172,8 +170,9 @@ public: } return fail_value; } + //------------------------------------------------------------------ - // Get a pointer to the first entry that matches "name". NULL will + // Get a pointer to the first entry that matches "name". nullptr will // be returned if there is no entry that matches "name". // // The caller is responsible for ensuring that the collection does @@ -191,12 +190,12 @@ public: if (pos_cstr == unique_cstr) return &(*pos); } - return NULL; + return nullptr; } //------------------------------------------------------------------ // Get a pointer to the next entry that matches "name" from a - // previously returned Entry pointer. NULL will be returned if there + // previously returned Entry pointer. nullptr will be returned if there // is no subsequent entry that matches "name". // // The caller is responsible for ensuring that the collection does @@ -216,7 +215,7 @@ public: return next_entry; } } - return NULL; + return nullptr; } size_t @@ -261,7 +260,6 @@ public: return m_map.size(); } - //------------------------------------------------------------------ // Returns true if this map is empty. //------------------------------------------------------------------ @@ -346,6 +344,7 @@ public: } return num_removed; } + protected: typedef std::vector<Entry> collection; typedef typename collection::iterator iterator; @@ -353,9 +352,6 @@ protected: collection m_map; }; - - } // namespace lldb_private -#endif // #if defined(__cplusplus) -#endif // liblldb_UniqueCStringMap_h_ +#endif // liblldb_UniqueCStringMap_h_ Modified: lldb/trunk/include/lldb/Core/Value.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Value.h?rev=251561&r1=251560&r2=251561&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/Value.h (original) +++ lldb/trunk/include/lldb/Core/Value.h Wed Oct 28 17:11:25 2015 @@ -12,8 +12,8 @@ // C Includes // C++ Includes -#include <string> #include <vector> + // Other libraries and framework includes // Project includes #include "lldb/lldb-private.h" @@ -27,7 +27,6 @@ namespace lldb_private { class Value { public: - // Values Less than zero are an error, greater than or equal to zero // returns what the Scalar result is. enum ValueType @@ -159,7 +158,7 @@ public: void ClearContext () { - m_context = NULL; + m_context = nullptr; m_context_type = eContextTypeInvalid; } @@ -268,10 +267,10 @@ public: GetValueByteSize (Error *error_ptr, ExecutionContext *exe_ctx); Error - GetValueAsData (ExecutionContext *exe_ctx, - DataExtractor &data, - uint32_t data_offset, - Module *module); // Can be NULL + GetValueAsData(ExecutionContext *exe_ctx, + DataExtractor &data, + uint32_t data_offset, + Module *module); // Can be nullptr static const char * GetValueTypeAsCString (ValueType context_type); @@ -305,9 +304,7 @@ public: ValueList (const ValueList &rhs); - ~ValueList () - { - } + ~ValueList() = default; const ValueList & operator= (const ValueList &rhs); @@ -318,8 +315,6 @@ public: Value *GetValueAtIndex(size_t idx); void Clear(); -protected: - private: typedef std::vector<Value> collection; @@ -328,4 +323,4 @@ private: } // namespace lldb_private -#endif // liblldb_Value_h_ +#endif // liblldb_Value_h_ Modified: lldb/trunk/include/lldb/Core/ValueObject.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObject.h?rev=251561&r1=251560&r2=251561&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/ValueObject.h (original) +++ lldb/trunk/include/lldb/Core/ValueObject.h Wed Oct 28 17:11:25 2015 @@ -12,6 +12,8 @@ // C Includes // C++ Includes +#include <functional> +#include <initializer_list> #include <map> #include <vector> @@ -69,7 +71,6 @@ namespace lldb_private { class ValueObject : public UserID { public: - enum GetExpressionPathFormat { eGetExpressionPathFormatDereferencePointers = 1, @@ -221,13 +222,11 @@ public: return g_default_options; } - }; class EvaluationPoint { public: - EvaluationPoint (); EvaluationPoint (ExecutionContextScope *exe_scope, bool use_selected = false); @@ -326,6 +325,8 @@ public: bool m_needs_update; }; + virtual ~ValueObject(); + const EvaluationPoint & GetUpdatePoint () const { @@ -371,8 +372,6 @@ public: void SetNeedsUpdate (); - virtual ~ValueObject(); - CompilerType GetCompilerType (); @@ -408,7 +407,7 @@ public: GetObjectRuntimeLanguage(); virtual uint32_t - GetTypeInfo (CompilerType *pointee_or_element_compiler_type = NULL); + GetTypeInfo(CompilerType *pointee_or_element_compiler_type = nullptr); virtual bool IsPointerType (); @@ -454,20 +453,20 @@ public: lldb::ValueObjectSP GetValueForExpressionPath(const char* expression, - const char** first_unparsed = NULL, - ExpressionPathScanEndReason* reason_to_stop = NULL, - ExpressionPathEndResultType* final_value_type = NULL, + const char** first_unparsed = nullptr, + ExpressionPathScanEndReason* reason_to_stop = nullptr, + ExpressionPathEndResultType* final_value_type = nullptr, const GetValueForExpressionPathOptions& options = GetValueForExpressionPathOptions::DefaultOptions(), - ExpressionPathAftermath* final_task_on_target = NULL); + ExpressionPathAftermath* final_task_on_target = nullptr); int GetValuesForExpressionPath(const char* expression, lldb::ValueObjectListSP& list, - const char** first_unparsed = NULL, - ExpressionPathScanEndReason* reason_to_stop = NULL, - ExpressionPathEndResultType* final_value_type = NULL, + const char** first_unparsed = nullptr, + ExpressionPathScanEndReason* reason_to_stop = nullptr, + ExpressionPathEndResultType* final_value_type = nullptr, const GetValueForExpressionPathOptions& options = GetValueForExpressionPathOptions::DefaultOptions(), - ExpressionPathAftermath* final_task_on_target = NULL); + ExpressionPathAftermath* final_task_on_target = nullptr); virtual bool IsInScope () @@ -517,10 +516,10 @@ public: std::string& destination); virtual uint64_t - GetValueAsUnsigned (uint64_t fail_value, bool *success = NULL); + GetValueAsUnsigned(uint64_t fail_value, bool *success = nullptr); virtual int64_t - GetValueAsSigned (int64_t fail_value, bool *success = NULL); + GetValueAsSigned(int64_t fail_value, bool *success = nullptr); virtual bool SetValueFromCString (const char *value_str, Error& error); @@ -556,37 +555,37 @@ public: // this will always create the children if necessary lldb::ValueObjectSP - GetChildAtIndexPath (const std::initializer_list<size_t> &idxs, - size_t* index_of_error = NULL); + GetChildAtIndexPath(const std::initializer_list<size_t> &idxs, + size_t* index_of_error = nullptr); lldb::ValueObjectSP - GetChildAtIndexPath (const std::vector<size_t> &idxs, - size_t* index_of_error = NULL); + GetChildAtIndexPath(const std::vector<size_t> &idxs, + size_t* index_of_error = nullptr); lldb::ValueObjectSP - GetChildAtIndexPath (const std::initializer_list< std::pair<size_t, bool> > &idxs, - size_t* index_of_error = NULL); + GetChildAtIndexPath(const std::initializer_list< std::pair<size_t, bool> > &idxs, + size_t* index_of_error = nullptr); lldb::ValueObjectSP - GetChildAtIndexPath (const std::vector< std::pair<size_t, bool> > &idxs, - size_t* index_of_error = NULL); + GetChildAtIndexPath(const std::vector< std::pair<size_t, bool> > &idxs, + size_t* index_of_error = nullptr); // this will always create the children if necessary lldb::ValueObjectSP - GetChildAtNamePath (const std::initializer_list<ConstString> &names, - ConstString* name_of_error = NULL); + GetChildAtNamePath(const std::initializer_list<ConstString> &names, + ConstString* name_of_error = nullptr); lldb::ValueObjectSP - GetChildAtNamePath (const std::vector<ConstString> &names, - ConstString* name_of_error = NULL); + GetChildAtNamePath(const std::vector<ConstString> &names, + ConstString* name_of_error = nullptr); lldb::ValueObjectSP - GetChildAtNamePath (const std::initializer_list< std::pair<ConstString, bool> > &names, - ConstString* name_of_error = NULL); + GetChildAtNamePath(const std::initializer_list< std::pair<ConstString, bool> > &names, + ConstString* name_of_error = nullptr); lldb::ValueObjectSP - GetChildAtNamePath (const std::vector< std::pair<ConstString, bool> > &names, - ConstString* name_of_error = NULL); + GetChildAtNamePath(const std::vector< std::pair<ConstString, bool> > &names, + ConstString* name_of_error = nullptr); virtual lldb::ValueObjectSP GetChildMemberWithName (const ConstString &name, bool can_create); @@ -672,11 +671,11 @@ public: SetName (const ConstString &name); virtual lldb::addr_t - GetAddressOf (bool scalar_is_load_address = true, - AddressType *address_type = NULL); + GetAddressOf(bool scalar_is_load_address = true, + AddressType *address_type = nullptr); lldb::addr_t - GetPointerValue (AddressType *address_type = NULL); + GetPointerValue(AddressType *address_type = nullptr); lldb::ValueObjectSP GetSyntheticChild (const ConstString &key) const; @@ -882,8 +881,7 @@ public: ClearUserVisibleData(eClearUserVisibleDataItemsValue); m_format = format; } - - + virtual lldb::LanguageType GetPreferredDisplayLanguage (); @@ -1019,21 +1017,15 @@ protected: HasChildAtIndex (size_t idx) { Mutex::Locker locker(m_mutex); - ChildrenIterator iter = m_children.find(idx); - ChildrenIterator end = m_children.end(); - return (iter != end); + return (m_children.find(idx) != m_children.end()); } ValueObject* GetChildAtIndex (size_t idx) { Mutex::Locker locker(m_mutex); - ChildrenIterator iter = m_children.find(idx); - ChildrenIterator end = m_children.end(); - if (iter == end) - return NULL; - else - return iter->second; + const auto iter = m_children.find(idx); + return ((iter == m_children.end()) ? nullptr : iter->second); } void @@ -1076,8 +1068,8 @@ protected: //------------------------------------------------------------------ // Classes that inherit from ValueObject can see and modify these //------------------------------------------------------------------ - ValueObject * m_parent; // The parent value object, or NULL if this has no parent - ValueObject * m_root; // The root of the hierarchy for this ValueObject (or NULL if never calculated) + ValueObject * m_parent; // The parent value object, or nullptr if this has no parent + ValueObject * m_root; // The root of the hierarchy for this ValueObject (or nullptr if never calculated) EvaluationPoint m_update_point; // Stores both the stop id and the full context at which this value was last // updated. When we are asked to update the value object, we check whether // the context & stop id are the same before updating. @@ -1246,10 +1238,6 @@ protected: SetPreferredDisplayLanguageIfNeeded (lldb::LanguageType); private: - //------------------------------------------------------------------ - // For ValueObject only - //------------------------------------------------------------------ - virtual CompilerType MaybeCalculateCompleteType (); @@ -1274,12 +1262,10 @@ private: ExpressionPathEndResultType* final_value_type, const GetValueForExpressionPathOptions& options, ExpressionPathAftermath* final_task_on_target); - - - DISALLOW_COPY_AND_ASSIGN (ValueObject); + DISALLOW_COPY_AND_ASSIGN (ValueObject); }; } // namespace lldb_private -#endif // liblldb_ValueObject_h_ +#endif // liblldb_ValueObject_h_ Modified: lldb/trunk/include/lldb/Core/ValueObjectCast.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObjectCast.h?rev=251561&r1=251560&r2=251561&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/ValueObjectCast.h (original) +++ lldb/trunk/include/lldb/Core/ValueObjectCast.h Wed Oct 28 17:11:25 2015 @@ -1,4 +1,4 @@ -//===-- ValueObjectDynamicValue.h -----------------------------------*- C++ -*-===// +//===-- ValueObjectDynamicValue.h -------------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -24,13 +24,13 @@ namespace lldb_private { class ValueObjectCast : public ValueObject { public: + ~ValueObjectCast() override; + static lldb::ValueObjectSP Create (ValueObject &parent, const ConstString &name, const CompilerType &cast_type); - ~ValueObjectCast() override; - uint64_t GetByteSize() override; @@ -46,22 +46,20 @@ public: ValueObject * GetParent() override { - if (m_parent) - return m_parent->GetParent(); - else - return NULL; + return ((m_parent != nullptr) ? m_parent->GetParent() : nullptr); } const ValueObject * GetParent() const override { - if (m_parent) - return m_parent->GetParent(); - else - return NULL; + return ((m_parent != nullptr) ? m_parent->GetParent() : nullptr); } protected: + ValueObjectCast(ValueObject &parent, + const ConstString &name, + const CompilerType &cast_type); + bool UpdateValue () override; @@ -70,14 +68,7 @@ protected: CompilerType m_cast_type; - ValueObjectCast (ValueObject &parent, - const ConstString &name, - const CompilerType &cast_type); - private: - //------------------------------------------------------------------ - // For ValueObject only - //------------------------------------------------------------------ DISALLOW_COPY_AND_ASSIGN (ValueObjectCast); }; Modified: lldb/trunk/include/lldb/Core/ValueObjectConstResult.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObjectConstResult.h?rev=251561&r1=251560&r2=251561&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/ValueObjectConstResult.h (original) +++ lldb/trunk/include/lldb/Core/ValueObjectConstResult.h Wed Oct 28 17:11:25 2015 @@ -104,7 +104,7 @@ public: lldb::addr_t GetAddressOf(bool scalar_is_load_address = true, - AddressType *address_type = NULL) override; + AddressType *address_type = nullptr) override; size_t GetPointeeData(DataExtractor& data, Modified: lldb/trunk/include/lldb/Core/ValueObjectConstResultImpl.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObjectConstResultImpl.h?rev=251561&r1=251560&r2=251561&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/ValueObjectConstResultImpl.h (original) +++ lldb/trunk/include/lldb/Core/ValueObjectConstResultImpl.h Wed Oct 28 17:11:25 2015 @@ -1,4 +1,4 @@ -//===-- ValueObjectConstResultImpl.h -----------------------------*- C++ -*-===// +//===-- ValueObjectConstResultImpl.h ----------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -26,15 +26,12 @@ namespace lldb_private { class ValueObjectConstResultImpl { public: - ValueObjectConstResultImpl (ValueObject* valobj, lldb::addr_t live_address = LLDB_INVALID_ADDRESS); - + virtual - ~ValueObjectConstResultImpl() - { - } - + ~ValueObjectConstResultImpl() = default; + lldb::ValueObjectSP Dereference (Error &error); @@ -65,16 +62,15 @@ public: } virtual lldb::addr_t - GetAddressOf (bool scalar_is_load_address = true, - AddressType *address_type = NULL); + GetAddressOf(bool scalar_is_load_address = true, + AddressType *address_type = nullptr); virtual size_t - GetPointeeData (DataExtractor& data, - uint32_t item_idx = 0, - uint32_t item_count = 1); + GetPointeeData(DataExtractor& data, + uint32_t item_idx = 0, + uint32_t item_count = 1); private: - ValueObject *m_impl_backend; lldb::addr_t m_live_address; AddressType m_live_address_type; @@ -86,4 +82,4 @@ private: } // namespace lldb_private -#endif // liblldb_ValueObjectConstResultImpl_h_ +#endif // liblldb_ValueObjectConstResultImpl_h_ Modified: lldb/trunk/include/lldb/Core/ValueObjectDynamicValue.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObjectDynamicValue.h?rev=251561&r1=251560&r2=251561&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/ValueObjectDynamicValue.h (original) +++ lldb/trunk/include/lldb/Core/ValueObjectDynamicValue.h Wed Oct 28 17:11:25 2015 @@ -1,4 +1,4 @@ -//===-- ValueObjectDynamicValue.h -----------------------------------*- C++ -*-===// +//===-- ValueObjectDynamicValue.h -------------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -64,19 +64,13 @@ public: ValueObject * GetParent() override { - if (m_parent) - return m_parent->GetParent(); - else - return NULL; + return ((m_parent != nullptr) ? m_parent->GetParent() : nullptr); } const ValueObject * GetParent() const override { - if (m_parent) - return m_parent->GetParent(); - else - return NULL; + return ((m_parent != nullptr) ? m_parent->GetParent() : nullptr); } lldb::ValueObjectSP @@ -91,7 +85,7 @@ public: if (m_owning_valobj_sp == owning_sp) return; - assert (m_owning_valobj_sp.get() == NULL); + assert (m_owning_valobj_sp.get() == nullptr); m_owning_valobj_sp = owning_sp; } @@ -149,9 +143,6 @@ private: friend class ValueObjectConstResult; ValueObjectDynamicValue (ValueObject &parent, lldb::DynamicValueType use_dynamic); - //------------------------------------------------------------------ - // For ValueObject only - //------------------------------------------------------------------ DISALLOW_COPY_AND_ASSIGN (ValueObjectDynamicValue); }; Modified: lldb/trunk/include/lldb/Core/ValueObjectSyntheticFilter.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObjectSyntheticFilter.h?rev=251561&r1=251560&r2=251561&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/ValueObjectSyntheticFilter.h (original) +++ lldb/trunk/include/lldb/Core/ValueObjectSyntheticFilter.h Wed Oct 28 17:11:25 2015 @@ -1,4 +1,4 @@ -//===-- ValueObjectSyntheticFilter.h -------------------------------*- C++ -*-===// +//===-- ValueObjectSyntheticFilter.h ----------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -12,7 +12,7 @@ // C Includes // C++ Includes -#include <vector> +#include <memory> // Other libraries and framework includes // Project includes @@ -89,46 +89,31 @@ public: bool IsDynamic() override { - if (m_parent) - return m_parent->IsDynamic(); - else - return false; + return ((m_parent != nullptr) ? m_parent->IsDynamic() : false); } lldb::ValueObjectSP GetStaticValue() override { - if (m_parent) - return m_parent->GetStaticValue(); - else - return GetSP(); + return ((m_parent != nullptr) ? m_parent->GetStaticValue() : GetSP()); } virtual lldb::DynamicValueType GetDynamicValueType () { - if (m_parent) - return m_parent->GetDynamicValueType(); - else - return lldb::eNoDynamicValues; + return ((m_parent != nullptr) ? m_parent->GetDynamicValueType() : lldb::eNoDynamicValues); } ValueObject * GetParent() override { - if (m_parent) - return m_parent->GetParent(); - else - return NULL; + return ((m_parent != nullptr) ? m_parent->GetParent() : nullptr); } const ValueObject * GetParent() const override { - if (m_parent) - return m_parent->GetParent(); - else - return NULL; + return ((m_parent != nullptr) ? m_parent->GetParent() : nullptr); } lldb::ValueObjectSP @@ -207,9 +192,6 @@ private: void CopyValueData (ValueObject *source); - //------------------------------------------------------------------ - // For ValueObject only - //------------------------------------------------------------------ DISALLOW_COPY_AND_ASSIGN (ValueObjectSynthetic); }; _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits