Syndicate, test and fix base64 implementation
authorserge-sans-paille <sguelton@redhat.com>
Tue, 3 Mar 2020 10:10:38 +0000 (11:10 +0100)
committerserge-sans-paille <sguelton@redhat.com>
Tue, 3 Mar 2020 11:17:53 +0000 (12:17 +0100)
commit1454c27b60447d969d0c1ecaf20b2186fe9d85ec
treed17c20dbed6f5d7eeac328174e730e83fe31b74d
parent8a2d294ed0e1603c8e4d8198e46f436d2612884e
Syndicate, test and fix base64 implementation

llvm/Support/Base64, fix its implementation and provide a decent test suite.

Previous implementation code was using + operator instead of | to combine

results, which is a problem when shifting signed values. (0xFF << 16) is
implicitly converted to a (signed) int, and thus results in 0xffff0000,
h is
negative. Combining negative numbers with a + in that context is not what we
want to do.

This is a recommit of 5a1958f2673f8c771e406a7e309e160b432c9a79 with UB removved.

This fixes https://github.com/llvm/llvm-project/issues/149.

Differential Revision: https://reviews.llvm.org/D75057
clang-tools-extra/clangd/SemanticHighlighting.cpp
compiler-rt/lib/fuzzer/FuzzerUtil.cpp
llvm/include/llvm/Support/Base64.h [new file with mode: 0644]
llvm/unittests/Support/Base64Test.cpp [new file with mode: 0644]
llvm/unittests/Support/CMakeLists.txt