Enable '-Wstring-conversion' and fix some bad asserts that it helped

find.

Notable is the assert in NewGVN which had no effect because of the bug.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@290400 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chandler Carruth 2016-12-23 01:38:06 +00:00
parent d4a4c08350
commit 3abadf484b
3 changed files with 5 additions and 2 deletions

View File

@ -454,6 +454,9 @@ elseif( LLVM_COMPILER_IS_GCC_COMPATIBLE )
if (NOT C_WCOMMENT_ALLOWS_LINE_WRAP)
append("-Wno-comment" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
endif()
# Enable -Wstring-conversion to catch misuse of string literals.
add_flag_if_supported("-Wstring-conversion" STRING_CONVERSION_FLAG)
endif (LLVM_ENABLE_WARNINGS)
append_if(LLVM_ENABLE_WERROR "-Werror" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
add_flag_if_supported("-Werror=date-time" WERROR_DATE_TIME)

View File

@ -45,7 +45,7 @@ public:
}
void relaxInstruction(const MCInst &Inst, const MCSubtargetInfo &STI,
MCInst &Res) const override {
assert(!"Not implemented");
llvm_unreachable("Not implemented");
}
bool mayNeedRelaxation(const MCInst &Inst) const override { return false; }
bool writeNopData(uint64_t Count, MCObjectWriter *OW) const override;

View File

@ -1487,7 +1487,7 @@ void NewGVN::convertDenseToDFSOrdered(CongruenceClass::MemberSet &Dense,
BasicBlock *BB = getBlockForValue(D);
// Constants are handled prior to ever calling this function, so
// we should only be left with instructions as members.
assert(BB || "Should have figured out a basic block for value");
assert(BB && "Should have figured out a basic block for value");
ValueDFS VD;
std::pair<int, int> DFSPair = DFSDomMap[BB];