diff options
author | Vedant Kumar <vsk@apple.com> | 2017-02-27 19:46:19 +0000 |
---|---|---|
committer | Vedant Kumar <vsk@apple.com> | 2017-02-27 19:46:19 +0000 |
commit | 5a9726535156adb72f0aeaeccaaca8229b7d26cd (patch) | |
tree | 28f170f8abc11e9f3a375f13ecaf0cebf8a2451c /clang/lib/CodeGen/CodeGenFunction.h | |
parent | aaf519136482705d483b702b699990643fbbf764 (diff) | |
download | llvm-5a9726535156adb72f0aeaeccaaca8229b7d26cd.zip llvm-5a9726535156adb72f0aeaeccaaca8229b7d26cd.tar.gz llvm-5a9726535156adb72f0aeaeccaaca8229b7d26cd.tar.bz2 |
[ubsan] Factor out logic to emit a range check. NFC.
This is a readability improvement, but it will also help prep an
upcoming patch to detect UB loads from bitfields.
llvm-svn: 296374
Diffstat (limited to 'clang/lib/CodeGen/CodeGenFunction.h')
-rw-r--r-- | clang/lib/CodeGen/CodeGenFunction.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CodeGenFunction.h b/clang/lib/CodeGen/CodeGenFunction.h index e011c11..25174a1 100644 --- a/clang/lib/CodeGen/CodeGenFunction.h +++ b/clang/lib/CodeGen/CodeGenFunction.h @@ -2866,6 +2866,13 @@ public: /// representation to its value representation. llvm::Value *EmitFromMemory(llvm::Value *Value, QualType Ty); + /// Check if the scalar \p Value is within the valid range for the given + /// type \p Ty. + /// + /// Returns true if a check is needed (even if the range is unknown). + bool EmitScalarRangeCheck(llvm::Value *Value, QualType Ty, + SourceLocation Loc); + /// EmitLoadOfScalar - Load a scalar value from an address, taking /// care to appropriately convert from the memory representation to /// the LLVM value representation. |