[PATCH] D46274: [Support] Harden JSON against invalid UTF-8.
Duncan P. N. Exon Smith via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 9 11:51:46 PDT 2018
dexonsmith added inline comments.
================
Comment at: include/llvm/Support/JSON.h:302
+ Value(std::string V) : Type(T_String) {
+ if (!LLVM_LIKELY(isUTF8(V))) {
+ assert(false && "Invalid UTF-8 in value used as JSON");
----------------
benhamilton wrote:
> Seems like flipping the check is clearer:
>
> ```
> if (LLVM_UNLIKELY(!isUTF8(V)) {
> ```
>
Moreover, `__builtin_expect` doesn't work if it's not the top-level condition, and `LLVM_LIKELY` and `LLVM_UNLIKELY` are both using it.
Repository:
rL LLVM
https://reviews.llvm.org/D46274
More information about the llvm-commits
mailing list