forked from OSchip/llvm-project
Fix warnings found with clang-cl.
Earlier this week I was able to get clang-cl on Windows to be able to self host. This opened the door to being able to get a whole new slew of warnings for the Windows build. This patch fixes all of the warnings, many of which were real bugs. llvm-svn: 230522
This commit is contained in:
parent
f42e83cf72
commit
171d943ac5
|
@ -18,7 +18,7 @@ namespace lldb {
|
|||
class LLDB_API SBCommunication
|
||||
{
|
||||
public:
|
||||
enum {
|
||||
enum : unsigned {
|
||||
eBroadcastBitDisconnected = (1 << 0), ///< Sent when the communications connection is lost.
|
||||
eBroadcastBitReadThreadGotBytes = (1 << 1), ///< Sent by the read thread when bytes become available.
|
||||
eBroadcastBitReadThreadDidExit = (1 << 2), ///< Sent by the read thread when it exits to inform clients.
|
||||
|
|
|
@ -21,7 +21,6 @@ namespace lldb {
|
|||
|
||||
class LLDB_API SBValue
|
||||
{
|
||||
friend class ValueLocker;
|
||||
|
||||
public:
|
||||
SBValue ();
|
||||
|
|
|
@ -85,14 +85,14 @@ namespace lldb_private {
|
|||
class Communication : public Broadcaster
|
||||
{
|
||||
public:
|
||||
enum {
|
||||
eBroadcastBitDisconnected = (1 << 0), ///< Sent when the communications connection is lost.
|
||||
eBroadcastBitReadThreadGotBytes = (1 << 1), ///< Sent by the read thread when bytes become available.
|
||||
eBroadcastBitReadThreadDidExit = (1 << 2), ///< Sent by the read thread when it exits to inform clients.
|
||||
eBroadcastBitReadThreadShouldExit = (1 << 3), ///< Sent by clients that need to cancel the read thread.
|
||||
eBroadcastBitPacketAvailable = (1 << 4), ///< Sent when data received makes a complete packet.
|
||||
kLoUserBroadcastBit = (1 << 16),///< Subclasses can used bits 31:16 for any needed events.
|
||||
kHiUserBroadcastBit = (1 << 31),
|
||||
enum : unsigned {
|
||||
eBroadcastBitDisconnected = (1u << 0), ///< Sent when the communications connection is lost.
|
||||
eBroadcastBitReadThreadGotBytes = (1u << 1), ///< Sent by the read thread when bytes become available.
|
||||
eBroadcastBitReadThreadDidExit = (1u << 2), ///< Sent by the read thread when it exits to inform clients.
|
||||
eBroadcastBitReadThreadShouldExit = (1u << 3), ///< Sent by clients that need to cancel the read thread.
|
||||
eBroadcastBitPacketAvailable = (1u << 4), ///< Sent when data received makes a complete packet.
|
||||
kLoUserBroadcastBit = (1u << 16),///< Subclasses can used bits 31:16 for any needed events.
|
||||
kHiUserBroadcastBit = (1u << 31),
|
||||
eAllEventBits = 0xffffffff
|
||||
};
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ public:
|
|||
const char *optstring,
|
||||
const Option *longopts, int *longindex);
|
||||
|
||||
static char* GetOptionArgument();
|
||||
static const char* GetOptionArgument();
|
||||
static int GetOptionIndex();
|
||||
static int GetOptionErrorCause();
|
||||
static std::string GetShortOptionString(struct option *long_options);
|
||||
|
|
|
@ -34,8 +34,10 @@ namespace lldb_private {
|
|||
|
||||
#if defined(_MSC_VER)
|
||||
typedef SOCKET NativeSocket;
|
||||
inline bool IS_VALID_SOCKET(NativeSocket socket) { return socket != INVALID_SOCKET; }
|
||||
#else
|
||||
typedef int NativeSocket;
|
||||
inline bool IS_VALID_SOCKET(NativeSocket socket) { return socket >= 0; }
|
||||
#endif
|
||||
|
||||
class Socket : public IOObject
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
|
||||
#if _HAS_EXCEPTIONS == 0
|
||||
// Exceptions are disabled so this isn't defined, but concrt assumes it is.
|
||||
static void *__uncaught_exception() { return nullptr; }
|
||||
inline void *__uncaught_exception() { return nullptr; }
|
||||
#endif
|
||||
|
||||
#endif // #ifndef liblldb_Platform_Config_h_
|
||||
|
|
|
@ -21,7 +21,7 @@ struct option
|
|||
int getopt( int argc, char * const argv[], const char *optstring );
|
||||
|
||||
// from getopt.h
|
||||
extern char * optarg;
|
||||
extern const char * optarg;
|
||||
extern int optind;
|
||||
extern int opterr;
|
||||
extern int optopt;
|
||||
|
|
|
@ -34,8 +34,6 @@ class ScriptInterpreterPython :
|
|||
{
|
||||
public:
|
||||
|
||||
friend class IOHandlerPythonInterpreter;
|
||||
|
||||
ScriptInterpreterPython (CommandInterpreter &interpreter);
|
||||
|
||||
~ScriptInterpreterPython ();
|
||||
|
|
|
@ -71,7 +71,7 @@ public:
|
|||
eEncodingIsSyntheticUID
|
||||
} EncodingDataType;
|
||||
|
||||
typedef enum ResolveStateTag
|
||||
typedef enum ResolveStateTag : unsigned
|
||||
{
|
||||
eResolveStateUnresolved = 0,
|
||||
eResolveStateForward = 1,
|
||||
|
|
|
@ -23,7 +23,7 @@ namespace lldb_private {
|
|||
class SectionLoadHistory
|
||||
{
|
||||
public:
|
||||
enum {
|
||||
enum : unsigned {
|
||||
// Pass eStopIDNow to any function that takes a stop ID to get
|
||||
// the current value.
|
||||
eStopIDNow = UINT32_MAX
|
||||
|
|
|
@ -652,7 +652,7 @@ namespace lldb {
|
|||
eBasicTypeOther
|
||||
} BasicType;
|
||||
|
||||
typedef enum TypeClass
|
||||
typedef enum TypeClass : unsigned
|
||||
{
|
||||
eTypeClassInvalid = (0u),
|
||||
eTypeClassArray = (1u << 0),
|
||||
|
|
|
@ -54,7 +54,7 @@ OptionParser::Parse (int argc,
|
|||
return getopt_long_only(argc, argv, optstring, &opts[0], longindex);
|
||||
}
|
||||
|
||||
char*
|
||||
const char*
|
||||
OptionParser::GetOptionArgument()
|
||||
{
|
||||
return optarg;
|
||||
|
|
|
@ -699,7 +699,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 (IS_VALID_SOCKET(socket))
|
||||
{
|
||||
SocketAddress sock_addr;
|
||||
socklen_t sock_addr_len = sock_addr.GetMaxLength ();
|
||||
|
@ -730,7 +730,7 @@ std::string Socket::GetLocalIPAddress () const
|
|||
|
||||
uint16_t Socket::GetRemotePortNumber () const
|
||||
{
|
||||
if (m_socket >= 0)
|
||||
if (IS_VALID_SOCKET(m_socket))
|
||||
{
|
||||
SocketAddress sock_addr;
|
||||
socklen_t sock_addr_len = sock_addr.GetMaxLength ();
|
||||
|
@ -743,7 +743,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 (IS_VALID_SOCKET(m_socket))
|
||||
{
|
||||
SocketAddress sock_addr;
|
||||
socklen_t sock_addr_len = sock_addr.GetMaxLength ();
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
func_fp(el);
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -20,8 +20,6 @@ using namespace lldb_private;
|
|||
|
||||
namespace
|
||||
{
|
||||
static const DWORD MS_VC_EXCEPTION = 0x406D1388;
|
||||
|
||||
#pragma pack(push, 8)
|
||||
struct THREADNAME_INFO
|
||||
{
|
||||
|
@ -38,7 +36,9 @@ 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__) /* clang-cl doesn't support SEH */
|
||||
static const DWORD MS_VC_EXCEPTION = 0x406D1388;
|
||||
|
||||
THREADNAME_INFO info;
|
||||
info.dwType = 0x1000;
|
||||
info.szName = name.data();
|
||||
|
|
|
@ -9,7 +9,7 @@ int opterr = 1; /* if error message should be printed */
|
|||
int optind = 1; /* index into parent argv vector */
|
||||
int optopt = '?'; /* character checked for validity */
|
||||
int optreset; /* reset getopt */
|
||||
char *optarg; /* argument associated with option */
|
||||
const char *optarg; /* argument associated with option */
|
||||
|
||||
#define PRINT_ERROR ((opterr) && (*options != ':'))
|
||||
|
||||
|
@ -31,20 +31,12 @@ static int parse_long_options(char * const *, const char *,
|
|||
static int gcd(int, int);
|
||||
static void permute_args(int, int, int, char * const *);
|
||||
|
||||
static char *place = EMSG; /* option letter processing */
|
||||
static const char *place = EMSG; /* option letter processing */
|
||||
|
||||
/* XXX: set optreset to 1 rather than these two */
|
||||
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.
|
||||
*/
|
||||
|
@ -112,7 +104,7 @@ static int
|
|||
parse_long_options(char * const *nargv, const char *options,
|
||||
const struct option *long_options, int *idx, int short_too)
|
||||
{
|
||||
char *current_argv, *has_equal;
|
||||
const char *current_argv, *has_equal;
|
||||
size_t current_argv_len;
|
||||
int i, match;
|
||||
|
||||
|
|
|
@ -269,7 +269,7 @@ ABISysV_hexagon::PrepareTrivialCall ( Thread &thread,
|
|||
|
||||
#if HEX_ABI_DEBUG
|
||||
// print the original stack pointer
|
||||
printf( "sp : %04lx \n", sp );
|
||||
printf( "sp : %04llx \n", sp );
|
||||
#endif
|
||||
|
||||
// make sure number of parameters matches prototype
|
||||
|
@ -337,7 +337,7 @@ ABISysV_hexagon::PrepareTrivialCall ( Thread &thread,
|
|||
uint32_t data = 0;
|
||||
lldb::addr_t addr = sp + i * 4;
|
||||
proc->ReadMemory( addr, (void*)&data, sizeof( data ), error );
|
||||
printf( "\n0x%04lx 0x%08x ", addr, data );
|
||||
printf( "\n0x%04llx 0x%08x ", addr, data );
|
||||
if ( i == 0 ) printf( "<<-- sp" );
|
||||
}
|
||||
printf( "\n" );
|
||||
|
|
|
@ -79,7 +79,6 @@ DebuggerThread::DebuggerThreadRoutine(const ProcessLaunchInfo &launch_info)
|
|||
// Grab a shared_ptr reference to this so that we know it won't get deleted until after the
|
||||
// thread routine has exited.
|
||||
std::shared_ptr<DebuggerThread> this_ref(shared_from_this());
|
||||
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
|
||||
|
||||
Error error;
|
||||
ProcessLauncherWindows launcher;
|
||||
|
|
|
@ -40,7 +40,7 @@ namespace lldb_private
|
|||
class LocalDebugDelegate : public IDebugDelegate
|
||||
{
|
||||
public:
|
||||
explicit LocalDebugDelegate::LocalDebugDelegate(lldb::ProcessSP process);
|
||||
explicit LocalDebugDelegate(lldb::ProcessSP process);
|
||||
|
||||
virtual void OnExitProcess(uint32_t exit_code) override;
|
||||
virtual void OnDebuggerConnected(lldb::addr_t image_base) override;
|
||||
|
|
|
@ -55,8 +55,8 @@ class ProcessWindowsData
|
|||
{
|
||||
public:
|
||||
ProcessWindowsData(const ProcessLaunchInfo &launch_info)
|
||||
: m_initial_stop_event(nullptr)
|
||||
, m_launch_info(launch_info)
|
||||
: m_launch_info(launch_info)
|
||||
, m_initial_stop_event(nullptr)
|
||||
, m_initial_stop_received(false)
|
||||
{
|
||||
m_initial_stop_event = ::CreateEvent(nullptr, TRUE, FALSE, nullptr);
|
||||
|
@ -330,7 +330,6 @@ ProcessWindows::RefreshStateAfterStop()
|
|||
BreakpointSiteSP site(GetBreakpointSiteList().FindByAddress(pc - 1));
|
||||
if (site && site->ValidForThisThread(stop_thread.get()))
|
||||
{
|
||||
lldb::break_id_t break_id = LLDB_INVALID_BREAK_ID;
|
||||
stop_info = StopInfo::CreateStopReasonWithBreakpointSiteID(*stop_thread, site->GetID());
|
||||
register_context->SetPC(pc - 1);
|
||||
}
|
||||
|
@ -389,7 +388,6 @@ void ProcessWindows::DidLaunch()
|
|||
{
|
||||
llvm::sys::ScopedLock lock(m_mutex);
|
||||
|
||||
StateType state = GetPrivateState();
|
||||
// The initial stop won't broadcast the state change event, so account for that here.
|
||||
if (m_session_data && GetPrivateState() == eStateStopped &&
|
||||
m_session_data->m_launch_info.GetFlags().Test(eLaunchFlagStopAtEntry))
|
||||
|
@ -553,7 +551,6 @@ ProcessWindows::OnDebugException(bool first_chance, const ExceptionRecord &recor
|
|||
}
|
||||
|
||||
ExceptionResult result = ExceptionResult::SendToApplication;
|
||||
lldb::StateType state = GetPrivateState();
|
||||
switch (record.GetExceptionCode())
|
||||
{
|
||||
case EXCEPTION_BREAKPOINT:
|
||||
|
|
|
@ -38,7 +38,7 @@ TargetThreadWindows::~TargetThreadWindows()
|
|||
void
|
||||
TargetThreadWindows::RefreshStateAfterStop()
|
||||
{
|
||||
DWORD old_suspend_count = ::SuspendThread(m_host_thread.GetNativeThread().GetSystemHandle());
|
||||
::SuspendThread(m_host_thread.GetNativeThread().GetSystemHandle());
|
||||
|
||||
GetRegisterContext()->InvalidateIfNeeded(false);
|
||||
}
|
||||
|
|
|
@ -93,8 +93,8 @@ RegisterSet g_register_sets[] = {
|
|||
//------------------------------------------------------------------
|
||||
RegisterContextWindows_x86::RegisterContextWindows_x86(Thread &thread, uint32_t concrete_frame_idx)
|
||||
: RegisterContext(thread, concrete_frame_idx)
|
||||
, m_context_stale(true)
|
||||
, m_context()
|
||||
, m_context_stale(true)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -5010,7 +5010,6 @@ public:
|
|||
if (OpenPipes())
|
||||
{
|
||||
const int read_fd = m_read_file.GetDescriptor();
|
||||
const int pipe_read_fd = m_pipe.GetReadFileDescriptor();
|
||||
TerminalState terminal_state;
|
||||
terminal_state.Save (read_fd, false);
|
||||
Terminal terminal(read_fd);
|
||||
|
@ -5018,6 +5017,7 @@ public:
|
|||
terminal.SetEcho(false);
|
||||
// FD_ZERO, FD_SET are not supported on windows
|
||||
#ifndef _WIN32
|
||||
const int pipe_read_fd = m_pipe.GetReadFileDescriptor();
|
||||
while (!GetIsDone())
|
||||
{
|
||||
fd_set read_fdset;
|
||||
|
|
|
@ -235,14 +235,13 @@ PseudoTerminal::GetSlaveName (char *error_str, size_t error_len) const
|
|||
lldb::pid_t
|
||||
PseudoTerminal::Fork (char *error_str, size_t error_len)
|
||||
{
|
||||
pid_t pid = LLDB_INVALID_PROCESS_ID;
|
||||
#if !defined(_MSC_VER)
|
||||
if (error_str)
|
||||
error_str[0] = '\0';
|
||||
|
||||
pid_t pid = LLDB_INVALID_PROCESS_ID;
|
||||
int flags = O_RDWR;
|
||||
#if !defined(_MSC_VER)
|
||||
flags |= O_CLOEXEC;
|
||||
#endif
|
||||
if (OpenFirstAvailableMaster (flags, error_str, error_len))
|
||||
{
|
||||
// Successfully opened our master pseudo terminal
|
||||
|
@ -300,6 +299,7 @@ PseudoTerminal::Fork (char *error_str, size_t error_len)
|
|||
// Do nothing and let the pid get returned!
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return pid;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue