diff --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp index 8829a55d57a49..af62d4e02eb10 100644 --- a/lldb/source/API/SBTarget.cpp +++ b/lldb/source/API/SBTarget.cpp @@ -73,9 +73,7 @@ using namespace lldb_private; #define DEFAULT_DISASM_BYTE_SIZE 32 -namespace { - -Status AttachToProcess(ProcessAttachInfo &attach_info, Target &target) { +static Status AttachToProcess(ProcessAttachInfo &attach_info, Target &target) { std::lock_guard guard(target.GetAPIMutex()); auto process_sp = target.GetProcessSP(); @@ -94,8 +92,6 @@ Status AttachToProcess(ProcessAttachInfo &attach_info, Target &target) { return target.Attach(attach_info, nullptr); } -} // namespace - // SBTarget constructor SBTarget::SBTarget() : m_opaque_sp() { LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBTarget); diff --git a/lldb/source/Breakpoint/Breakpoint.cpp b/lldb/source/Breakpoint/Breakpoint.cpp index 8d5d5a31337c1..c644463719d43 100644 --- a/lldb/source/Breakpoint/Breakpoint.cpp +++ b/lldb/source/Breakpoint/Breakpoint.cpp @@ -602,7 +602,6 @@ void Breakpoint::ModulesChanged(ModuleList &module_list, bool load, } } -namespace { static bool SymbolContextsMightBeEquivalent(SymbolContext &old_sc, SymbolContext &new_sc) { bool equivalent_scs = false; @@ -640,7 +639,6 @@ static bool SymbolContextsMightBeEquivalent(SymbolContext &old_sc, } return equivalent_scs; } -} // anonymous namespace void Breakpoint::ModuleReplaced(ModuleSP old_module_sp, ModuleSP new_module_sp) { diff --git a/lldb/source/Core/PluginManager.cpp b/lldb/source/Core/PluginManager.cpp index 012143576e527..c0669927b6363 100644 --- a/lldb/source/Core/PluginManager.cpp +++ b/lldb/source/Core/PluginManager.cpp @@ -1435,8 +1435,9 @@ namespace { typedef lldb::OptionValuePropertiesSP GetDebuggerPropertyForPluginsPtr(Debugger &, ConstString, ConstString, bool can_create); +} -lldb::OptionValuePropertiesSP +static lldb::OptionValuePropertiesSP GetSettingForPlugin(Debugger &debugger, ConstString setting_name, ConstString plugin_type_name, GetDebuggerPropertyForPluginsPtr get_debugger_property = @@ -1452,13 +1453,13 @@ GetSettingForPlugin(Debugger &debugger, ConstString setting_name, return properties_sp; } -bool CreateSettingForPlugin( - Debugger &debugger, ConstString plugin_type_name, - ConstString plugin_type_desc, - const lldb::OptionValuePropertiesSP &properties_sp, ConstString description, - bool is_global_property, - GetDebuggerPropertyForPluginsPtr get_debugger_property = - GetDebuggerPropertyForPlugins) { +static bool +CreateSettingForPlugin(Debugger &debugger, ConstString plugin_type_name, + ConstString plugin_type_desc, + const lldb::OptionValuePropertiesSP &properties_sp, + ConstString description, bool is_global_property, + GetDebuggerPropertyForPluginsPtr get_debugger_property = + GetDebuggerPropertyForPlugins) { if (properties_sp) { lldb::OptionValuePropertiesSP plugin_type_properties_sp( get_debugger_property(debugger, plugin_type_name, plugin_type_desc, @@ -1473,14 +1474,12 @@ bool CreateSettingForPlugin( return false; } -const char *kDynamicLoaderPluginName("dynamic-loader"); -const char *kPlatformPluginName("platform"); -const char *kProcessPluginName("process"); -const char *kSymbolFilePluginName("symbol-file"); -const char *kJITLoaderPluginName("jit-loader"); -const char *kStructuredDataPluginName("structured-data"); - -} // anonymous namespace +static const char *kDynamicLoaderPluginName("dynamic-loader"); +static const char *kPlatformPluginName("platform"); +static const char *kProcessPluginName("process"); +static const char *kSymbolFilePluginName("symbol-file"); +static const char *kJITLoaderPluginName("jit-loader"); +static const char *kStructuredDataPluginName("structured-data"); lldb::OptionValuePropertiesSP PluginManager::GetSettingForDynamicLoaderPlugin(Debugger &debugger, diff --git a/lldb/source/Host/common/LockFileBase.cpp b/lldb/source/Host/common/LockFileBase.cpp index d4cd8f7ffed16..1c0de9e04e29f 100644 --- a/lldb/source/Host/common/LockFileBase.cpp +++ b/lldb/source/Host/common/LockFileBase.cpp @@ -11,12 +11,9 @@ using namespace lldb; using namespace lldb_private; -namespace { +static Status AlreadyLocked() { return Status("Already locked"); } -Status AlreadyLocked() { return Status("Already locked"); } - -Status NotLocked() { return Status("Not locked"); } -} +static Status NotLocked() { return Status("Not locked"); } LockFileBase::LockFileBase(int fd) : m_fd(fd), m_locked(false), m_start(0), m_len(0) {} diff --git a/lldb/source/Host/common/Socket.cpp b/lldb/source/Host/common/Socket.cpp index 38e8dbfbbfa25..9ca26d911c257 100644 --- a/lldb/source/Host/common/Socket.cpp +++ b/lldb/source/Host/common/Socket.cpp @@ -59,16 +59,13 @@ typedef void *get_socket_option_arg_type; const NativeSocket Socket::kInvalidSocketValue = -1; #endif // #if defined(_WIN32) -namespace { - -bool IsInterrupted() { +static bool IsInterrupted() { #if defined(_WIN32) return ::WSAGetLastError() == WSAEINTR; #else return errno == EINTR; #endif } -} Socket::Socket(SocketProtocol protocol, bool should_close, bool child_processes_inherit) diff --git a/lldb/source/Host/common/TCPSocket.cpp b/lldb/source/Host/common/TCPSocket.cpp index d7051718db432..4e5bd69b1520e 100644 --- a/lldb/source/Host/common/TCPSocket.cpp +++ b/lldb/source/Host/common/TCPSocket.cpp @@ -53,9 +53,7 @@ static Status GetLastSocketError() { return EC; } -namespace { -const int kType = SOCK_STREAM; -} +static const int kType = SOCK_STREAM; TCPSocket::TCPSocket(bool should_close, bool child_processes_inherit) : Socket(ProtocolTcp, should_close, child_processes_inherit) {} diff --git a/lldb/source/Host/common/UDPSocket.cpp b/lldb/source/Host/common/UDPSocket.cpp index a101a6eb485c6..ceab6f781a074 100644 --- a/lldb/source/Host/common/UDPSocket.cpp +++ b/lldb/source/Host/common/UDPSocket.cpp @@ -21,13 +21,10 @@ using namespace lldb; using namespace lldb_private; -namespace { - -const int kDomain = AF_INET; -const int kType = SOCK_DGRAM; +static const int kDomain = AF_INET; +static const int kType = SOCK_DGRAM; static const char *g_not_supported_error = "Not supported"; -} UDPSocket::UDPSocket(NativeSocket socket) : Socket(ProtocolUdp, true, true) { m_socket = socket; diff --git a/lldb/source/Host/common/XML.cpp b/lldb/source/Host/common/XML.cpp index 7f6f74396d7ac..79128b98dc38d 100644 --- a/lldb/source/Host/common/XML.cpp +++ b/lldb/source/Host/common/XML.cpp @@ -448,9 +448,7 @@ bool ApplePropertyList::ExtractStringFromValueNode(const XMLNode &node, #if LLDB_ENABLE_LIBXML2 -namespace { - -StructuredData::ObjectSP CreatePlistValue(XMLNode node) { +static StructuredData::ObjectSP CreatePlistValue(XMLNode node) { llvm::StringRef element_name = node.GetName(); if (element_name == "array") { std::shared_ptr array_sp( @@ -503,7 +501,6 @@ StructuredData::ObjectSP CreatePlistValue(XMLNode node) { } return StructuredData::ObjectSP(new StructuredData::Null()); } -} #endif StructuredData::ObjectSP ApplePropertyList::GetStructuredData() { diff --git a/lldb/source/Host/linux/HostInfoLinux.cpp b/lldb/source/Host/linux/HostInfoLinux.cpp index 6c37b97d7ccfb..13dcc5aed65c6 100644 --- a/lldb/source/Host/linux/HostInfoLinux.cpp +++ b/lldb/source/Host/linux/HostInfoLinux.cpp @@ -31,9 +31,9 @@ struct HostInfoLinuxFields { llvm::once_flag m_os_version_once_flag; llvm::VersionTuple m_os_version; }; +} // namespace -HostInfoLinuxFields *g_fields = nullptr; -} +static HostInfoLinuxFields *g_fields = nullptr; void HostInfoLinux::Initialize(SharedLibraryDirectoryHelper *helper) { HostInfoPosix::Initialize(helper); diff --git a/lldb/source/Host/macosx/objcxx/HostThreadMacOSX.mm b/lldb/source/Host/macosx/objcxx/HostThreadMacOSX.mm index 0a1cfa9456843..4f7e7ab248ad6 100644 --- a/lldb/source/Host/macosx/objcxx/HostThreadMacOSX.mm +++ b/lldb/source/Host/macosx/objcxx/HostThreadMacOSX.mm @@ -16,11 +16,11 @@ using namespace lldb_private; -namespace { -pthread_once_t g_thread_create_once = PTHREAD_ONCE_INIT; -pthread_key_t g_thread_create_key = 0; +static pthread_once_t g_thread_create_once = PTHREAD_ONCE_INIT; +static pthread_key_t g_thread_create_key = 0; +namespace { class MacOSXDarwinThread { public: MacOSXDarwinThread() { m_pool = [[NSAutoreleasePool alloc] init]; } @@ -45,12 +45,12 @@ static void PThreadDestructor(void *v) { MacOSXDarwinThread(const MacOSXDarwinThread &) = delete; const MacOSXDarwinThread &operator=(const MacOSXDarwinThread &) = delete; }; +} // namespace -void InitThreadCreated() { +static void InitThreadCreated() { ::pthread_key_create(&g_thread_create_key, MacOSXDarwinThread::PThreadDestructor); } -} // namespace HostThreadMacOSX::HostThreadMacOSX() : HostThreadPosix() {} diff --git a/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp b/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp index 0a9c83d65b770..2d93e457a6990 100644 --- a/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp +++ b/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp @@ -62,17 +62,14 @@ const char *ConnectionFileDescriptor::UNIX_ABSTRACT_CONNECT_SCHEME = const char *ConnectionFileDescriptor::FD_SCHEME = "fd"; const char *ConnectionFileDescriptor::FILE_SCHEME = "file"; -namespace { - -llvm::Optional GetURLAddress(llvm::StringRef url, - llvm::StringRef scheme) { +static llvm::Optional GetURLAddress(llvm::StringRef url, + llvm::StringRef scheme) { if (!url.consume_front(scheme)) return llvm::None; if (!url.consume_front("://")) return llvm::None; return url; } -} ConnectionFileDescriptor::ConnectionFileDescriptor(bool child_processes_inherit) : Connection(), m_pipe(), m_mutex(), m_shutting_down(false), diff --git a/lldb/source/Host/posix/DomainSocket.cpp b/lldb/source/Host/posix/DomainSocket.cpp index 0a43d00e93ee1..ddbd983abb81d 100644 --- a/lldb/source/Host/posix/DomainSocket.cpp +++ b/lldb/source/Host/posix/DomainSocket.cpp @@ -26,13 +26,11 @@ using namespace lldb_private; #endif #endif // #ifdef __ANDROID__ -namespace { +static const int kDomain = AF_UNIX; +static const int kType = SOCK_STREAM; -const int kDomain = AF_UNIX; -const int kType = SOCK_STREAM; - -bool SetSockAddr(llvm::StringRef name, const size_t name_offset, - sockaddr_un *saddr_un, socklen_t &saddr_un_len) { +static bool SetSockAddr(llvm::StringRef name, const size_t name_offset, + sockaddr_un *saddr_un, socklen_t &saddr_un_len) { if (name.size() + name_offset > sizeof(saddr_un->sun_path)) return false; @@ -56,7 +54,6 @@ bool SetSockAddr(llvm::StringRef name, const size_t name_offset, return true; } -} // namespace DomainSocket::DomainSocket(bool should_close, bool child_processes_inherit) : Socket(ProtocolUnixDomain, should_close, child_processes_inherit) {} diff --git a/lldb/source/Host/posix/HostProcessPosix.cpp b/lldb/source/Host/posix/HostProcessPosix.cpp index f0142ec946b72..8599a94d22416 100644 --- a/lldb/source/Host/posix/HostProcessPosix.cpp +++ b/lldb/source/Host/posix/HostProcessPosix.cpp @@ -18,9 +18,7 @@ using namespace lldb_private; -namespace { -const int kInvalidPosixProcess = 0; -} +static const int kInvalidPosixProcess = 0; HostProcessPosix::HostProcessPosix() : HostNativeProcessBase(kInvalidPosixProcess) {} diff --git a/lldb/source/Host/posix/LockFilePosix.cpp b/lldb/source/Host/posix/LockFilePosix.cpp index d197974a72a50..cb9ca5c29e5fd 100644 --- a/lldb/source/Host/posix/LockFilePosix.cpp +++ b/lldb/source/Host/posix/LockFilePosix.cpp @@ -16,10 +16,8 @@ using namespace lldb; using namespace lldb_private; -namespace { - -Status fileLock(int fd, int cmd, int lock_type, const uint64_t start, - const uint64_t len) { +static Status fileLock(int fd, int cmd, int lock_type, const uint64_t start, + const uint64_t len) { struct flock fl; fl.l_type = lock_type; @@ -35,8 +33,6 @@ Status fileLock(int fd, int cmd, int lock_type, const uint64_t start, return error; } -} // namespace - LockFilePosix::LockFilePosix(int fd) : LockFileBase(fd) {} LockFilePosix::~LockFilePosix() { Unlock(); } diff --git a/lldb/source/Host/posix/PipePosix.cpp b/lldb/source/Host/posix/PipePosix.cpp index a8cce573f12a7..bd311ad8769a4 100644 --- a/lldb/source/Host/posix/PipePosix.cpp +++ b/lldb/source/Host/posix/PipePosix.cpp @@ -38,12 +38,10 @@ enum PIPES { READ, WRITE }; // Constants 0 and 1 for READ and WRITE #define PIPE2_SUPPORTED 0 #endif -namespace { - -constexpr auto OPEN_WRITER_SLEEP_TIMEOUT_MSECS = 100; +static constexpr auto OPEN_WRITER_SLEEP_TIMEOUT_MSECS = 100; #if defined(FD_CLOEXEC) && !PIPE2_SUPPORTED -bool SetCloexecFlag(int fd) { +static bool SetCloexecFlag(int fd) { int flags = ::fcntl(fd, F_GETFD); if (flags == -1) return false; @@ -51,10 +49,9 @@ bool SetCloexecFlag(int fd) { } #endif -std::chrono::time_point Now() { +static std::chrono::time_point Now() { return std::chrono::steady_clock::now(); } -} // namespace PipePosix::PipePosix() : m_fds{PipePosix::kInvalidDescriptor, PipePosix::kInvalidDescriptor} {} diff --git a/lldb/source/Host/windows/Host.cpp b/lldb/source/Host/windows/Host.cpp index fbfc5358abfec..a881cfae2151c 100644 --- a/lldb/source/Host/windows/Host.cpp +++ b/lldb/source/Host/windows/Host.cpp @@ -30,8 +30,8 @@ using namespace lldb; using namespace lldb_private; -namespace { -bool GetTripleForProcess(const FileSpec &executable, llvm::Triple &triple) { +static bool GetTripleForProcess(const FileSpec &executable, + llvm::Triple &triple) { // Open the PE File as a binary file, and parse just enough information to // determine the machine type. auto imageBinaryP = FileSystem::Instance().Open( @@ -66,7 +66,8 @@ bool GetTripleForProcess(const FileSpec &executable, llvm::Triple &triple) { return true; } -bool GetExecutableForProcess(const AutoHandle &handle, std::string &path) { +static bool GetExecutableForProcess(const AutoHandle &handle, + std::string &path) { // Get the process image path. MAX_PATH isn't long enough, paths can // actually be up to 32KB. std::vector buffer(PATH_MAX); @@ -76,8 +77,8 @@ bool GetExecutableForProcess(const AutoHandle &handle, std::string &path) { return llvm::convertWideToUTF8(buffer.data(), path); } -void GetProcessExecutableAndTriple(const AutoHandle &handle, - ProcessInstanceInfo &process) { +static void GetProcessExecutableAndTriple(const AutoHandle &handle, + ProcessInstanceInfo &process) { // We may not have permissions to read the path from the process. So start // off by setting the executable file to whatever Toolhelp32 gives us, and // then try to enhance this with more detailed information, but fail @@ -96,7 +97,6 @@ void GetProcessExecutableAndTriple(const AutoHandle &handle, // TODO(zturner): Add the ability to get the process user name. } -} lldb::thread_t Host::GetCurrentThread() { return lldb::thread_t(::GetCurrentThread()); diff --git a/lldb/source/Host/windows/HostThreadWindows.cpp b/lldb/source/Host/windows/HostThreadWindows.cpp index b1b8ac38d7eb9..1219c38775453 100644 --- a/lldb/source/Host/windows/HostThreadWindows.cpp +++ b/lldb/source/Host/windows/HostThreadWindows.cpp @@ -16,11 +16,9 @@ using namespace lldb; using namespace lldb_private; -namespace { -void __stdcall ExitThreadProxy(ULONG_PTR dwExitCode) { +static void __stdcall ExitThreadProxy(ULONG_PTR dwExitCode) { ::ExitThread(dwExitCode); } -} HostThreadWindows::HostThreadWindows() : HostNativeThreadBase(), m_owns_handle(true) {} diff --git a/lldb/source/Host/windows/LockFileWindows.cpp b/lldb/source/Host/windows/LockFileWindows.cpp index 4e0675e50ae41..2dd7aa9e545f8 100644 --- a/lldb/source/Host/windows/LockFileWindows.cpp +++ b/lldb/source/Host/windows/LockFileWindows.cpp @@ -13,10 +13,8 @@ using namespace lldb; using namespace lldb_private; -namespace { - -Status fileLock(HANDLE file_handle, DWORD flags, const uint64_t start, - const uint64_t len) { +static Status fileLock(HANDLE file_handle, DWORD flags, const uint64_t start, + const uint64_t len) { if (start != 0) return Status("Non-zero start lock regions are not supported"); @@ -33,8 +31,6 @@ Status fileLock(HANDLE file_handle, DWORD flags, const uint64_t start, return Status(); } -} // namespace - LockFileWindows::LockFileWindows(int fd) : LockFileBase(fd), m_file(reinterpret_cast(_get_osfhandle(fd))) {} diff --git a/lldb/source/Host/windows/PipeWindows.cpp b/lldb/source/Host/windows/PipeWindows.cpp index b63e58e53e7f1..c82c919607b5b 100644 --- a/lldb/source/Host/windows/PipeWindows.cpp +++ b/lldb/source/Host/windows/PipeWindows.cpp @@ -22,10 +22,8 @@ using namespace lldb; using namespace lldb_private; -namespace { -std::atomic g_pipe_serial(0); -constexpr llvm::StringLiteral g_pipe_name_prefix = "\\\\.\\Pipe\\"; -} // namespace +static std::atomic g_pipe_serial(0); +static constexpr llvm::StringLiteral g_pipe_name_prefix = "\\\\.\\Pipe\\"; PipeWindows::PipeWindows() : m_read(INVALID_HANDLE_VALUE), m_write(INVALID_HANDLE_VALUE), diff --git a/lldb/source/Host/windows/ProcessLauncherWindows.cpp b/lldb/source/Host/windows/ProcessLauncherWindows.cpp index fc8da143b99fa..7ef546e5673c0 100644 --- a/lldb/source/Host/windows/ProcessLauncherWindows.cpp +++ b/lldb/source/Host/windows/ProcessLauncherWindows.cpp @@ -20,9 +20,8 @@ using namespace lldb; using namespace lldb_private; -namespace { -void CreateEnvironmentBuffer(const Environment &env, - std::vector &buffer) { +static void CreateEnvironmentBuffer(const Environment &env, + std::vector &buffer) { // The buffer is a list of null-terminated UTF-16 strings, followed by an // extra L'\0' (two bytes of 0). An empty environment must have one // empty string, followed by an extra L'\0'. @@ -42,7 +41,7 @@ void CreateEnvironmentBuffer(const Environment &env, buffer.push_back(0); } -bool GetFlattenedWindowsCommandString(Args args, std::wstring &command) { +static bool GetFlattenedWindowsCommandString(Args args, std::wstring &command) { if (args.empty()) return false; @@ -58,7 +57,6 @@ bool GetFlattenedWindowsCommandString(Args args, std::wstring &command) { command = *result; return true; } -} // namespace HostProcess ProcessLauncherWindows::LaunchProcess(const ProcessLaunchInfo &launch_info, diff --git a/lldb/source/Interpreter/OptionValuePathMappings.cpp b/lldb/source/Interpreter/OptionValuePathMappings.cpp index c6b8c57bbcdc4..e6a366f39061d 100644 --- a/lldb/source/Interpreter/OptionValuePathMappings.cpp +++ b/lldb/source/Interpreter/OptionValuePathMappings.cpp @@ -15,14 +15,13 @@ using namespace lldb; using namespace lldb_private; -namespace { + static bool VerifyPathExists(const char *path) { if (path && path[0]) return FileSystem::Instance().Exists(path); else return false; } -} void OptionValuePathMappings::DumpValue(const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask) { diff --git a/lldb/source/Plugins/ABI/ARC/ABISysV_arc.cpp b/lldb/source/Plugins/ABI/ARC/ABISysV_arc.cpp index cc1e3c321025d..6cf85b27025ba 100644 --- a/lldb/source/Plugins/ABI/ARC/ABISysV_arc.cpp +++ b/lldb/source/Plugins/ABI/ARC/ABISysV_arc.cpp @@ -167,15 +167,15 @@ ABISP ABISysV_arc::CreateInstance(ProcessSP process_sp, const ArchSpec &arch) { ABISP(); } -namespace { -const size_t word_size = 4U; -const size_t reg_size = word_size; +static const size_t word_size = 4U; +static const size_t reg_size = word_size; -inline size_t AugmentArgSize(size_t size_in_bytes) { +static inline size_t AugmentArgSize(size_t size_in_bytes) { return llvm::alignTo(size_in_bytes, word_size); } -size_t TotalArgsSizeInWords(const llvm::ArrayRef &args) { +static size_t +TotalArgsSizeInWords(const llvm::ArrayRef &args) { size_t total_size = 0; for (const auto &arg : args) total_size += @@ -185,7 +185,6 @@ size_t TotalArgsSizeInWords(const llvm::ArrayRef &args) { return total_size; } -} // namespace bool ABISysV_arc::PrepareTrivialCall(Thread &thread, addr_t sp, addr_t func_addr, addr_t return_addr, @@ -372,9 +371,8 @@ Status ABISysV_arc::SetReturnValueObject(StackFrameSP &frame_sp, return result; } -namespace { template -void SetInteger(Scalar &scalar, uint64_t raw_value, bool is_signed) { +static void SetInteger(Scalar &scalar, uint64_t raw_value, bool is_signed) { raw_value &= std::numeric_limits::max(); if (is_signed) scalar = static_cast::type>(raw_value); @@ -382,8 +380,8 @@ void SetInteger(Scalar &scalar, uint64_t raw_value, bool is_signed) { scalar = static_cast(raw_value); } -bool SetSizedInteger(Scalar &scalar, uint64_t raw_value, uint8_t size_in_bytes, - bool is_signed) { +static bool SetSizedInteger(Scalar &scalar, uint64_t raw_value, + uint8_t size_in_bytes, bool is_signed) { switch (size_in_bytes) { default: return false; @@ -408,7 +406,8 @@ bool SetSizedInteger(Scalar &scalar, uint64_t raw_value, uint8_t size_in_bytes, return true; } -bool SetSizedFloat(Scalar &scalar, uint64_t raw_value, uint8_t size_in_bytes) { +static bool SetSizedFloat(Scalar &scalar, uint64_t raw_value, + uint8_t size_in_bytes) { switch (size_in_bytes) { default: return false; @@ -425,7 +424,8 @@ bool SetSizedFloat(Scalar &scalar, uint64_t raw_value, uint8_t size_in_bytes) { return true; } -uint64_t ReadRawValue(const RegisterContextSP ®_ctx, uint8_t size_in_bytes) { +static uint64_t ReadRawValue(const RegisterContextSP ®_ctx, + uint8_t size_in_bytes) { auto reg_info_r0 = reg_ctx->GetRegisterInfo(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG1); @@ -441,7 +441,6 @@ uint64_t ReadRawValue(const RegisterContextSP ®_ctx, uint8_t size_in_bytes) { return raw_value; } -} // namespace ValueObjectSP ABISysV_arc::GetReturnValueObjectSimple(Thread &thread, diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp index 68ae665083930..846c1597292bc 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp @@ -59,9 +59,7 @@ using namespace lldb; using namespace lldb_private; using namespace clang; -namespace { -const char *g_lldb_local_vars_namespace_cstr = "$__lldb_local_vars"; -} // anonymous namespace +static const char *g_lldb_local_vars_namespace_cstr = "$__lldb_local_vars"; ClangExpressionDeclMap::ClangExpressionDeclMap( bool keep_result_in_memory, diff --git a/lldb/source/Plugins/Language/ObjC/NSDictionary.cpp b/lldb/source/Plugins/Language/ObjC/NSDictionary.cpp index d8bf034e731b0..73c40ba959a60 100644 --- a/lldb/source/Plugins/Language/ObjC/NSDictionary.cpp +++ b/lldb/source/Plugins/Language/ObjC/NSDictionary.cpp @@ -334,7 +334,6 @@ namespace Foundation1428 { } namespace Foundation1437 { - namespace { static const uint64_t NSDictionaryCapacities[] = { 0, 3, 7, 13, 23, 41, 71, 127, 191, 251, 383, 631, 1087, 1723, 2803, 4523, 7351, 11959, 19447, 31231, 50683, 81919, 132607, @@ -345,7 +344,8 @@ namespace Foundation1437 { static const size_t NSDictionaryNumSizeBuckets = sizeof(NSDictionaryCapacities) / sizeof(uint64_t); - + + namespace { struct DataDescriptor_32 { uint32_t _buffer; uint32_t _muts; @@ -371,8 +371,8 @@ namespace Foundation1437 { 0 : NSDictionaryCapacities[_szidx]; } }; - } - + } // namespace + using NSDictionaryMSyntheticFrontEnd = GenericNSDictionaryMSyntheticFrontEnd; diff --git a/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptExpressionOpts.cpp b/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptExpressionOpts.cpp index 08a752eaa8880..f54f69a3321ba 100644 --- a/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptExpressionOpts.cpp +++ b/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptExpressionOpts.cpp @@ -40,9 +40,8 @@ using namespace lldb_renderscript; // perform a fixup pass that removes those assumptions right before the module // is sent to be generated by the llvm backend. -namespace { -bool registerRSDefaultTargetOpts(clang::TargetOptions &proto, - const llvm::Triple::ArchType &arch) { +static bool registerRSDefaultTargetOpts(clang::TargetOptions &proto, + const llvm::Triple::ArchType &arch) { switch (arch) { case llvm::Triple::ArchType::x86: proto.Triple = "i686--linux-android"; @@ -75,7 +74,6 @@ bool registerRSDefaultTargetOpts(clang::TargetOptions &proto, } return true; } -} // end anonymous namespace bool RenderScriptRuntimeModulePass::runOnModule(llvm::Module &module) { bool changed_module = false; diff --git a/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptx86ABIFixups.cpp b/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptx86ABIFixups.cpp index bb09b5e171f00..f3b7c9dd3edc0 100644 --- a/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptx86ABIFixups.cpp +++ b/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptx86ABIFixups.cpp @@ -22,9 +22,8 @@ #include "lldb/Utility/Log.h" using namespace lldb_private; -namespace { -bool isRSAPICall(llvm::Module &module, llvm::CallInst *call_inst) { +static bool isRSAPICall(llvm::Module &module, llvm::CallInst *call_inst) { // TODO get the list of renderscript modules from lldb and check if // this llvm::Module calls into any of them. (void)module; @@ -38,7 +37,8 @@ bool isRSAPICall(llvm::Module &module, llvm::CallInst *call_inst) { return true; } -bool isRSLargeReturnCall(llvm::Module &module, llvm::CallInst *call_inst) { +static bool isRSLargeReturnCall(llvm::Module &module, + llvm::CallInst *call_inst) { // i686 and x86_64 returns for large vectors in the RenderScript API are not // handled as normal register pairs, but as a hidden sret type. This is not // reflected in the debug info or mangled symbol name, and the android ABI @@ -58,7 +58,7 @@ bool isRSLargeReturnCall(llvm::Module &module, llvm::CallInst *call_inst) { ->getPrimitiveSizeInBits() > 128; } -bool isRSAllocationPtrTy(const llvm::Type *type) { +static bool isRSAllocationPtrTy(const llvm::Type *type) { if (!type->isPointerTy()) return false; auto ptr_type = type->getPointerElementType(); @@ -67,7 +67,8 @@ bool isRSAllocationPtrTy(const llvm::Type *type) { ptr_type->getStructName().startswith("struct.rs_allocation"); } -bool isRSAllocationTyCallSite(llvm::Module &module, llvm::CallInst *call_inst) { +static bool isRSAllocationTyCallSite(llvm::Module &module, + llvm::CallInst *call_inst) { (void)module; if (!call_inst->hasByValArgument()) return false; @@ -77,7 +78,7 @@ bool isRSAllocationTyCallSite(llvm::Module &module, llvm::CallInst *call_inst) { return false; } -llvm::FunctionType *cloneToStructRetFnTy(llvm::CallInst *call_inst) { +static llvm::FunctionType *cloneToStructRetFnTy(llvm::CallInst *call_inst) { // on x86 StructReturn functions return a pointer to the return value, rather // than the return value itself // [ref](http://www.agner.org/optimize/calling_conventions.pdf section 6). We @@ -122,9 +123,9 @@ llvm::FunctionType *cloneToStructRetFnTy(llvm::CallInst *call_inst) { orig->isVarArg()); } -bool findRSCallSites(llvm::Module &module, - std::set &rs_callsites, - bool (*predicate)(llvm::Module &, llvm::CallInst *)) { +static bool +findRSCallSites(llvm::Module &module, std::set &rs_callsites, + bool (*predicate)(llvm::Module &, llvm::CallInst *)) { bool found = false; for (auto &func : module.getFunctionList()) @@ -143,7 +144,7 @@ bool findRSCallSites(llvm::Module &module, return found; } -bool fixupX86StructRetCalls(llvm::Module &module) { +static bool fixupX86StructRetCalls(llvm::Module &module) { bool changed = false; // changing a basic block while iterating over it seems to have some // undefined behaviour going on so we find all RS callsites first, then fix @@ -207,7 +208,7 @@ bool fixupX86StructRetCalls(llvm::Module &module) { return changed; } -bool fixupRSAllocationStructByValCalls(llvm::Module &module) { +static bool fixupRSAllocationStructByValCalls(llvm::Module &module) { // On x86_64, calls to functions in the RS runtime that take an // `rs_allocation` type argument are actually handled as by-ref params by // bcc, but appear to be passed by value by lldb (the callsite all use @@ -259,7 +260,6 @@ bool fixupRSAllocationStructByValCalls(llvm::Module &module) { } return changed; } -} // end anonymous namespace namespace lldb_private { namespace lldb_renderscript { diff --git a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp index d1911ff8a0341..8428978163270 100644 --- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp +++ b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp @@ -55,36 +55,36 @@ using namespace llvm::ELF; LLDB_PLUGIN_DEFINE(ObjectFileELF) -namespace { - // ELF note owner definitions -const char *const LLDB_NT_OWNER_FREEBSD = "FreeBSD"; -const char *const LLDB_NT_OWNER_GNU = "GNU"; -const char *const LLDB_NT_OWNER_NETBSD = "NetBSD"; -const char *const LLDB_NT_OWNER_NETBSDCORE = "NetBSD-CORE"; -const char *const LLDB_NT_OWNER_OPENBSD = "OpenBSD"; -const char *const LLDB_NT_OWNER_ANDROID = "Android"; -const char *const LLDB_NT_OWNER_CORE = "CORE"; -const char *const LLDB_NT_OWNER_LINUX = "LINUX"; +static const char *const LLDB_NT_OWNER_FREEBSD = "FreeBSD"; +static const char *const LLDB_NT_OWNER_GNU = "GNU"; +static const char *const LLDB_NT_OWNER_NETBSD = "NetBSD"; +static const char *const LLDB_NT_OWNER_NETBSDCORE = "NetBSD-CORE"; +static const char *const LLDB_NT_OWNER_OPENBSD = "OpenBSD"; +static const char *const LLDB_NT_OWNER_ANDROID = "Android"; +static const char *const LLDB_NT_OWNER_CORE = "CORE"; +static const char *const LLDB_NT_OWNER_LINUX = "LINUX"; // ELF note type definitions -const elf_word LLDB_NT_FREEBSD_ABI_TAG = 0x01; -const elf_word LLDB_NT_FREEBSD_ABI_SIZE = 4; +static const elf_word LLDB_NT_FREEBSD_ABI_TAG = 0x01; +static const elf_word LLDB_NT_FREEBSD_ABI_SIZE = 4; -const elf_word LLDB_NT_GNU_ABI_TAG = 0x01; -const elf_word LLDB_NT_GNU_ABI_SIZE = 16; +static const elf_word LLDB_NT_GNU_ABI_TAG = 0x01; +static const elf_word LLDB_NT_GNU_ABI_SIZE = 16; -const elf_word LLDB_NT_GNU_BUILD_ID_TAG = 0x03; +static const elf_word LLDB_NT_GNU_BUILD_ID_TAG = 0x03; -const elf_word LLDB_NT_NETBSD_IDENT_TAG = 1; -const elf_word LLDB_NT_NETBSD_IDENT_DESCSZ = 4; -const elf_word LLDB_NT_NETBSD_IDENT_NAMESZ = 7; -const elf_word LLDB_NT_NETBSD_PROCINFO = 1; +static const elf_word LLDB_NT_NETBSD_IDENT_TAG = 1; +static const elf_word LLDB_NT_NETBSD_IDENT_DESCSZ = 4; +static const elf_word LLDB_NT_NETBSD_IDENT_NAMESZ = 7; +static const elf_word LLDB_NT_NETBSD_PROCINFO = 1; // GNU ABI note OS constants -const elf_word LLDB_NT_GNU_ABI_OS_LINUX = 0x00; -const elf_word LLDB_NT_GNU_ABI_OS_HURD = 0x01; -const elf_word LLDB_NT_GNU_ABI_OS_SOLARIS = 0x02; +static const elf_word LLDB_NT_GNU_ABI_OS_LINUX = 0x00; +static const elf_word LLDB_NT_GNU_ABI_OS_HURD = 0x01; +static const elf_word LLDB_NT_GNU_ABI_OS_SOLARIS = 0x02; + +namespace { //===----------------------------------------------------------------------===// /// \class ELFRelocation @@ -125,6 +125,7 @@ class ELFRelocation { RelocUnion reloc; }; +} // end anonymous namespace ELFRelocation::ELFRelocation(unsigned type) { if (type == DT_REL || type == SHT_REL) @@ -208,8 +209,6 @@ unsigned ELFRelocation::RelocAddend64(const ELFRelocation &rel) { return rel.reloc.get()->r_addend; } -} // end anonymous namespace - static user_id_t SegmentID(size_t PHdrIndex) { return ~user_id_t(PHdrIndex); } diff --git a/lldb/source/Plugins/Platform/Android/AdbClient.cpp b/lldb/source/Plugins/Platform/Android/AdbClient.cpp index ed2d56fb3fd8c..afd869c6739c5 100644 --- a/lldb/source/Plugins/Platform/Android/AdbClient.cpp +++ b/lldb/source/Plugins/Platform/Android/AdbClient.cpp @@ -42,28 +42,26 @@ using namespace lldb_private; using namespace lldb_private::platform_android; using namespace std::chrono; -namespace { +static const seconds kReadTimeout(20); +static const char *kOKAY = "OKAY"; +static const char *kFAIL = "FAIL"; +static const char *kDATA = "DATA"; +static const char *kDONE = "DONE"; -const seconds kReadTimeout(20); -const char *kOKAY = "OKAY"; -const char *kFAIL = "FAIL"; -const char *kDATA = "DATA"; -const char *kDONE = "DONE"; +static const char *kSEND = "SEND"; +static const char *kRECV = "RECV"; +static const char *kSTAT = "STAT"; -const char *kSEND = "SEND"; -const char *kRECV = "RECV"; -const char *kSTAT = "STAT"; - -const size_t kSyncPacketLen = 8; +static const size_t kSyncPacketLen = 8; // Maximum size of a filesync DATA packet. -const size_t kMaxPushData = 2 * 1024; +static const size_t kMaxPushData = 2 * 1024; // Default mode for pushed files. -const uint32_t kDefaultMode = 0100770; // S_IFREG | S_IRWXU | S_IRWXG +static const uint32_t kDefaultMode = 0100770; // S_IFREG | S_IRWXU | S_IRWXG -const char *kSocketNamespaceAbstract = "localabstract"; -const char *kSocketNamespaceFileSystem = "localfilesystem"; +static const char *kSocketNamespaceAbstract = "localabstract"; +static const char *kSocketNamespaceFileSystem = "localfilesystem"; -Status ReadAllBytes(Connection &conn, void *buffer, size_t size) { +static Status ReadAllBytes(Connection &conn, void *buffer, size_t size) { Status error; ConnectionStatus status; @@ -90,8 +88,6 @@ Status ReadAllBytes(Connection &conn, void *buffer, size_t size) { return error; } -} // namespace - Status AdbClient::CreateByDeviceID(const std::string &device_id, AdbClient &adb) { Status error; diff --git a/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp b/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp index 8c45796ae0b3c..279ffb1f2a9cf 100644 --- a/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp +++ b/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp @@ -107,8 +107,7 @@ static bool ProcessVmReadvSupported() { return is_supported; } -namespace { -void MaybeLogLaunchInfo(const ProcessLaunchInfo &info) { +static void MaybeLogLaunchInfo(const ProcessLaunchInfo &info) { Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PROCESS)); if (!log) return; @@ -134,7 +133,7 @@ void MaybeLogLaunchInfo(const ProcessLaunchInfo &info) { LLDB_LOG(log, "arg {0}: '{1}'", i, *args); } -void DisplayBytes(StreamString &s, void *bytes, uint32_t count) { +static void DisplayBytes(StreamString &s, void *bytes, uint32_t count) { uint8_t *ptr = (uint8_t *)bytes; const uint32_t loop_count = std::min(DEBUG_PTRACE_MAXBYTES, count); for (uint32_t i = 0; i < loop_count; i++) { @@ -143,7 +142,7 @@ void DisplayBytes(StreamString &s, void *bytes, uint32_t count) { } } -void PtraceDisplayBytes(int &req, void *data, size_t data_size) { +static void PtraceDisplayBytes(int &req, void *data, size_t data_size) { Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PTRACE)); if (!log) return; @@ -193,7 +192,6 @@ void PtraceDisplayBytes(int &req, void *data, size_t data_size) { static constexpr unsigned k_ptrace_word_size = sizeof(void *); static_assert(sizeof(long) >= k_ptrace_word_size, "Size of long must be larger than ptrace word size"); -} // end of anonymous namespace // Simple helper function to ensure flags are enabled on the given file // descriptor. diff --git a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_ppc64le.cpp b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_ppc64le.cpp index 60582e4cc61f6..5af5aa548f2eb 100644 --- a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_ppc64le.cpp +++ b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_ppc64le.cpp @@ -97,10 +97,8 @@ static const uint32_t g_vsx_regnums_ppc64le[] = { LLDB_INVALID_REGNUM // register sets need to end with this flag }; -namespace { // Number of register sets provided by this context. -enum { k_num_register_sets = 4 }; -} +static constexpr int k_num_register_sets = 4; static const RegisterSet g_reg_sets_ppc64le[k_num_register_sets] = { {"General Purpose Registers", "gpr", k_num_gpr_registers_ppc64le,