From 12f3ca4cdb95b193af905a00e722a4dcb40b3de3 Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Wed, 26 Apr 2017 19:45:00 +0000 Subject: Vendor import of llvm trunk r301441: https://llvm.org/svn/llvm-project/llvm/trunk@301441 --- include/llvm/Support/FileSystem.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'include/llvm/Support/FileSystem.h') diff --git a/include/llvm/Support/FileSystem.h b/include/llvm/Support/FileSystem.h index 29515c231bc4..e3c5de7fbe64 100644 --- a/include/llvm/Support/FileSystem.h +++ b/include/llvm/Support/FileSystem.h @@ -116,7 +116,9 @@ inline perms &operator&=(perms &l, perms r) { return l; } inline perms operator~(perms x) { - return static_cast(~static_cast(x)); + // Avoid UB by explicitly truncating the (unsigned) ~ result. + return static_cast( + static_cast(~static_cast(x))); } class UniqueID { -- cgit v1.2.3