From 4b3c0fd5da2ef595ea8e015a8e38a48890057eed Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Wed, 21 Aug 2019 00:50:46 +0000 Subject: [PATCH] [NFC] Remove lldb_utility namespace. While generating the Doxygen I noticed this lone namespace that has one class and one function in it. This moves them into lldb_private. llvm-svn: 369485 --- .../lldb/DataFormatters/FormattersContainer.h | 2 +- lldb/include/lldb/Utility/AnsiTerminal.h | 4 +-- lldb/include/lldb/Utility/StringLexer.h | 4 +-- lldb/source/Core/Debugger.cpp | 4 +-- lldb/source/Core/Highlighter.cpp | 5 +-- lldb/source/Core/ValueObject.cpp | 15 ++++----- .../AppleObjCTypeEncodingParser.cpp | 37 ++++++++-------------- .../AppleObjCRuntime/AppleObjCTypeEncodingParser.h | 32 +++++++------------ lldb/source/Utility/StringLexer.cpp | 2 +- lldb/unittests/Utility/AnsiTerminalTest.cpp | 2 +- lldb/unittests/Utility/StringLexerTest.cpp | 2 +- 11 files changed, 44 insertions(+), 65 deletions(-) diff --git a/lldb/include/lldb/DataFormatters/FormattersContainer.h b/lldb/include/lldb/DataFormatters/FormattersContainer.h index 9d7d373..3dcae64 100644 --- a/lldb/include/lldb/DataFormatters/FormattersContainer.h +++ b/lldb/include/lldb/DataFormatters/FormattersContainer.h @@ -47,7 +47,7 @@ static inline ConstString GetValidTypeName_Impl(ConstString type) { return type; std::string type_cstr(type.AsCString()); - lldb_utility::StringLexer type_lexer(type_cstr); + StringLexer type_lexer(type_cstr); type_lexer.AdvanceIf("class "); type_lexer.AdvanceIf("enum "); diff --git a/lldb/include/lldb/Utility/AnsiTerminal.h b/lldb/include/lldb/Utility/AnsiTerminal.h index 1473c60..21375e3 100644 --- a/lldb/include/lldb/Utility/AnsiTerminal.h +++ b/lldb/include/lldb/Utility/AnsiTerminal.h @@ -55,7 +55,7 @@ #include -namespace lldb_utility { +namespace lldb_private { namespace ansi { @@ -137,4 +137,4 @@ inline std::string FormatAnsiTerminalCodes(llvm::StringRef format, return fmt; } } -} +} // namespace lldb_private diff --git a/lldb/include/lldb/Utility/StringLexer.h b/lldb/include/lldb/Utility/StringLexer.h index d9806c1..533fd4f 100644 --- a/lldb/include/lldb/Utility/StringLexer.h +++ b/lldb/include/lldb/Utility/StringLexer.h @@ -1,4 +1,4 @@ -//===--------------------- StringLexer.h ------------------------*- C++ -*-===// +//===-- StringLexer.h -------------------------------------------*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -13,7 +13,7 @@ #include #include -namespace lldb_utility { +namespace lldb_private { class StringLexer { public: diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp index 673de95..e3cd18a 100644 --- a/lldb/source/Core/Debugger.cpp +++ b/lldb/source/Core/Debugger.cpp @@ -270,7 +270,7 @@ Status Debugger::SetPropertyValue(const ExecutionContext *exe_ctx, // FIXME it would be nice to have "on-change" callbacks for properties if (property_path == g_debugger_properties[ePropertyPrompt].name) { llvm::StringRef new_prompt = GetPrompt(); - std::string str = lldb_utility::ansi::FormatAnsiTerminalCodes( + std::string str = lldb_private::ansi::FormatAnsiTerminalCodes( new_prompt, GetUseColor()); if (str.length()) new_prompt = str; @@ -345,7 +345,7 @@ void Debugger::SetPrompt(llvm::StringRef p) { m_collection_sp->SetPropertyAtIndexAsString(nullptr, idx, p); llvm::StringRef new_prompt = GetPrompt(); std::string str = - lldb_utility::ansi::FormatAnsiTerminalCodes(new_prompt, GetUseColor()); + lldb_private::ansi::FormatAnsiTerminalCodes(new_prompt, GetUseColor()); if (str.length()) new_prompt = str; GetCommandInterpreter().UpdatePrompt(new_prompt); diff --git a/lldb/source/Core/Highlighter.cpp b/lldb/source/Core/Highlighter.cpp index 0b0aa96..c3c614a 100644 --- a/lldb/source/Core/Highlighter.cpp +++ b/lldb/source/Core/Highlighter.cpp @@ -13,6 +13,7 @@ #include "lldb/Utility/StreamString.h" using namespace lldb_private; +using namespace lldb_private::ansi; void HighlightStyle::ColorStyle::Apply(Stream &s, llvm::StringRef value) const { s << m_prefix << value << m_suffix; @@ -20,8 +21,8 @@ void HighlightStyle::ColorStyle::Apply(Stream &s, llvm::StringRef value) const { void HighlightStyle::ColorStyle::Set(llvm::StringRef prefix, llvm::StringRef suffix) { - m_prefix = lldb_utility::ansi::FormatAnsiTerminalCodes(prefix); - m_suffix = lldb_utility::ansi::FormatAnsiTerminalCodes(suffix); + m_prefix = FormatAnsiTerminalCodes(prefix); + m_suffix = FormatAnsiTerminalCodes(suffix); } void DefaultHighlighter::Highlight(const HighlightStyle &options, diff --git a/lldb/source/Core/ValueObject.cpp b/lldb/source/Core/ValueObject.cpp index 24e0456..74176ee 100644 --- a/lldb/source/Core/ValueObject.cpp +++ b/lldb/source/Core/ValueObject.cpp @@ -73,7 +73,6 @@ class SymbolContextScope; using namespace lldb; using namespace lldb_private; -using namespace lldb_utility; static user_id_t g_value_obj_uid = 0; @@ -3301,32 +3300,32 @@ lldb::ValueObjectSP ValueObjectManager::GetSP() { lldb::ProcessSP process_sp = GetProcessSP(); if (!process_sp) return lldb::ValueObjectSP(); - + const uint32_t current_stop_id = process_sp->GetLastNaturalStopID(); if (current_stop_id == m_stop_id) return m_user_valobj_sp; - + m_stop_id = current_stop_id; - + if (!m_root_valobj_sp) { m_user_valobj_sp.reset(); return m_root_valobj_sp; } - + m_user_valobj_sp = m_root_valobj_sp; - + if (m_use_dynamic != lldb::eNoDynamicValues) { lldb::ValueObjectSP dynamic_sp = m_user_valobj_sp->GetDynamicValue(m_use_dynamic); if (dynamic_sp) m_user_valobj_sp = dynamic_sp; } - + if (m_use_synthetic) { lldb::ValueObjectSP synthetic_sp = m_user_valobj_sp->GetSyntheticValue(m_use_synthetic); if (synthetic_sp) m_user_valobj_sp = synthetic_sp; } - + return m_user_valobj_sp; } diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp index 2bfe7ad..6402e80 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp @@ -18,7 +18,6 @@ #include using namespace lldb_private; -using namespace lldb_utility; AppleObjCTypeEncodingParser::AppleObjCTypeEncodingParser( ObjCLanguageRuntime &runtime) @@ -32,16 +31,14 @@ AppleObjCTypeEncodingParser::AppleObjCTypeEncodingParser( .c_str())); } -std::string -AppleObjCTypeEncodingParser::ReadStructName(lldb_utility::StringLexer &type) { +std::string AppleObjCTypeEncodingParser::ReadStructName(StringLexer &type) { StreamString buffer; while (type.HasAtLeast(1) && type.Peek() != '=') buffer.Printf("%c", type.Next()); return buffer.GetString(); } -std::string -AppleObjCTypeEncodingParser::ReadQuotedString(lldb_utility::StringLexer &type) { +std::string AppleObjCTypeEncodingParser::ReadQuotedString(StringLexer &type) { StreamString buffer; while (type.HasAtLeast(1) && type.Peek() != '"') buffer.Printf("%c", type.Next()); @@ -51,8 +48,7 @@ AppleObjCTypeEncodingParser::ReadQuotedString(lldb_utility::StringLexer &type) { return buffer.GetString(); } -uint32_t -AppleObjCTypeEncodingParser::ReadNumber(lldb_utility::StringLexer &type) { +uint32_t AppleObjCTypeEncodingParser::ReadNumber(StringLexer &type) { uint32_t total = 0; while (type.HasAtLeast(1) && isdigit(type.Peek())) total = 10 * total + (type.Next() - '0'); @@ -68,7 +64,7 @@ AppleObjCTypeEncodingParser::StructElement::StructElement() AppleObjCTypeEncodingParser::StructElement AppleObjCTypeEncodingParser::ReadStructElement(clang::ASTContext &ast_ctx, - lldb_utility::StringLexer &type, + StringLexer &type, bool for_expression) { StructElement retval; if (type.NextIf('"')) @@ -81,25 +77,21 @@ AppleObjCTypeEncodingParser::ReadStructElement(clang::ASTContext &ast_ctx, return retval; } -clang::QualType -AppleObjCTypeEncodingParser::BuildStruct(clang::ASTContext &ast_ctx, - lldb_utility::StringLexer &type, - bool for_expression) { +clang::QualType AppleObjCTypeEncodingParser::BuildStruct( + clang::ASTContext &ast_ctx, StringLexer &type, bool for_expression) { return BuildAggregate(ast_ctx, type, for_expression, '{', '}', clang::TTK_Struct); } -clang::QualType -AppleObjCTypeEncodingParser::BuildUnion(clang::ASTContext &ast_ctx, - lldb_utility::StringLexer &type, - bool for_expression) { +clang::QualType AppleObjCTypeEncodingParser::BuildUnion( + clang::ASTContext &ast_ctx, StringLexer &type, bool for_expression) { return BuildAggregate(ast_ctx, type, for_expression, '(', ')', clang::TTK_Union); } clang::QualType AppleObjCTypeEncodingParser::BuildAggregate( - clang::ASTContext &ast_ctx, lldb_utility::StringLexer &type, - bool for_expression, char opener, char closer, uint32_t kind) { + clang::ASTContext &ast_ctx, StringLexer &type, bool for_expression, + char opener, char closer, uint32_t kind) { if (!type.NextIf(opener)) return clang::QualType(); std::string name(ReadStructName(type)); @@ -159,10 +151,8 @@ clang::QualType AppleObjCTypeEncodingParser::BuildAggregate( return ClangUtil::GetQualType(union_type); } -clang::QualType -AppleObjCTypeEncodingParser::BuildArray(clang::ASTContext &ast_ctx, - lldb_utility::StringLexer &type, - bool for_expression) { +clang::QualType AppleObjCTypeEncodingParser::BuildArray( + clang::ASTContext &ast_ctx, StringLexer &type, bool for_expression) { if (!type.NextIf('[')) return clang::QualType(); uint32_t size = ReadNumber(type); @@ -185,8 +175,7 @@ AppleObjCTypeEncodingParser::BuildArray(clang::ASTContext &ast_ctx, // consume but ignore the type info and always return an 'id'; if anything, // dynamic typing will resolve things for us anyway clang::QualType AppleObjCTypeEncodingParser::BuildObjCObjectPointerType( - clang::ASTContext &ast_ctx, lldb_utility::StringLexer &type, - bool for_expression) { + clang::ASTContext &ast_ctx, StringLexer &type, bool for_expression) { if (!type.NextIf('@')) return clang::QualType(); diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.h b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.h index e576e8f..590bc4b 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.h +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.h @@ -15,12 +15,8 @@ #include "Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h" -namespace lldb_utility { -class StringLexer; -} - namespace lldb_private { - +class StringLexer; class AppleObjCTypeEncodingParser : public ObjCLanguageRuntime::EncodingToType { public: AppleObjCTypeEncodingParser(ObjCLanguageRuntime &runtime); @@ -39,41 +35,35 @@ private: ~StructElement() = default; }; - clang::QualType BuildType(clang::ASTContext &ast_ctx, - lldb_utility::StringLexer &type, + clang::QualType BuildType(clang::ASTContext &ast_ctx, StringLexer &type, bool for_expression, uint32_t *bitfield_bit_size = nullptr); - clang::QualType BuildStruct(clang::ASTContext &ast_ctx, - lldb_utility::StringLexer &type, + clang::QualType BuildStruct(clang::ASTContext &ast_ctx, StringLexer &type, bool for_expression); - clang::QualType BuildAggregate(clang::ASTContext &ast_ctx, - lldb_utility::StringLexer &type, + clang::QualType BuildAggregate(clang::ASTContext &ast_ctx, StringLexer &type, bool for_expression, char opener, char closer, uint32_t kind); - clang::QualType BuildUnion(clang::ASTContext &ast_ctx, - lldb_utility::StringLexer &type, + clang::QualType BuildUnion(clang::ASTContext &ast_ctx, StringLexer &type, bool for_expression); - clang::QualType BuildArray(clang::ASTContext &ast_ctx, - lldb_utility::StringLexer &type, + clang::QualType BuildArray(clang::ASTContext &ast_ctx, StringLexer &type, bool for_expression); - std::string ReadStructName(lldb_utility::StringLexer &type); + std::string ReadStructName(StringLexer &type); - StructElement ReadStructElement(clang::ASTContext &ast_ctx, - lldb_utility::StringLexer &type, + StructElement ReadStructElement(clang::ASTContext &ast_ctx, StringLexer &type, bool for_expression); clang::QualType BuildObjCObjectPointerType(clang::ASTContext &ast_ctx, - lldb_utility::StringLexer &type, + StringLexer &type, bool for_expression); - uint32_t ReadNumber(lldb_utility::StringLexer &type); + uint32_t ReadNumber(StringLexer &type); - std::string ReadQuotedString(lldb_utility::StringLexer &type); + std::string ReadQuotedString(StringLexer &type); ObjCLanguageRuntime &m_runtime; }; diff --git a/lldb/source/Utility/StringLexer.cpp b/lldb/source/Utility/StringLexer.cpp index 958a958..c357cb0 100644 --- a/lldb/source/Utility/StringLexer.cpp +++ b/lldb/source/Utility/StringLexer.cpp @@ -11,7 +11,7 @@ #include #include -using namespace lldb_utility; +using namespace lldb_private; StringLexer::StringLexer(std::string s) : m_data(s), m_position(0) {} diff --git a/lldb/unittests/Utility/AnsiTerminalTest.cpp b/lldb/unittests/Utility/AnsiTerminalTest.cpp index 5982825..5361b0b 100644 --- a/lldb/unittests/Utility/AnsiTerminalTest.cpp +++ b/lldb/unittests/Utility/AnsiTerminalTest.cpp @@ -10,7 +10,7 @@ #include "lldb/Utility/AnsiTerminal.h" -using namespace lldb_utility; +using namespace lldb_private; TEST(AnsiTerminal, Empty) { EXPECT_EQ("", ansi::FormatAnsiTerminalCodes("")); } diff --git a/lldb/unittests/Utility/StringLexerTest.cpp b/lldb/unittests/Utility/StringLexerTest.cpp index b68dc5e..1d8c918 100644 --- a/lldb/unittests/Utility/StringLexerTest.cpp +++ b/lldb/unittests/Utility/StringLexerTest.cpp @@ -9,7 +9,7 @@ #include "lldb/Utility/StringLexer.h" #include "gtest/gtest.h" -using namespace lldb_utility; +using namespace lldb_private; TEST(StringLexerTest, GetUnlexed) { StringLexer l("foo"); -- 2.7.4