Make lldb -Werror clean for -Wstring-conversion

Also found/fixed one bug identified by this warning in
RenderScriptx86ABIFixups.cpp where a string literal was being used in an
effort to provide a name for an instruction/register, but was instead
being passed as the bool 'isVolatile' parameter.

llvm-svn: 291198
This commit is contained in:
David Blaikie 2017-01-06 00:38:06 +00:00
parent 049b017538
commit a322f36cfd
26 changed files with 66 additions and 115 deletions

View File

@ -52,8 +52,7 @@ public:
default:
break;
}
assert(!"Invalid hash function index");
return 0;
llvm_unreachable("Invalid hash function index");
}
static const uint32_t HASH_MAGIC = 0x48415348u;

View File

@ -258,8 +258,7 @@ uint32_t DataEncoder::PutMaxU64(uint32_t offset, uint32_t byte_size,
case 8:
return PutU64(offset, value);
default:
assert(!"GetMax64 unhandled case!");
break;
llvm_unreachable("GetMax64 unhandled case!");
}
return UINT32_MAX;
}

View File

@ -165,8 +165,7 @@ bool ValueObjectMemory::UpdateValue() {
switch (value_type) {
default:
assert(!"Unhandled expression result value kind...");
break;
llvm_unreachable("Unhandled expression result value kind...");
case Value::eValueTypeScalar:
// The variable value is in the Scalar value inside the m_value.

View File

@ -1602,25 +1602,23 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function,
lldb::addr_t addr = tmp_op.ULongLong();
size_t dataSize = 0;
if (execution_unit.GetAllocSize(addr, dataSize)) {
// Create the required buffer
rawArgs[i].size = dataSize;
rawArgs[i].data_ap.reset(new uint8_t[dataSize + 1]);
bool Success = execution_unit.GetAllocSize(addr, dataSize);
(void)Success;
assert(Success &&
"unable to locate host data for transfer to device");
// Create the required buffer
rawArgs[i].size = dataSize;
rawArgs[i].data_ap.reset(new uint8_t[dataSize + 1]);
// Read string from host memory
execution_unit.ReadMemory(rawArgs[i].data_ap.get(), addr, dataSize,
error);
if (error.Fail()) {
assert(!"we have failed to read the string from memory");
return false;
}
// Add null terminator
rawArgs[i].data_ap[dataSize] = '\0';
rawArgs[i].type = lldb_private::ABI::CallArgument::HostPointer;
} else {
assert(!"unable to locate host data for transfer to device");
return false;
}
// Read string from host memory
execution_unit.ReadMemory(rawArgs[i].data_ap.get(), addr, dataSize,
error);
assert(!error.Fail() &&
"we have failed to read the string from memory");
// Add null terminator
rawArgs[i].data_ap[dataSize] = '\0';
rawArgs[i].type = lldb_private::ABI::CallArgument::HostPointer;
} else /* if ( arg_ty->isPointerTy() ) */
{
rawArgs[i].type = lldb_private::ABI::CallArgument::TargetValue;

View File

@ -285,11 +285,10 @@ void el_end(EditLine *el) {
// assert( !"Not implemented!" );
}
void el_reset(EditLine *) { assert(!"Not implemented!"); }
void el_reset(EditLine *) { llvm_unreachable("Not implemented!"); }
int el_getc(EditLine *, char *) {
assert(!"Not implemented!");
return 0;
llvm_unreachable("Not implemented!");
}
void el_push(EditLine *, const char *) {}
@ -297,8 +296,7 @@ void el_push(EditLine *, const char *) {}
void el_beep(EditLine *) { Beep(1000, 500); }
int el_parse(EditLine *, int, const char **) {
assert(!"Not implemented!");
return 0;
llvm_unreachable("Not implemented!");
}
int el_get(EditLine *el, int code, ...) {
@ -311,7 +309,7 @@ int el_get(EditLine *el, int code, ...) {
*dout = clientData;
} break;
default:
assert(!"Not implemented!");
llvm_unreachable("Not implemented!");
}
return 0;
}
@ -322,7 +320,7 @@ int el_source(EditLine *el, const char *file) {
return 0;
}
void el_resize(EditLine *) { assert(!"Not implemented!"); }
void el_resize(EditLine *) { llvm_unreachable("Not implemented!"); }
const LineInfo *el_line(EditLine *el) { return 0; }
@ -331,7 +329,7 @@ int el_insertstr(EditLine *, const char *) {
return 0;
}
void el_deletestr(EditLine *, int) { assert(!"Not implemented!"); }
void el_deletestr(EditLine *, int) { llvm_unreachable("Not implemented!"); }
History *history_init(void) {
// return dummy handle

View File

@ -584,8 +584,7 @@ Error OptionValueProperties::DumpPropertyValue(const ExecutionContext *exe_ctx,
}
lldb::OptionValueSP OptionValueProperties::DeepCopy() const {
assert(!"this shouldn't happen");
return lldb::OptionValueSP();
llvm_unreachable("this shouldn't happen");
}
const Property *OptionValueProperties::GetPropertyAtPath(

View File

@ -196,8 +196,8 @@ bool fixupX86StructRetCalls(llvm::Module &module) {
llvm::AllocaInst *new_func_ptr =
new llvm::AllocaInst(new_func_ptr_type, "new_func_ptr", call_inst);
// store the new_func_cast to the newly allocated space
(void)new llvm::StoreInst(new_func_cast, new_func_ptr,
"new_func_ptr_load_cast", call_inst);
(new llvm::StoreInst(new_func_cast, new_func_ptr, call_inst))
->setName("new_func_ptr_load_cast");
// load the new function address ready for a jump
llvm::LoadInst *new_func_addr_load =
new llvm::LoadInst(new_func_ptr, "load_func_pointer", call_inst);

View File

@ -480,8 +480,7 @@ Error ProcessKDP::DoResume() {
default:
// The only valid thread resume states are listed above
assert(!"invalid thread resume state");
break;
llvm_unreachable("invalid thread resume state");
}
}

View File

@ -116,8 +116,7 @@ ThreadKDP::CreateRegisterContextForFrame(StackFrame *frame) {
new RegisterContextKDP_x86_64(*this, concrete_frame_idx));
break;
default:
assert(!"Add CPU type support in KDP");
break;
llvm_unreachable("Add CPU type support in KDP");
}
}
} else {

View File

@ -167,7 +167,7 @@ DynamicRegisterInfo::SetRegisterInfo(const StructuredData::Dictionary &dict,
reg_info.byte_offset =
containing_reg_info->byte_offset + msbyte;
} else {
assert(!"Invalid byte order");
llvm_unreachable("Invalid byte order");
}
} else {
if (msbit > max_bit)

View File

@ -1053,8 +1053,7 @@ bool RegisterContextLLDB::ReadRegisterValueFromRegisterLocation(
case UnwindLLDB::RegisterLocation::eRegisterNotSaved:
break;
case UnwindLLDB::RegisterLocation::eRegisterSavedAtHostMemoryLocation:
assert("FIXME debugger inferior function call unwind");
break;
llvm_unreachable("FIXME debugger inferior function call unwind");
case UnwindLLDB::RegisterLocation::eRegisterSavedAtMemoryLocation: {
Error error(ReadRegisterValueFromMemory(
reg_info, regloc.location.target_memory_location, reg_info->byte_size,
@ -1062,8 +1061,7 @@ bool RegisterContextLLDB::ReadRegisterValueFromRegisterLocation(
success = error.Success();
} break;
default:
assert("Unknown RegisterLocation type.");
break;
llvm_unreachable("Unknown RegisterLocation type.");
}
return success;
}
@ -1097,8 +1095,7 @@ bool RegisterContextLLDB::WriteRegisterValueToRegisterLocation(
case UnwindLLDB::RegisterLocation::eRegisterNotSaved:
break;
case UnwindLLDB::RegisterLocation::eRegisterSavedAtHostMemoryLocation:
assert("FIXME debugger inferior function call unwind");
break;
llvm_unreachable("FIXME debugger inferior function call unwind");
case UnwindLLDB::RegisterLocation::eRegisterSavedAtMemoryLocation: {
Error error(WriteRegisterValueToMemory(
reg_info, regloc.location.target_memory_location, reg_info->byte_size,
@ -1106,8 +1103,7 @@ bool RegisterContextLLDB::WriteRegisterValueToRegisterLocation(
success = error.Success();
} break;
default:
assert("Unknown RegisterLocation type.");
break;
llvm_unreachable("Unknown RegisterLocation type.");
}
return success;
}

View File

@ -2599,10 +2599,7 @@ size_t GDBRemoteCommunicationClient::GetCurrentThreadIDs(
thread_ids.push_back(1);
}
} else {
#if defined(LLDB_CONFIGURATION_DEBUG)
// assert(!"ProcessGDBRemote::UpdateThreadList() failed due to not getting the
// sequence mutex");
#else
#if !defined(LLDB_CONFIGURATION_DEBUG)
Log *log(ProcessGDBRemoteLog::GetLogIfAnyCategoryIsSet(GDBR_LOG_PROCESS |
GDBR_LOG_PACKETS));
if (log)

View File

@ -1599,12 +1599,7 @@ StructuredData::ArraySP ScriptInterpreterPython::OSPlugin_ThreadsInfo(
// as the underlying typedef for uint* types, size_t, off_t and other values
// change.
template <typename T> const char *GetPythonValueFormatString(T t) {
assert(!"Unhandled type passed to GetPythonValueFormatString(T), make a "
"specialization of GetPythonValueFormatString() to support this "
"type.");
return nullptr;
}
template <typename T> const char *GetPythonValueFormatString(T t) = delete;
template <> const char *GetPythonValueFormatString(char *) { return "s"; }
template <> const char *GetPythonValueFormatString(char) { return "b"; }
template <> const char *GetPythonValueFormatString(unsigned char) {

View File

@ -65,8 +65,7 @@ bool DWARFDebugRanges::Extract(SymbolFileDWARF *dwarf2Data,
break;
default:
assert(!"DWARFRangeList::Extract() unsupported address size.");
break;
llvm_unreachable("DWARFRangeList::Extract() unsupported address size.");
}
// Filter out empty ranges

View File

@ -734,12 +734,11 @@ int DWARFFormValue::Compare(const DWARFFormValue &a_value,
}
case DW_FORM_indirect:
assert(!"This shouldn't happen after the form has been extracted...");
break;
llvm_unreachable(
"This shouldn't happen after the form has been extracted...");
default:
assert(!"Unhandled DW_FORM");
break;
llvm_unreachable("Unhandled DW_FORM");
}
return -1;
}

View File

@ -167,8 +167,7 @@ void DWARFMappedHash::Prologue::AppendAtom(AtomType type, dw_form_t form) {
case DW_FORM_exprloc:
case DW_FORM_flag_present:
case DW_FORM_ref_sig8:
assert(!"Unhandled atom form");
break;
llvm_unreachable("Unhandled atom form");
case DW_FORM_string:
case DW_FORM_block:

View File

@ -1253,8 +1253,7 @@ SymbolFileDWARFDebugMap::GetCompileUnit(SymbolFileDWARF *oso_dwarf) {
}
}
}
assert(!"this shouldn't happen");
return lldb::CompUnitSP();
llvm_unreachable("this shouldn't happen");
}
SymbolFileDWARFDebugMap::CompileUnitInfo *

View File

@ -442,15 +442,14 @@ size_t UnwindAssemblyInstEmulation::WriteMemory(
case EmulateInstruction::eContextPushRegisterOnStack: {
uint32_t reg_num = LLDB_INVALID_REGNUM;
uint32_t generic_regnum = LLDB_INVALID_REGNUM;
if (context.info_type ==
EmulateInstruction::eInfoTypeRegisterToRegisterPlusOffset) {
const uint32_t unwind_reg_kind = m_unwind_plan_ptr->GetRegisterKind();
reg_num = context.info.RegisterToRegisterPlusOffset.data_reg
.kinds[unwind_reg_kind];
generic_regnum = context.info.RegisterToRegisterPlusOffset.data_reg
.kinds[eRegisterKindGeneric];
} else
assert(!"unhandled case, add code to handle this!");
assert(context.info_type ==
EmulateInstruction::eInfoTypeRegisterToRegisterPlusOffset &&
"unhandled case, add code to handle this!");
const uint32_t unwind_reg_kind = m_unwind_plan_ptr->GetRegisterKind();
reg_num = context.info.RegisterToRegisterPlusOffset.data_reg
.kinds[unwind_reg_kind];
generic_regnum = context.info.RegisterToRegisterPlusOffset.data_reg
.kinds[eRegisterKindGeneric];
if (reg_num != LLDB_INVALID_REGNUM &&
generic_regnum != LLDB_REGNUM_GENERIC_SP) {

View File

@ -390,7 +390,7 @@ static void ParseLangArgs(LangOptions &Opts, InputKind IK, const char *triple) {
case IK_AST:
case IK_LLVM_IR:
case IK_RenderScript:
assert(!"Invalid input kind!");
llvm_unreachable("Invalid input kind!");
case IK_OpenCL:
LangStd = LangStandard::lang_opencl;
break;
@ -7568,8 +7568,7 @@ ClangASTContext::GetTemplateArgument(lldb::opaque_compiler_type_t type,
return CompilerType();
default:
assert(!"Unhandled clang::TemplateArgument::ArgKind");
break;
llvm_unreachable("Unhandled clang::TemplateArgument::ArgKind");
}
}
}

View File

@ -484,8 +484,7 @@ bool Type::ResolveClangType(ResolveState compiler_type_resolve_state) {
break;
default:
assert(!"Unhandled encoding_data_type.");
break;
llvm_unreachable("Unhandled encoding_data_type.");
}
} else {
// We have no encoding type, return void?
@ -529,8 +528,7 @@ bool Type::ResolveClangType(ResolveState compiler_type_resolve_state) {
break;
default:
assert(!"Unhandled encoding_data_type.");
break;
llvm_unreachable("Unhandled encoding_data_type.");
}
}

View File

@ -189,8 +189,7 @@ bool ABI::PrepareTrivialCall(Thread &thread, lldb::addr_t sp,
lldb::addr_t returnAddress, llvm::Type &returntype,
llvm::ArrayRef<ABI::CallArgument> args) const {
// dummy prepare trivial call
assert(!"Should never get here!");
return false;
llvm_unreachable("Should never get here!");
}
bool ABI::GetFallbackRegisterLocation(

View File

@ -1876,9 +1876,8 @@ size_t Platform::GetSoftwareBreakpointTrapOpcode(Target &target,
} break;
default:
assert(
!"Unhandled architecture in Platform::GetSoftwareBreakpointTrapOpcode");
break;
llvm_unreachable(
"Unhandled architecture in Platform::GetSoftwareBreakpointTrapOpcode");
}
assert(bp_site);

View File

@ -541,8 +541,7 @@ StackFrameSP StackFrameList::GetFrameAtIndex(uint32_t idx) {
if (m_frames.empty()) {
// Why do we have a thread with zero frames, that should not ever
// happen...
if (m_thread.IsValid())
assert("A valid thread has no frames.");
assert(!m_thread.IsValid() && "A valid thread has no frames.");
} else {
ResetCurrentInlinedDepth();
frame_sp = m_frames[original_idx];

View File

@ -115,18 +115,13 @@ uint32_t DNBDataRef::GetMax32(offset_t *offset_ptr, uint32_t byte_size) const {
switch (byte_size) {
case 1:
return Get8(offset_ptr);
break;
case 2:
return Get16(offset_ptr);
break;
case 4:
return Get32(offset_ptr);
break;
default:
assert(!"GetMax32 unhandled case!");
break;
llvm_unreachable("GetMax32 unhandled case!");
}
return 0;
}
//----------------------------------------------------------------------
@ -139,21 +134,15 @@ uint64_t DNBDataRef::GetMax64(offset_t *offset_ptr, uint32_t size) const {
switch (size) {
case 1:
return Get8(offset_ptr);
break;
case 2:
return Get16(offset_ptr);
break;
case 4:
return Get32(offset_ptr);
break;
case 8:
return Get64(offset_ptr);
break;
default:
assert(!"GetMax64 unhandled case!");
break;
llvm_unreachable("GetMax64 unhandled case!");
}
return 0;
}
//----------------------------------------------------------------------

View File

@ -34,9 +34,8 @@ int ioctl(int d, int request, ...) {
return 0;
} break;
default:
assert(!"Not implemented!");
llvm_unreachable("Not implemented!");
}
return -1;
}
int kill(pid_t pid, int sig) {
@ -44,13 +43,11 @@ int kill(pid_t pid, int sig) {
if (pid == getpid())
exit(sig);
//
assert(!"Not implemented!");
return -1;
llvm_unreachable("Not implemented!");
}
int tcsetattr(int fd, int optional_actions, const struct termios *termios_p) {
assert(!"Not implemented!");
return -1;
llvm_unreachable("Not implemented!");
}
int tcgetattr(int fildes, struct termios *termios_p) {

View File

@ -76,8 +76,7 @@ static void AddResultToArray(CFCMutableArray &parent_array,
} break;
default:
assert(!"unhandled result");
break;
llvm_unreachable("unhandled result");
}
}
@ -125,8 +124,7 @@ static void AddResultToDictionary(CFCMutableDictionary &parent_dict,
result->GetAsUnsigned()->GetValue(), true);
} break;
default:
assert(!"unhandled result");
break;
llvm_unreachable("unhandled result");
}
}
void Results::Write(const char *out_path) {