diff options
| author | Benjamin Kramer <benny.kra@googlemail.com> | 2013-09-22 14:09:50 +0000 |
|---|---|---|
| committer | Benjamin Kramer <benny.kra@googlemail.com> | 2013-09-22 14:09:50 +0000 |
| commit | 8817cca5ce782c187605ee08e1a7363aa5470534 (patch) | |
| tree | a70f68125c16f17261abf4865bb60f46a053b51e /llvm/lib/MC/ELFObjectWriter.cpp | |
| parent | 402f807d9d0238cf7c7dd98bea52be221637d580 (diff) | |
| download | bcm5719-llvm-8817cca5ce782c187605ee08e1a7363aa5470534.tar.gz bcm5719-llvm-8817cca5ce782c187605ee08e1a7363aa5470534.zip | |
Provide basic type safety for array_pod_sort comparators.
This makes using array_pod_sort significantly safer. The implementation relies
on function pointer casting but that should be safe as we're dealing with void*
here.
llvm-svn: 191175
Diffstat (limited to 'llvm/lib/MC/ELFObjectWriter.cpp')
| -rw-r--r-- | llvm/lib/MC/ELFObjectWriter.cpp | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/llvm/lib/MC/ELFObjectWriter.cpp b/llvm/lib/MC/ELFObjectWriter.cpp index 2db59acd504..402a6167f5a 100644 --- a/llvm/lib/MC/ELFObjectWriter.cpp +++ b/llvm/lib/MC/ELFObjectWriter.cpp @@ -1104,11 +1104,10 @@ void ELFObjectWriter::WriteRelocationsFragment(const MCAssembler &Asm, } } -static int compareBySuffix(const void *a, const void *b) { - const MCSectionELF *secA = *static_cast<const MCSectionELF* const *>(a); - const MCSectionELF *secB = *static_cast<const MCSectionELF* const *>(b); - const StringRef &NameA = secA->getSectionName(); - const StringRef &NameB = secB->getSectionName(); +static int compareBySuffix(const MCSectionELF *const *a, + const MCSectionELF *const *b) { + const StringRef &NameA = (*a)->getSectionName(); + const StringRef &NameB = (*b)->getSectionName(); const unsigned sizeA = NameA.size(); const unsigned sizeB = NameB.size(); const unsigned len = std::min(sizeA, sizeB); |

