summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGAtomic.cpp
diff options
context:
space:
mode:
authorVedant Kumar <vsk@apple.com>2017-03-08 17:38:57 +0000
committerVedant Kumar <vsk@apple.com>2017-03-08 17:38:57 +0000
commit5c13623a69baed43b7f0cbf2912a3baa951285e2 (patch)
treea40c8c1bed57790b028f3a12d38572f7b26c51d3 /clang/lib/CodeGen/CGAtomic.cpp
parent007c002cb6fbe9575041fc46c3007717c768a0ff (diff)
downloadbcm5719-llvm-5c13623a69baed43b7f0cbf2912a3baa951285e2.tar.gz
bcm5719-llvm-5c13623a69baed43b7f0cbf2912a3baa951285e2.zip
[ubsan] Detect UB loads from bitfields
It's possible to load out-of-range values from bitfields backed by a boolean or an enum. Check for UB loads from bitfields. This is the motivating example: struct S { BOOL b : 1; // Signed ObjC BOOL. }; S s; s.b = 1; // This is actually stored as -1. if (s.b == 1) // Evaluates to false, -1 != 1. ... Differential Revision: https://reviews.llvm.org/D30423 llvm-svn: 297298
Diffstat (limited to 'clang/lib/CodeGen/CGAtomic.cpp')
-rw-r--r--clang/lib/CodeGen/CGAtomic.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CGAtomic.cpp b/clang/lib/CodeGen/CGAtomic.cpp
index 9287e46127b..28e20b53d65 100644
--- a/clang/lib/CodeGen/CGAtomic.cpp
+++ b/clang/lib/CodeGen/CGAtomic.cpp
@@ -1181,7 +1181,7 @@ RValue AtomicInfo::convertAtomicTempToRValue(Address addr,
if (LVal.isBitField())
return CGF.EmitLoadOfBitfieldLValue(
LValue::MakeBitfield(addr, LVal.getBitFieldInfo(), LVal.getType(),
- LVal.getAlignmentSource()));
+ LVal.getAlignmentSource()), loc);
if (LVal.isVectorElt())
return CGF.EmitLoadOfLValue(
LValue::MakeVectorElt(addr, LVal.getVectorIdx(), LVal.getType(),
OpenPOWER on IntegriCloud