[Lldb-commits] [lldb] r298412 - Move StringList from Core -> Utility.
Zachary Turner via lldb-commits
lldb-commits at lists.llvm.org
Tue Mar 21 11:25:04 PDT 2017
Author: zturner
Date: Tue Mar 21 13:25:04 2017
New Revision: 298412
URL: http://llvm.org/viewvc/llvm-project?rev=298412&view=rev
Log:
Move StringList from Core -> Utility.
Added:
lldb/trunk/include/lldb/Utility/StringList.h
lldb/trunk/source/Utility/StringList.cpp
Removed:
lldb/trunk/include/lldb/Core/StringList.h
lldb/trunk/source/Core/StringList.cpp
Modified:
lldb/trunk/include/lldb/Breakpoint/Breakpoint.h
lldb/trunk/include/lldb/Breakpoint/BreakpointOptions.h
lldb/trunk/include/lldb/Breakpoint/WatchpointOptions.h
lldb/trunk/include/lldb/Core/IOHandler.h
lldb/trunk/include/lldb/Core/UserSettingsController.h
lldb/trunk/include/lldb/Host/Host.h
lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h
lldb/trunk/include/lldb/Interpreter/CommandObject.h
lldb/trunk/source/API/SBStringList.cpp
lldb/trunk/source/Breakpoint/BreakpointOptions.cpp
lldb/trunk/source/Breakpoint/WatchpointOptions.cpp
lldb/trunk/source/Commands/CommandObjectCommands.cpp
lldb/trunk/source/Commands/CommandObjectType.cpp
lldb/trunk/source/Core/ArchSpec.cpp
lldb/trunk/source/Core/CMakeLists.txt
lldb/trunk/source/Host/common/Editline.cpp
lldb/trunk/source/Host/common/FileSpec.cpp
lldb/trunk/source/Interpreter/OptionValue.cpp
lldb/trunk/source/Interpreter/OptionValueBoolean.cpp
lldb/trunk/source/Interpreter/OptionValueChar.cpp
lldb/trunk/source/Interpreter/OptionValueEnumeration.cpp
lldb/trunk/source/Interpreter/OptionValueFormatEntity.cpp
lldb/trunk/source/Interpreter/OptionValueProperties.cpp
lldb/trunk/source/Interpreter/OptionValueUUID.cpp
lldb/trunk/source/Interpreter/ScriptInterpreter.cpp
lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.h
lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
lldb/trunk/source/Plugins/ScriptInterpreter/None/ScriptInterpreterNone.cpp
lldb/trunk/source/Utility/CMakeLists.txt
lldb/trunk/unittests/Editline/EditlineTest.cpp
lldb/trunk/unittests/Interpreter/TestCompletion.cpp
Modified: lldb/trunk/include/lldb/Breakpoint/Breakpoint.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Breakpoint/Breakpoint.h?rev=298412&r1=298411&r2=298412&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Breakpoint/Breakpoint.h (original)
+++ lldb/trunk/include/lldb/Breakpoint/Breakpoint.h Tue Mar 21 13:25:04 2017
@@ -26,8 +26,8 @@
#include "lldb/Breakpoint/Stoppoint.h"
#include "lldb/Core/Event.h"
#include "lldb/Core/SearchFilter.h"
-#include "lldb/Core/StringList.h"
#include "lldb/Core/StructuredData.h"
+#include "lldb/Utility/StringList.h"
namespace lldb_private {
Modified: lldb/trunk/include/lldb/Breakpoint/BreakpointOptions.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Breakpoint/BreakpointOptions.h?rev=298412&r1=298411&r2=298412&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Breakpoint/BreakpointOptions.h (original)
+++ lldb/trunk/include/lldb/Breakpoint/BreakpointOptions.h Tue Mar 21 13:25:04 2017
@@ -17,9 +17,9 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/StringList.h"
#include "lldb/Core/StructuredData.h"
#include "lldb/Utility/Baton.h"
+#include "lldb/Utility/StringList.h"
#include "lldb/lldb-private.h"
namespace lldb_private {
Modified: lldb/trunk/include/lldb/Breakpoint/WatchpointOptions.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Breakpoint/WatchpointOptions.h?rev=298412&r1=298411&r2=298412&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Breakpoint/WatchpointOptions.h (original)
+++ lldb/trunk/include/lldb/Breakpoint/WatchpointOptions.h Tue Mar 21 13:25:04 2017
@@ -17,8 +17,8 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/StringList.h"
#include "lldb/Utility/Baton.h"
+#include "lldb/Utility/StringList.h"
#include "lldb/lldb-private.h"
namespace lldb_private {
Modified: lldb/trunk/include/lldb/Core/IOHandler.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/IOHandler.h?rev=298412&r1=298411&r2=298412&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/IOHandler.h (original)
+++ lldb/trunk/include/lldb/Core/IOHandler.h Tue Mar 21 13:25:04 2017
@@ -23,12 +23,12 @@
// Project includes
#include "lldb/Utility/Flags.h"
-#include "lldb/Core/StringList.h"
#include "lldb/Core/ValueObjectList.h"
#include "lldb/Host/Predicate.h"
#include "lldb/Utility/ConstString.h"
#include "lldb/Utility/Error.h"
#include "lldb/Utility/Stream.h"
+#include "lldb/Utility/StringList.h"
#include "lldb/lldb-enumerations.h"
#include "lldb/lldb-public.h"
Removed: lldb/trunk/include/lldb/Core/StringList.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/StringList.h?rev=298411&view=auto
==============================================================================
--- lldb/trunk/include/lldb/Core/StringList.h (original)
+++ lldb/trunk/include/lldb/Core/StringList.h (removed)
@@ -1,139 +0,0 @@
-//===-- StringList.h --------------------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef liblldb_StringList_h_
-#define liblldb_StringList_h_
-
-// C Includes
-#include <stdint.h>
-
-// C++ Includes
-#include <string>
-
-// Other libraries and framework includes
-#include "llvm/ADT/StringRef.h"
-
-// Project includes
-#include "lldb/Core/STLUtils.h"
-#include "lldb/lldb-forward.h"
-
-namespace lldb_private {
-
-class StringList {
-public:
- StringList();
-
- StringList(const char *str);
-
- StringList(const char **strv, int strc);
-
- virtual ~StringList();
-
- void AppendString(const std::string &s);
-
- void AppendString(std::string &&s);
-
- void AppendString(const char *str);
-
- void AppendString(const char *str, size_t str_len);
-
- void AppendString(llvm::StringRef str);
-
- void AppendList(const char **strv, int strc);
-
- void AppendList(StringList strings);
-
- size_t GetSize() const;
-
- void SetSize(size_t n) { m_strings.resize(n); }
-
- size_t GetMaxStringLength() const;
-
- std::string &operator[](size_t idx) {
- // No bounds checking, verify "idx" is good prior to calling this function
- return m_strings[idx];
- }
-
- const std::string &operator[](size_t idx) const {
- // No bounds checking, verify "idx" is good prior to calling this function
- return m_strings[idx];
- }
-
- void PopBack() { m_strings.pop_back(); }
- const char *GetStringAtIndex(size_t idx) const;
-
- void Join(const char *separator, Stream &strm);
-
- void Clear();
-
- void LongestCommonPrefix(std::string &common_prefix);
-
- void InsertStringAtIndex(size_t idx, const std::string &str);
-
- void InsertStringAtIndex(size_t idx, std::string &&str);
-
- void InsertStringAtIndex(size_t id, const char *str);
-
- void DeleteStringAtIndex(size_t id);
-
- void RemoveBlankLines();
-
- size_t SplitIntoLines(const std::string &lines);
-
- size_t SplitIntoLines(const char *lines, size_t len);
-
- std::string CopyList(const char *item_preamble = nullptr,
- const char *items_sep = "\n") const;
-
- StringList &operator<<(const char *str);
-
- StringList &operator<<(const std::string &s);
-
- StringList &operator<<(StringList strings);
-
- // Copy assignment for a vector of strings
- StringList &operator=(const std::vector<std::string> &rhs);
-
- // This string list contains a list of valid auto completion
- // strings, and the "s" is passed in. "matches" is filled in
- // with zero or more string values that start with "s", and
- // the first string to exactly match one of the string
- // values in this collection, will have "exact_matches_idx"
- // filled in to match the index, or "exact_matches_idx" will
- // have SIZE_MAX
- size_t AutoComplete(llvm::StringRef s, StringList &matches,
- size_t &exact_matches_idx) const;
-
- // Dump the StringList to the given lldb_private::Log, `log`, one item per
- // line.
- // If given, `name` will be used to identify the start and end of the list in
- // the output.
- virtual void LogDump(Log *log, const char *name = nullptr);
-
- // Static helper to convert an iterable of strings to a StringList, and then
- // dump it with the semantics of the `LogDump` method.
- template <typename T>
- static void LogDump(Log *log, T s_iterable, const char *name = nullptr) {
- if (!log)
- return;
- // Make a copy of the iterable as a StringList
- StringList l{};
- for (const auto &s : s_iterable)
- l << s;
-
- l.LogDump(log, name);
- }
-
-private:
- STLStringArray m_strings;
-};
-
-} // namespace lldb_private
-
-#endif // liblldb_StringList_h_
Modified: lldb/trunk/include/lldb/Core/UserSettingsController.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/UserSettingsController.h?rev=298412&r1=298411&r2=298412&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/UserSettingsController.h (original)
+++ lldb/trunk/include/lldb/Core/UserSettingsController.h Tue Mar 21 13:25:04 2017
@@ -19,11 +19,11 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/StringList.h"
#include "lldb/Interpreter/OptionValue.h"
#include "lldb/Utility/ConstString.h"
#include "lldb/Utility/Stream.h"
#include "lldb/Utility/StreamString.h"
+#include "lldb/Utility/StringList.h"
#include "lldb/lldb-private.h"
namespace lldb_private {
Modified: lldb/trunk/include/lldb/Host/Host.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/Host.h?rev=298412&r1=298411&r2=298412&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Host/Host.h (original)
+++ lldb/trunk/include/lldb/Host/Host.h Tue Mar 21 13:25:04 2017
@@ -16,10 +16,10 @@
#include <map>
#include <string>
-#include "lldb/Core/StringList.h"
#include "lldb/Host/File.h"
#include "lldb/Host/FileSpec.h"
#include "lldb/Host/HostThread.h"
+#include "lldb/Utility/StringList.h"
#include "lldb/lldb-private-forward.h"
#include "lldb/lldb-private.h"
Modified: lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h?rev=298412&r1=298411&r2=298412&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h (original)
+++ lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h Tue Mar 21 13:25:04 2017
@@ -19,13 +19,13 @@
#include "lldb/Core/Debugger.h"
#include "lldb/Core/Event.h"
#include "lldb/Core/IOHandler.h"
-#include "lldb/Core/StringList.h"
#include "lldb/Interpreter/Args.h"
#include "lldb/Interpreter/CommandAlias.h"
#include "lldb/Interpreter/CommandHistory.h"
#include "lldb/Interpreter/CommandObject.h"
#include "lldb/Interpreter/ScriptInterpreter.h"
#include "lldb/Utility/Log.h"
+#include "lldb/Utility/StringList.h"
#include "lldb/lldb-forward.h"
#include "lldb/lldb-private.h"
Modified: lldb/trunk/include/lldb/Interpreter/CommandObject.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/CommandObject.h?rev=298412&r1=298411&r2=298412&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Interpreter/CommandObject.h (original)
+++ lldb/trunk/include/lldb/Interpreter/CommandObject.h Tue Mar 21 13:25:04 2017
@@ -20,10 +20,10 @@
// Project includes
#include "lldb/Utility/Flags.h"
-#include "lldb/Core/StringList.h"
#include "lldb/Interpreter/Args.h"
#include "lldb/Interpreter/CommandCompletions.h"
#include "lldb/Target/ExecutionContext.h"
+#include "lldb/Utility/StringList.h"
#include "lldb/lldb-private.h"
namespace lldb_private {
Added: lldb/trunk/include/lldb/Utility/StringList.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Utility/StringList.h?rev=298412&view=auto
==============================================================================
--- lldb/trunk/include/lldb/Utility/StringList.h (added)
+++ lldb/trunk/include/lldb/Utility/StringList.h Tue Mar 21 13:25:04 2017
@@ -0,0 +1,138 @@
+//===-- StringList.h --------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef liblldb_StringList_h_
+#define liblldb_StringList_h_
+
+// C Includes
+#include <stdint.h>
+
+// C++ Includes
+#include <string>
+
+// Other libraries and framework includes
+#include "llvm/ADT/StringRef.h"
+
+// Project includes
+#include "lldb/lldb-forward.h"
+
+namespace lldb_private {
+
+class StringList {
+public:
+ StringList();
+
+ StringList(const char *str);
+
+ StringList(const char **strv, int strc);
+
+ virtual ~StringList();
+
+ void AppendString(const std::string &s);
+
+ void AppendString(std::string &&s);
+
+ void AppendString(const char *str);
+
+ void AppendString(const char *str, size_t str_len);
+
+ void AppendString(llvm::StringRef str);
+
+ void AppendList(const char **strv, int strc);
+
+ void AppendList(StringList strings);
+
+ size_t GetSize() const;
+
+ void SetSize(size_t n) { m_strings.resize(n); }
+
+ size_t GetMaxStringLength() const;
+
+ std::string &operator[](size_t idx) {
+ // No bounds checking, verify "idx" is good prior to calling this function
+ return m_strings[idx];
+ }
+
+ const std::string &operator[](size_t idx) const {
+ // No bounds checking, verify "idx" is good prior to calling this function
+ return m_strings[idx];
+ }
+
+ void PopBack() { m_strings.pop_back(); }
+ const char *GetStringAtIndex(size_t idx) const;
+
+ void Join(const char *separator, Stream &strm);
+
+ void Clear();
+
+ void LongestCommonPrefix(std::string &common_prefix);
+
+ void InsertStringAtIndex(size_t idx, const std::string &str);
+
+ void InsertStringAtIndex(size_t idx, std::string &&str);
+
+ void InsertStringAtIndex(size_t id, const char *str);
+
+ void DeleteStringAtIndex(size_t id);
+
+ void RemoveBlankLines();
+
+ size_t SplitIntoLines(const std::string &lines);
+
+ size_t SplitIntoLines(const char *lines, size_t len);
+
+ std::string CopyList(const char *item_preamble = nullptr,
+ const char *items_sep = "\n") const;
+
+ StringList &operator<<(const char *str);
+
+ StringList &operator<<(const std::string &s);
+
+ StringList &operator<<(StringList strings);
+
+ // Copy assignment for a vector of strings
+ StringList &operator=(const std::vector<std::string> &rhs);
+
+ // This string list contains a list of valid auto completion
+ // strings, and the "s" is passed in. "matches" is filled in
+ // with zero or more string values that start with "s", and
+ // the first string to exactly match one of the string
+ // values in this collection, will have "exact_matches_idx"
+ // filled in to match the index, or "exact_matches_idx" will
+ // have SIZE_MAX
+ size_t AutoComplete(llvm::StringRef s, StringList &matches,
+ size_t &exact_matches_idx) const;
+
+ // Dump the StringList to the given lldb_private::Log, `log`, one item per
+ // line.
+ // If given, `name` will be used to identify the start and end of the list in
+ // the output.
+ virtual void LogDump(Log *log, const char *name = nullptr);
+
+ // Static helper to convert an iterable of strings to a StringList, and then
+ // dump it with the semantics of the `LogDump` method.
+ template <typename T>
+ static void LogDump(Log *log, T s_iterable, const char *name = nullptr) {
+ if (!log)
+ return;
+ // Make a copy of the iterable as a StringList
+ StringList l{};
+ for (const auto &s : s_iterable)
+ l << s;
+
+ l.LogDump(log, name);
+ }
+
+private:
+ std::vector<std::string> m_strings;
+};
+
+} // namespace lldb_private
+
+#endif // liblldb_StringList_h_
Modified: lldb/trunk/source/API/SBStringList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBStringList.cpp?rev=298412&r1=298411&r2=298412&view=diff
==============================================================================
--- lldb/trunk/source/API/SBStringList.cpp (original)
+++ lldb/trunk/source/API/SBStringList.cpp Tue Mar 21 13:25:04 2017
@@ -9,7 +9,7 @@
#include "lldb/API/SBStringList.h"
-#include "lldb/Core/StringList.h"
+#include "lldb/Utility/StringList.h"
using namespace lldb;
using namespace lldb_private;
Modified: lldb/trunk/source/Breakpoint/BreakpointOptions.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/BreakpointOptions.cpp?rev=298412&r1=298411&r2=298412&view=diff
==============================================================================
--- lldb/trunk/source/Breakpoint/BreakpointOptions.cpp (original)
+++ lldb/trunk/source/Breakpoint/BreakpointOptions.cpp Tue Mar 21 13:25:04 2017
@@ -14,7 +14,6 @@
#include "lldb/Breakpoint/BreakpointOptions.h"
#include "lldb/Breakpoint/StoppointCallbackContext.h"
-#include "lldb/Core/StringList.h"
#include "lldb/Core/Value.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandReturnObject.h"
@@ -22,6 +21,7 @@
#include "lldb/Target/Target.h"
#include "lldb/Target/ThreadSpec.h"
#include "lldb/Utility/Stream.h"
+#include "lldb/Utility/StringList.h"
#include "llvm/ADT/STLExtras.h"
Modified: lldb/trunk/source/Breakpoint/WatchpointOptions.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/WatchpointOptions.cpp?rev=298412&r1=298411&r2=298412&view=diff
==============================================================================
--- lldb/trunk/source/Breakpoint/WatchpointOptions.cpp (original)
+++ lldb/trunk/source/Breakpoint/WatchpointOptions.cpp Tue Mar 21 13:25:04 2017
@@ -14,12 +14,12 @@
#include "lldb/Breakpoint/WatchpointOptions.h"
#include "lldb/Breakpoint/StoppointCallbackContext.h"
-#include "lldb/Core/StringList.h"
#include "lldb/Core/Value.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/ThreadSpec.h"
#include "lldb/Utility/Stream.h"
+#include "lldb/Utility/StringList.h"
using namespace lldb;
using namespace lldb_private;
Modified: lldb/trunk/source/Commands/CommandObjectCommands.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectCommands.cpp?rev=298412&r1=298411&r2=298412&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectCommands.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectCommands.cpp Tue Mar 21 13:25:04 2017
@@ -17,7 +17,6 @@
#include "CommandObjectHelp.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Core/IOHandler.h"
-#include "lldb/Core/StringList.h"
#include "lldb/Interpreter/Args.h"
#include "lldb/Interpreter/CommandHistory.h"
#include "lldb/Interpreter/CommandInterpreter.h"
@@ -28,6 +27,7 @@
#include "lldb/Interpreter/OptionValueUInt64.h"
#include "lldb/Interpreter/Options.h"
#include "lldb/Interpreter/ScriptInterpreter.h"
+#include "lldb/Utility/StringList.h"
using namespace lldb;
using namespace lldb_private;
Modified: lldb/trunk/source/Commands/CommandObjectType.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectType.cpp?rev=298412&r1=298411&r2=298412&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectType.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectType.cpp Tue Mar 21 13:25:04 2017
@@ -19,7 +19,6 @@
#include "lldb/Core/Debugger.h"
#include "lldb/Core/IOHandler.h"
#include "lldb/Core/State.h"
-#include "lldb/Core/StringList.h"
#include "lldb/DataFormatters/DataVisualization.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandObject.h"
@@ -38,6 +37,7 @@
#include "lldb/Target/ThreadList.h"
#include "lldb/Utility/ConstString.h"
#include "lldb/Utility/RegularExpression.h"
+#include "lldb/Utility/StringList.h"
// Other libraries and framework includes
#include "llvm/ADT/STLExtras.h"
Modified: lldb/trunk/source/Core/ArchSpec.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ArchSpec.cpp?rev=298412&r1=298411&r2=298412&view=diff
==============================================================================
--- lldb/trunk/source/Core/ArchSpec.cpp (original)
+++ lldb/trunk/source/Core/ArchSpec.cpp Tue Mar 21 13:25:04 2017
@@ -24,7 +24,6 @@
// Project includes
#include "Plugins/Process/Utility/ARMDefines.h"
#include "Plugins/Process/Utility/InstructionUtils.h"
-#include "lldb/Core/StringList.h"
#include "lldb/Host/HostInfo.h"
#include "lldb/Target/Platform.h"
#include "lldb/Target/Process.h"
@@ -34,6 +33,7 @@
#include "lldb/Utility/NameMatches.h"
#include "lldb/Utility/RegularExpression.h"
#include "lldb/Utility/SafeMachO.h"
+#include "lldb/Utility/StringList.h"
using namespace lldb;
using namespace lldb_private;
Modified: lldb/trunk/source/Core/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/CMakeLists.txt?rev=298412&r1=298411&r2=298412&view=diff
==============================================================================
--- lldb/trunk/source/Core/CMakeLists.txt (original)
+++ lldb/trunk/source/Core/CMakeLists.txt Tue Mar 21 13:25:04 2017
@@ -33,7 +33,6 @@ add_lldb_library(lldbCore
State.cpp
StreamAsynchronousIO.cpp
StreamFile.cpp
- StringList.cpp
StructuredData.cpp
Timer.cpp
UserSettingsController.cpp
Removed: lldb/trunk/source/Core/StringList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/StringList.cpp?rev=298411&view=auto
==============================================================================
--- lldb/trunk/source/Core/StringList.cpp (original)
+++ lldb/trunk/source/Core/StringList.cpp (removed)
@@ -1,267 +0,0 @@
-//===-- StringList.cpp ------------------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "lldb/Core/StringList.h"
-
-#include "lldb/Host/FileSpec.h"
-#include "lldb/Utility/Log.h"
-#include "lldb/Utility/StreamString.h"
-
-#include <string>
-
-using namespace lldb_private;
-
-StringList::StringList() : m_strings() {}
-
-StringList::StringList(const char *str) : m_strings() {
- if (str)
- m_strings.push_back(str);
-}
-
-StringList::StringList(const char **strv, int strc) : m_strings() {
- for (int i = 0; i < strc; ++i) {
- if (strv[i])
- m_strings.push_back(strv[i]);
- }
-}
-
-StringList::~StringList() {}
-
-void StringList::AppendString(const char *str) {
- if (str)
- m_strings.push_back(str);
-}
-
-void StringList::AppendString(const std::string &s) { m_strings.push_back(s); }
-
-void StringList::AppendString(std::string &&s) { m_strings.push_back(s); }
-
-void StringList::AppendString(const char *str, size_t str_len) {
- if (str)
- m_strings.push_back(std::string(str, str_len));
-}
-
-void StringList::AppendString(llvm::StringRef str) {
- m_strings.push_back(str.str());
-}
-
-void StringList::AppendList(const char **strv, int strc) {
- for (int i = 0; i < strc; ++i) {
- if (strv[i])
- m_strings.push_back(strv[i]);
- }
-}
-
-void StringList::AppendList(StringList strings) {
- size_t len = strings.GetSize();
-
- for (size_t i = 0; i < len; ++i)
- m_strings.push_back(strings.GetStringAtIndex(i));
-}
-
-size_t StringList::GetSize() const { return m_strings.size(); }
-
-size_t StringList::GetMaxStringLength() const {
- size_t max_length = 0;
- for (const auto &s : m_strings) {
- const size_t len = s.size();
- if (max_length < len)
- max_length = len;
- }
- return max_length;
-}
-
-const char *StringList::GetStringAtIndex(size_t idx) const {
- if (idx < m_strings.size())
- return m_strings[idx].c_str();
- return NULL;
-}
-
-void StringList::Join(const char *separator, Stream &strm) {
- size_t size = GetSize();
-
- if (size == 0)
- return;
-
- for (uint32_t i = 0; i < size; ++i) {
- if (i > 0)
- strm.PutCString(separator);
- strm.PutCString(GetStringAtIndex(i));
- }
-}
-
-void StringList::Clear() { m_strings.clear(); }
-
-void StringList::LongestCommonPrefix(std::string &common_prefix) {
- common_prefix.clear();
- if (m_strings.empty())
- return;
-
- auto args = llvm::makeArrayRef(m_strings);
- llvm::StringRef prefix = args.front();
- for (auto arg : args.drop_front()) {
- size_t count = 0;
- for (count = 0; count < std::min(prefix.size(), arg.size()); ++count) {
- if (prefix[count] != arg[count])
- break;
- }
- prefix = prefix.take_front(count);
- }
- common_prefix = prefix;
-}
-
-void StringList::InsertStringAtIndex(size_t idx, const char *str) {
- if (str) {
- if (idx < m_strings.size())
- m_strings.insert(m_strings.begin() + idx, str);
- else
- m_strings.push_back(str);
- }
-}
-
-void StringList::InsertStringAtIndex(size_t idx, const std::string &str) {
- if (idx < m_strings.size())
- m_strings.insert(m_strings.begin() + idx, str);
- else
- m_strings.push_back(str);
-}
-
-void StringList::InsertStringAtIndex(size_t idx, std::string &&str) {
- if (idx < m_strings.size())
- m_strings.insert(m_strings.begin() + idx, str);
- else
- m_strings.push_back(str);
-}
-
-void StringList::DeleteStringAtIndex(size_t idx) {
- if (idx < m_strings.size())
- m_strings.erase(m_strings.begin() + idx);
-}
-
-size_t StringList::SplitIntoLines(const std::string &lines) {
- return SplitIntoLines(lines.c_str(), lines.size());
-}
-
-size_t StringList::SplitIntoLines(const char *lines, size_t len) {
- const size_t orig_size = m_strings.size();
-
- if (len == 0)
- return 0;
-
- const char *k_newline_chars = "\r\n";
- const char *p = lines;
- const char *end = lines + len;
- while (p < end) {
- size_t count = strcspn(p, k_newline_chars);
- if (count == 0) {
- if (p[count] == '\r' || p[count] == '\n')
- m_strings.push_back(std::string());
- else
- break;
- } else {
- if (p + count > end)
- count = end - p;
- m_strings.push_back(std::string(p, count));
- }
- if (p[count] == '\r' && p[count + 1] == '\n')
- count++; // Skip an extra newline char for the DOS newline
- count++; // Skip the newline character
- p += count;
- }
- return m_strings.size() - orig_size;
-}
-
-void StringList::RemoveBlankLines() {
- if (GetSize() == 0)
- return;
-
- size_t idx = 0;
- while (idx < m_strings.size()) {
- if (m_strings[idx].empty())
- DeleteStringAtIndex(idx);
- else
- idx++;
- }
-}
-
-std::string StringList::CopyList(const char *item_preamble,
- const char *items_sep) const {
- StreamString strm;
- for (size_t i = 0; i < GetSize(); i++) {
- if (i && items_sep && items_sep[0])
- strm << items_sep;
- if (item_preamble)
- strm << item_preamble;
- strm << GetStringAtIndex(i);
- }
- return strm.GetString();
-}
-
-StringList &StringList::operator<<(const char *str) {
- AppendString(str);
- return *this;
-}
-
-StringList &StringList::operator<<(const std::string &str) {
- AppendString(str);
- return *this;
-}
-
-StringList &StringList::operator<<(StringList strings) {
- AppendList(strings);
- return *this;
-}
-
-StringList &StringList::operator=(const std::vector<std::string> &rhs) {
- Clear();
- for (const auto &s : rhs)
- m_strings.push_back(s);
-
- return *this;
-}
-
-size_t StringList::AutoComplete(llvm::StringRef s, StringList &matches,
- size_t &exact_idx) const {
- matches.Clear();
- exact_idx = SIZE_MAX;
- if (s.empty()) {
- // No string, so it matches everything
- matches = *this;
- return matches.GetSize();
- }
-
- const size_t s_len = s.size();
- const size_t num_strings = m_strings.size();
-
- for (size_t i = 0; i < num_strings; ++i) {
- if (m_strings[i].find(s) == 0) {
- if (exact_idx == SIZE_MAX && m_strings[i].size() == s_len)
- exact_idx = matches.GetSize();
- matches.AppendString(m_strings[i]);
- }
- }
- return matches.GetSize();
-}
-
-void StringList::LogDump(Log *log, const char *name) {
- if (!log)
- return;
-
- StreamString strm;
- if (name)
- strm.Printf("Begin %s:\n", name);
- for (const auto &s : m_strings) {
- strm.Indent();
- strm.Printf("%s\n", s.c_str());
- }
- if (name)
- strm.Printf("End %s.\n", name);
-
- LLDB_LOGV(log, "{0}", strm.GetData());
-}
Modified: lldb/trunk/source/Host/common/Editline.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/Editline.cpp?rev=298412&r1=298411&r2=298412&view=diff
==============================================================================
--- lldb/trunk/source/Host/common/Editline.cpp (original)
+++ lldb/trunk/source/Host/common/Editline.cpp Tue Mar 21 13:25:04 2017
@@ -11,7 +11,6 @@
#include <iostream>
#include <limits.h>
-#include "lldb/Core/StringList.h"
#include "lldb/Host/ConnectionFileDescriptor.h"
#include "lldb/Host/Editline.h"
#include "lldb/Host/FileSpec.h"
@@ -20,6 +19,7 @@
#include "lldb/Utility/LLDBAssert.h"
#include "lldb/Utility/SelectHelper.h"
#include "lldb/Utility/StreamString.h"
+#include "lldb/Utility/StringList.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Threading.h"
Modified: lldb/trunk/source/Host/common/FileSpec.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/FileSpec.cpp?rev=298412&r1=298411&r2=298412&view=diff
==============================================================================
--- lldb/trunk/source/Host/common/FileSpec.cpp (original)
+++ lldb/trunk/source/Host/common/FileSpec.cpp Tue Mar 21 13:25:04 2017
@@ -16,12 +16,12 @@
#include <pwd.h>
#endif
-#include "lldb/Core/StringList.h"
#include "lldb/Host/FileSpec.h"
#include "lldb/Utility/CleanUp.h"
#include "lldb/Utility/RegularExpression.h"
#include "lldb/Utility/Stream.h"
#include "lldb/Utility/StreamString.h"
+#include "lldb/Utility/StringList.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringRef.h"
Modified: lldb/trunk/source/Interpreter/OptionValue.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/OptionValue.cpp?rev=298412&r1=298411&r2=298412&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/OptionValue.cpp (original)
+++ lldb/trunk/source/Interpreter/OptionValue.cpp Tue Mar 21 13:25:04 2017
@@ -13,8 +13,8 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/StringList.h"
#include "lldb/Interpreter/OptionValues.h"
+#include "lldb/Utility/StringList.h"
using namespace lldb;
using namespace lldb_private;
Modified: lldb/trunk/source/Interpreter/OptionValueBoolean.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/OptionValueBoolean.cpp?rev=298412&r1=298411&r2=298412&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/OptionValueBoolean.cpp (original)
+++ lldb/trunk/source/Interpreter/OptionValueBoolean.cpp Tue Mar 21 13:25:04 2017
@@ -13,10 +13,10 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/StringList.h"
#include "lldb/Host/PosixApi.h"
#include "lldb/Interpreter/Args.h"
#include "lldb/Utility/Stream.h"
+#include "lldb/Utility/StringList.h"
#include "llvm/ADT/STLExtras.h"
using namespace lldb;
Modified: lldb/trunk/source/Interpreter/OptionValueChar.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/OptionValueChar.cpp?rev=298412&r1=298411&r2=298412&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/OptionValueChar.cpp (original)
+++ lldb/trunk/source/Interpreter/OptionValueChar.cpp Tue Mar 21 13:25:04 2017
@@ -13,9 +13,9 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/StringList.h"
#include "lldb/Interpreter/Args.h"
#include "lldb/Utility/Stream.h"
+#include "lldb/Utility/StringList.h"
#include "llvm/ADT/STLExtras.h"
using namespace lldb;
Modified: lldb/trunk/source/Interpreter/OptionValueEnumeration.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/OptionValueEnumeration.cpp?rev=298412&r1=298411&r2=298412&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/OptionValueEnumeration.cpp (original)
+++ lldb/trunk/source/Interpreter/OptionValueEnumeration.cpp Tue Mar 21 13:25:04 2017
@@ -13,7 +13,7 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/StringList.h"
+#include "lldb/Utility/StringList.h"
using namespace lldb;
using namespace lldb_private;
Modified: lldb/trunk/source/Interpreter/OptionValueFormatEntity.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/OptionValueFormatEntity.cpp?rev=298412&r1=298411&r2=298412&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/OptionValueFormatEntity.cpp (original)
+++ lldb/trunk/source/Interpreter/OptionValueFormatEntity.cpp Tue Mar 21 13:25:04 2017
@@ -14,9 +14,9 @@
// Other libraries and framework includes
// Project includes
#include "lldb/Core/Module.h"
-#include "lldb/Core/StringList.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Utility/Stream.h"
+#include "lldb/Utility/StringList.h"
using namespace lldb;
using namespace lldb_private;
Modified: lldb/trunk/source/Interpreter/OptionValueProperties.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/OptionValueProperties.cpp?rev=298412&r1=298411&r2=298412&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/OptionValueProperties.cpp (original)
+++ lldb/trunk/source/Interpreter/OptionValueProperties.cpp Tue Mar 21 13:25:04 2017
@@ -15,12 +15,12 @@
// Project includes
#include "lldb/Utility/Flags.h"
-#include "lldb/Core/StringList.h"
#include "lldb/Core/UserSettingsController.h"
#include "lldb/Interpreter/Args.h"
#include "lldb/Interpreter/OptionValues.h"
#include "lldb/Interpreter/Property.h"
#include "lldb/Utility/Stream.h"
+#include "lldb/Utility/StringList.h"
using namespace lldb;
using namespace lldb_private;
Modified: lldb/trunk/source/Interpreter/OptionValueUUID.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/OptionValueUUID.cpp?rev=298412&r1=298411&r2=298412&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/OptionValueUUID.cpp (original)
+++ lldb/trunk/source/Interpreter/OptionValueUUID.cpp Tue Mar 21 13:25:04 2017
@@ -14,9 +14,9 @@
// Other libraries and framework includes
// Project includes
#include "lldb/Core/Module.h"
-#include "lldb/Core/StringList.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Utility/Stream.h"
+#include "lldb/Utility/StringList.h"
using namespace lldb;
using namespace lldb_private;
Modified: lldb/trunk/source/Interpreter/ScriptInterpreter.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/ScriptInterpreter.cpp?rev=298412&r1=298411&r2=298412&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/ScriptInterpreter.cpp (original)
+++ lldb/trunk/source/Interpreter/ScriptInterpreter.cpp Tue Mar 21 13:25:04 2017
@@ -13,11 +13,11 @@
#include <stdlib.h>
#include <string>
-#include "lldb/Core/StringList.h"
#include "lldb/Host/PseudoTerminal.h"
#include "lldb/Interpreter/CommandReturnObject.h"
#include "lldb/Utility/Error.h"
#include "lldb/Utility/Stream.h"
+#include "lldb/Utility/StringList.h"
using namespace lldb;
using namespace lldb_private;
Modified: lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp?rev=298412&r1=298411&r2=298412&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp (original)
+++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp Tue Mar 21 13:25:04 2017
@@ -71,7 +71,6 @@
#include "lldb/Core/Disassembler.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/StreamFile.h"
-#include "lldb/Core/StringList.h"
#include "lldb/Expression/IRDynamicChecks.h"
#include "lldb/Expression/IRExecutionUnit.h"
#include "lldb/Expression/IRInterpreter.h"
@@ -90,6 +89,7 @@
#include "lldb/Utility/Log.h"
#include "lldb/Utility/Stream.h"
#include "lldb/Utility/StreamString.h"
+#include "lldb/Utility/StringList.h"
using namespace clang;
using namespace llvm;
Modified: lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.h?rev=298412&r1=298411&r2=298412&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.h (original)
+++ lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.h Tue Mar 21 13:25:04 2017
@@ -19,7 +19,6 @@
// Other libraries and framework includes
#include "lldb/Core/ArchSpec.h"
#include "lldb/Core/Broadcaster.h"
-#include "lldb/Core/StringList.h"
#include "lldb/Core/ThreadSafeValue.h"
#include "lldb/Host/HostThread.h"
#include "lldb/Target/Process.h"
@@ -27,6 +26,7 @@
#include "lldb/Utility/ConstString.h"
#include "lldb/Utility/Error.h"
#include "lldb/Utility/StreamString.h"
+#include "lldb/Utility/StringList.h"
#include "CommunicationKDP.h"
Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h?rev=298412&r1=298411&r2=298412&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h Tue Mar 21 13:25:04 2017
@@ -24,7 +24,6 @@
#include "lldb/Core/Broadcaster.h"
#include "lldb/Core/LoadedModuleInfoList.h"
#include "lldb/Core/ModuleSpec.h"
-#include "lldb/Core/StringList.h"
#include "lldb/Core/StructuredData.h"
#include "lldb/Core/ThreadSafeValue.h"
#include "lldb/Host/HostThread.h"
@@ -34,6 +33,7 @@
#include "lldb/Utility/Error.h"
#include "lldb/Utility/StreamString.h"
#include "lldb/Utility/StringExtractor.h"
+#include "lldb/Utility/StringList.h"
#include "lldb/lldb-private-forward.h"
#include "GDBRemoteCommunicationClient.h"
Modified: lldb/trunk/source/Plugins/ScriptInterpreter/None/ScriptInterpreterNone.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ScriptInterpreter/None/ScriptInterpreterNone.cpp?rev=298412&r1=298411&r2=298412&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ScriptInterpreter/None/ScriptInterpreterNone.cpp (original)
+++ lldb/trunk/source/Plugins/ScriptInterpreter/None/ScriptInterpreterNone.cpp Tue Mar 21 13:25:04 2017
@@ -11,9 +11,9 @@
#include "lldb/Core/Debugger.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/StreamFile.h"
-#include "lldb/Core/StringList.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Utility/Stream.h"
+#include "lldb/Utility/StringList.h"
#include "llvm/Support/Threading.h"
Modified: lldb/trunk/source/Utility/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/CMakeLists.txt?rev=298412&r1=298411&r2=298412&view=diff
==============================================================================
--- lldb/trunk/source/Utility/CMakeLists.txt (original)
+++ lldb/trunk/source/Utility/CMakeLists.txt Tue Mar 21 13:25:04 2017
@@ -24,6 +24,7 @@ add_lldb_library(lldbUtility
StringExtractor.cpp
StringExtractorGDBRemote.cpp
StringLexer.cpp
+ StringList.cpp
TaskPool.cpp
TildeExpressionResolver.cpp
UserID.cpp
Added: lldb/trunk/source/Utility/StringList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/StringList.cpp?rev=298412&view=auto
==============================================================================
--- lldb/trunk/source/Utility/StringList.cpp (added)
+++ lldb/trunk/source/Utility/StringList.cpp Tue Mar 21 13:25:04 2017
@@ -0,0 +1,264 @@
+//===-- StringList.cpp ------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "lldb/Utility/StringList.h"
+
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/StreamString.h"
+
+#include <string>
+
+using namespace lldb_private;
+
+StringList::StringList() : m_strings() {}
+
+StringList::StringList(const char *str) : m_strings() {
+ if (str)
+ m_strings.push_back(str);
+}
+
+StringList::StringList(const char **strv, int strc) : m_strings() {
+ for (int i = 0; i < strc; ++i) {
+ if (strv[i])
+ m_strings.push_back(strv[i]);
+ }
+}
+
+StringList::~StringList() {}
+
+void StringList::AppendString(const char *str) {
+ if (str)
+ m_strings.push_back(str);
+}
+
+void StringList::AppendString(const std::string &s) { m_strings.push_back(s); }
+
+void StringList::AppendString(std::string &&s) { m_strings.push_back(s); }
+
+void StringList::AppendString(const char *str, size_t str_len) {
+ if (str)
+ m_strings.push_back(std::string(str, str_len));
+}
+
+void StringList::AppendString(llvm::StringRef str) {
+ m_strings.push_back(str.str());
+}
+
+void StringList::AppendList(const char **strv, int strc) {
+ for (int i = 0; i < strc; ++i) {
+ if (strv[i])
+ m_strings.push_back(strv[i]);
+ }
+}
+
+void StringList::AppendList(StringList strings) {
+ size_t len = strings.GetSize();
+
+ for (size_t i = 0; i < len; ++i)
+ m_strings.push_back(strings.GetStringAtIndex(i));
+}
+
+size_t StringList::GetSize() const { return m_strings.size(); }
+
+size_t StringList::GetMaxStringLength() const {
+ size_t max_length = 0;
+ for (const auto &s : m_strings) {
+ const size_t len = s.size();
+ if (max_length < len)
+ max_length = len;
+ }
+ return max_length;
+}
+
+const char *StringList::GetStringAtIndex(size_t idx) const {
+ if (idx < m_strings.size())
+ return m_strings[idx].c_str();
+ return NULL;
+}
+
+void StringList::Join(const char *separator, Stream &strm) {
+ size_t size = GetSize();
+
+ if (size == 0)
+ return;
+
+ for (uint32_t i = 0; i < size; ++i) {
+ if (i > 0)
+ strm.PutCString(separator);
+ strm.PutCString(GetStringAtIndex(i));
+ }
+}
+
+void StringList::Clear() { m_strings.clear(); }
+
+void StringList::LongestCommonPrefix(std::string &common_prefix) {
+ common_prefix.clear();
+ if (m_strings.empty())
+ return;
+
+ auto args = llvm::makeArrayRef(m_strings);
+ llvm::StringRef prefix = args.front();
+ for (auto arg : args.drop_front()) {
+ size_t count = 0;
+ for (count = 0; count < std::min(prefix.size(), arg.size()); ++count) {
+ if (prefix[count] != arg[count])
+ break;
+ }
+ prefix = prefix.take_front(count);
+ }
+ common_prefix = prefix;
+}
+
+void StringList::InsertStringAtIndex(size_t idx, const char *str) {
+ if (str) {
+ if (idx < m_strings.size())
+ m_strings.insert(m_strings.begin() + idx, str);
+ else
+ m_strings.push_back(str);
+ }
+}
+
+void StringList::InsertStringAtIndex(size_t idx, const std::string &str) {
+ if (idx < m_strings.size())
+ m_strings.insert(m_strings.begin() + idx, str);
+ else
+ m_strings.push_back(str);
+}
+
+void StringList::InsertStringAtIndex(size_t idx, std::string &&str) {
+ if (idx < m_strings.size())
+ m_strings.insert(m_strings.begin() + idx, str);
+ else
+ m_strings.push_back(str);
+}
+
+void StringList::DeleteStringAtIndex(size_t idx) {
+ if (idx < m_strings.size())
+ m_strings.erase(m_strings.begin() + idx);
+}
+
+size_t StringList::SplitIntoLines(const std::string &lines) {
+ return SplitIntoLines(lines.c_str(), lines.size());
+}
+
+size_t StringList::SplitIntoLines(const char *lines, size_t len) {
+ const size_t orig_size = m_strings.size();
+
+ if (len == 0)
+ return 0;
+
+ const char *k_newline_chars = "\r\n";
+ const char *p = lines;
+ const char *end = lines + len;
+ while (p < end) {
+ size_t count = strcspn(p, k_newline_chars);
+ if (count == 0) {
+ if (p[count] == '\r' || p[count] == '\n')
+ m_strings.push_back(std::string());
+ else
+ break;
+ } else {
+ if (p + count > end)
+ count = end - p;
+ m_strings.push_back(std::string(p, count));
+ }
+ if (p[count] == '\r' && p[count + 1] == '\n')
+ count++; // Skip an extra newline char for the DOS newline
+ count++; // Skip the newline character
+ p += count;
+ }
+ return m_strings.size() - orig_size;
+}
+
+void StringList::RemoveBlankLines() {
+ if (GetSize() == 0)
+ return;
+
+ size_t idx = 0;
+ while (idx < m_strings.size()) {
+ if (m_strings[idx].empty())
+ DeleteStringAtIndex(idx);
+ else
+ idx++;
+ }
+}
+
+std::string StringList::CopyList(const char *item_preamble,
+ const char *items_sep) const {
+ StreamString strm;
+ for (size_t i = 0; i < GetSize(); i++) {
+ if (i && items_sep && items_sep[0])
+ strm << items_sep;
+ if (item_preamble)
+ strm << item_preamble;
+ strm << GetStringAtIndex(i);
+ }
+ return strm.GetString();
+}
+
+StringList &StringList::operator<<(const char *str) {
+ AppendString(str);
+ return *this;
+}
+
+StringList &StringList::operator<<(const std::string &str) {
+ AppendString(str);
+ return *this;
+}
+
+StringList &StringList::operator<<(StringList strings) {
+ AppendList(strings);
+ return *this;
+}
+
+StringList &StringList::operator=(const std::vector<std::string> &rhs) {
+ m_strings.assign(rhs.begin(), rhs.end());
+
+ return *this;
+}
+
+size_t StringList::AutoComplete(llvm::StringRef s, StringList &matches,
+ size_t &exact_idx) const {
+ matches.Clear();
+ exact_idx = SIZE_MAX;
+ if (s.empty()) {
+ // No string, so it matches everything
+ matches = *this;
+ return matches.GetSize();
+ }
+
+ const size_t s_len = s.size();
+ const size_t num_strings = m_strings.size();
+
+ for (size_t i = 0; i < num_strings; ++i) {
+ if (m_strings[i].find(s) == 0) {
+ if (exact_idx == SIZE_MAX && m_strings[i].size() == s_len)
+ exact_idx = matches.GetSize();
+ matches.AppendString(m_strings[i]);
+ }
+ }
+ return matches.GetSize();
+}
+
+void StringList::LogDump(Log *log, const char *name) {
+ if (!log)
+ return;
+
+ StreamString strm;
+ if (name)
+ strm.Printf("Begin %s:\n", name);
+ for (const auto &s : m_strings) {
+ strm.Indent();
+ strm.Printf("%s\n", s.c_str());
+ }
+ if (name)
+ strm.Printf("End %s.\n", name);
+
+ LLDB_LOGV(log, "{0}", strm.GetData());
+}
Modified: lldb/trunk/unittests/Editline/EditlineTest.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Editline/EditlineTest.cpp?rev=298412&r1=298411&r2=298412&view=diff
==============================================================================
--- lldb/trunk/unittests/Editline/EditlineTest.cpp (original)
+++ lldb/trunk/unittests/Editline/EditlineTest.cpp Tue Mar 21 13:25:04 2017
@@ -19,11 +19,11 @@
#include "gtest/gtest.h"
-#include "lldb/Core/StringList.h"
#include "lldb/Host/Editline.h"
#include "lldb/Host/Pipe.h"
#include "lldb/Host/PseudoTerminal.h"
#include "lldb/Utility/Error.h"
+#include "lldb/Utility/StringList.h"
namespace {
const size_t TIMEOUT_MILLIS = 5000;
Modified: lldb/trunk/unittests/Interpreter/TestCompletion.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Interpreter/TestCompletion.cpp?rev=298412&r1=298411&r2=298412&view=diff
==============================================================================
--- lldb/trunk/unittests/Interpreter/TestCompletion.cpp (original)
+++ lldb/trunk/unittests/Interpreter/TestCompletion.cpp Tue Mar 21 13:25:04 2017
@@ -9,8 +9,8 @@
#include "gtest/gtest.h"
-#include "lldb/Core/StringList.h"
#include "lldb/Interpreter/CommandCompletions.h"
+#include "lldb/Utility/StringList.h"
#include "lldb/Utility/TildeExpressionResolver.h"
#include "llvm/ADT/SmallString.h"
More information about the lldb-commits
mailing list