diff options
| author | Zachary Turner <zturner@google.com> | 2015-04-02 20:57:38 +0000 |
|---|---|---|
| committer | Zachary Turner <zturner@google.com> | 2015-04-02 20:57:38 +0000 |
| commit | 48b475cbaa098095b47d220aa3503a275ee70982 (patch) | |
| tree | 549e17d17d08085eb196ffa9fcc2321f5d120a9f /lldb/source/Host | |
| parent | d4e1b8685e4c6f9514ffff5f7cd030d4aa4d58a1 (diff) | |
| download | bcm5719-llvm-48b475cbaa098095b47d220aa3503a275ee70982.tar.gz bcm5719-llvm-48b475cbaa098095b47d220aa3503a275ee70982.zip | |
Fix warnings generated by clang-cl.
There were a couple of real bugs here regarding error checking and
signed/unsigned comparisons, but mostly these were just noise.
There was one class of bugs fixed here which is particularly
annoying, dealing with MSVC's non-standard behavior regarding
the underlying type of enums. See the comment in
lldb-enumerations.h for details. In short, from now on please use
FLAGS_ENUM and FLAGS_ANONYMOUS_ENUM when defining enums which
contain values larger than can fit into a signed integer.
llvm-svn: 233943
Diffstat (limited to 'lldb/source/Host')
| -rw-r--r-- | lldb/source/Host/common/File.cpp | 1 | ||||
| -rw-r--r-- | lldb/source/Host/common/Socket.cpp | 8 | ||||
| -rw-r--r-- | lldb/source/Host/common/Terminal.cpp | 6 | ||||
| -rw-r--r-- | lldb/source/Host/windows/ConnectionGenericFileWindows.cpp | 4 | ||||
| -rw-r--r-- | lldb/source/Host/windows/EditLineWin.cpp | 6 | ||||
| -rw-r--r-- | lldb/source/Host/windows/HostProcessWindows.cpp | 2 | ||||
| -rw-r--r-- | lldb/source/Host/windows/ThisThread.cpp | 10 | ||||
| -rw-r--r-- | lldb/source/Host/windows/getopt/GetOptInc.cpp | 17 |
8 files changed, 29 insertions, 25 deletions
diff --git a/lldb/source/Host/common/File.cpp b/lldb/source/Host/common/File.cpp index 946f3dd6fef..bfec946456c 100644 --- a/lldb/source/Host/common/File.cpp +++ b/lldb/source/Host/common/File.cpp @@ -811,7 +811,6 @@ File::Write (const void *buf, size_t &num_bytes, off_t &offset) if (!error.Fail()) SeekFromStart(cur); - ssize_t bytes_written = after - cur; offset = after; #endif } diff --git a/lldb/source/Host/common/Socket.cpp b/lldb/source/Host/common/Socket.cpp index 3bcd934aced..ff1ca7d10a2 100644 --- a/lldb/source/Host/common/Socket.cpp +++ b/lldb/source/Host/common/Socket.cpp @@ -704,7 +704,7 @@ int Socket::SetOption(int level, int option_name, int option_value) uint16_t Socket::GetLocalPortNumber(const NativeSocket& socket) { // We bound to port zero, so we need to figure out which port we actually bound to - if (socket >= 0) + if (socket != kInvalidSocketValue) { SocketAddress sock_addr; socklen_t sock_addr_len = sock_addr.GetMaxLength (); @@ -723,7 +723,7 @@ uint16_t Socket::GetLocalPortNumber() const std::string Socket::GetLocalIPAddress () const { // We bound to port zero, so we need to figure out which port we actually bound to - if (m_socket >= 0) + if (m_socket != kInvalidSocketValue) { SocketAddress sock_addr; socklen_t sock_addr_len = sock_addr.GetMaxLength (); @@ -735,7 +735,7 @@ std::string Socket::GetLocalIPAddress () const uint16_t Socket::GetRemotePortNumber () const { - if (m_socket >= 0) + if (m_socket != kInvalidSocketValue) { SocketAddress sock_addr; socklen_t sock_addr_len = sock_addr.GetMaxLength (); @@ -748,7 +748,7 @@ uint16_t Socket::GetRemotePortNumber () const std::string Socket::GetRemoteIPAddress () const { // We bound to port zero, so we need to figure out which port we actually bound to - if (m_socket >= 0) + if (m_socket != kInvalidSocketValue) { SocketAddress sock_addr; socklen_t sock_addr_len = sock_addr.GetMaxLength (); diff --git a/lldb/source/Host/common/Terminal.cpp b/lldb/source/Host/common/Terminal.cpp index ca46eb0f744..9f3abb75e91 100644 --- a/lldb/source/Host/common/Terminal.cpp +++ b/lldb/source/Host/common/Terminal.cpp @@ -180,20 +180,18 @@ TerminalState::Save (int fd, bool save_process_group) bool TerminalState::Restore () const { +#ifndef LLDB_DISABLE_POSIX if (IsValid()) { const int fd = m_tty.GetFileDescriptor(); -#ifndef LLDB_DISABLE_POSIX if (TFlagsIsValid()) fcntl (fd, F_SETFL, m_tflags); -#endif #ifdef LLDB_CONFIG_TERMIOS_SUPPORTED if (TTYStateIsValid()) tcsetattr (fd, TCSANOW, m_termios_ap.get()); #endif // #ifdef LLDB_CONFIG_TERMIOS_SUPPORTED -#ifndef LLDB_DISABLE_POSIX if (ProcessGroupIsValid()) { // Save the original signal handler. @@ -204,9 +202,9 @@ TerminalState::Restore () const // Restore the original signal handler. signal (SIGTTOU, saved_sigttou_callback); } -#endif return true; } +#endif return false; } diff --git a/lldb/source/Host/windows/ConnectionGenericFileWindows.cpp b/lldb/source/Host/windows/ConnectionGenericFileWindows.cpp index bbf315019aa..e2b23d0a0f5 100644 --- a/lldb/source/Host/windows/ConnectionGenericFileWindows.cpp +++ b/lldb/source/Host/windows/ConnectionGenericFileWindows.cpp @@ -208,9 +208,9 @@ ConnectionGenericFile::Read(void *dst, size_t dst_len, uint32_t timeout_usec, ll TimeValue time_value; time_value.OffsetWithMicroSeconds(timeout_usec); DWORD milliseconds = time_value.milliseconds(); - result = ::WaitForMultipleObjects(llvm::array_lengthof(m_event_handles), m_event_handles, FALSE, milliseconds); + DWORD wait_result = ::WaitForMultipleObjects(llvm::array_lengthof(m_event_handles), m_event_handles, FALSE, milliseconds); // All of the events are manual reset events, so make sure we reset them to non-signalled. - switch (result) + switch (wait_result) { case WAIT_OBJECT_0 + kBytesAvailableEvent: break; diff --git a/lldb/source/Host/windows/EditLineWin.cpp b/lldb/source/Host/windows/EditLineWin.cpp index 6bd7e161cd0..8b5c2f2501b 100644 --- a/lldb/source/Host/windows/EditLineWin.cpp +++ b/lldb/source/Host/windows/EditLineWin.cpp @@ -194,7 +194,7 @@ el_gets (EditLine *el, int *length) { // print the prompt if we have one if ( _prompt != NULL ) - printf( _prompt ); + printf("%s", _prompt); // create a buffer for the user input char *buffer = new char[ MAX_PATH ]; // try to get user input string @@ -247,10 +247,10 @@ el_set (EditLine *el, int code, ...) // get the function pointer from the arg list void *func_vp = (void*)va_arg(vl, el_prompt_func); - char escape = (char)va_arg(vl, int); + va_arg(vl, int); // call to get the prompt as a string el_prompt_func func_fp = (el_prompt_func)func_vp; - const char *newPrompt = func_fp(el); + _prompt = func_fp(el); } break; diff --git a/lldb/source/Host/windows/HostProcessWindows.cpp b/lldb/source/Host/windows/HostProcessWindows.cpp index d8e407c667a..0f81c18d34a 100644 --- a/lldb/source/Host/windows/HostProcessWindows.cpp +++ b/lldb/source/Host/windows/HostProcessWindows.cpp @@ -120,7 +120,7 @@ HostProcessWindows::MonitorThread(void *thread_arg) MonitorInfo *info = static_cast<MonitorInfo *>(thread_arg); if (info) { - DWORD wait_result = ::WaitForSingleObject(info->process_handle, INFINITE); + ::WaitForSingleObject(info->process_handle, INFINITE); ::GetExitCodeProcess(info->process_handle, &exit_code); info->callback(info->baton, ::GetProcessId(info->process_handle), true, 0, exit_code); ::CloseHandle(info->process_handle); diff --git a/lldb/source/Host/windows/ThisThread.cpp b/lldb/source/Host/windows/ThisThread.cpp index 9c37d7c57e7..bcd5b8d1c1d 100644 --- a/lldb/source/Host/windows/ThisThread.cpp +++ b/lldb/source/Host/windows/ThisThread.cpp @@ -18,6 +18,8 @@ using namespace lldb; using namespace lldb_private; +#if defined(_MSC_VER) && !defined(__clang__) + namespace { static const DWORD MS_VC_EXCEPTION = 0x406D1388; @@ -33,19 +35,23 @@ struct THREADNAME_INFO #pragma pack(pop) } +#endif + void ThisThread::SetName(llvm::StringRef name) { // Other compilers don't yet support SEH, so we can only set the thread if compiling with MSVC. // TODO(zturner): Once clang-cl supports SEH, relax this conditional. -#if defined(_MSC_VER) +#if defined(_MSC_VER) && !defined(__clang__) THREADNAME_INFO info; info.dwType = 0x1000; info.szName = name.data(); info.dwThreadId = ::GetCurrentThreadId(); info.dwFlags = 0; - __try { ::RaiseException(MS_VC_EXCEPTION, 0, sizeof(info) / sizeof(ULONG_PTR), (ULONG_PTR *)&info); } + __try { + ::RaiseException(MS_VC_EXCEPTION, 0, sizeof(info) / sizeof(ULONG_PTR), (ULONG_PTR *)&info); + } __except(EXCEPTION_EXECUTE_HANDLER) {} #endif } diff --git a/lldb/source/Host/windows/getopt/GetOptInc.cpp b/lldb/source/Host/windows/getopt/GetOptInc.cpp index 612fc9f8147..1101c621c90 100644 --- a/lldb/source/Host/windows/getopt/GetOptInc.cpp +++ b/lldb/source/Host/windows/getopt/GetOptInc.cpp @@ -5,6 +5,11 @@ #include <stdlib.h> #include <string.h> +#if defined(__clang__) && defined(_MSC_VER) +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wwritable-strings" +#endif + int opterr = 1; /* if error message should be printed */ int optind = 1; /* index into parent argv vector */ int optopt = '?'; /* character checked for validity */ @@ -37,14 +42,6 @@ static char *place = EMSG; /* option letter processing */ static int nonopt_start = -1; /* first non option argument (for permute) */ static int nonopt_end = -1; /* first option after non options (for permute) */ -/* Error messages */ -static const char recargchar[] = "option requires an argument -- %c"; -static const char recargstring[] = "option requires an argument -- %s"; -static const char ambig[] = "ambiguous option -- %.*s"; -static const char noarg[] = "option doesn't take an argument -- %.*s"; -static const char illoptchar[] = "unknown option -- %c"; -static const char illoptstring[] = "unknown option -- %s"; - /* * Compute the greatest common divisor of a and b. */ @@ -467,3 +464,7 @@ const struct option *long_options, int *idx) return (getopt_internal(nargc, nargv, options, long_options, idx, FLAG_PERMUTE | FLAG_LONGONLY)); } + +#if defined(__clang__) && defined(_MSC_VER) +#pragma clang diagnostic pop +#endif
\ No newline at end of file |

