aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CodeGenFunction.h
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2012-08-24 00:54:33 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2012-08-24 00:54:33 +0000
commit2c9f87ca5cccbfdaad82762368af5b2323320653 (patch)
treee22ac59c06b9a9e7149788fba3e590fea2ce1aab /lib/CodeGen/CodeGenFunction.h
parent6fbe982bb487931feb3f1ceb9eec8f7f1961393a (diff)
New -fcatch-undefined-behavior features:
* when checking that a pointer or reference refers to appropriate storage for a type, also check the alignment and perform a null check * check that references are bound to appropriate storage * check that 'this' has appropriate storage in member accesses and member function calls git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@162523 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CodeGenFunction.h')
-rw-r--r--lib/CodeGen/CodeGenFunction.h26
1 files changed, 24 insertions, 2 deletions
diff --git a/lib/CodeGen/CodeGenFunction.h b/lib/CodeGen/CodeGenFunction.h
index 5855555782..b96ee2e14a 100644
--- a/lib/CodeGen/CodeGenFunction.h
+++ b/lib/CodeGen/CodeGenFunction.h
@@ -1833,7 +1833,29 @@ public:
void EmitStdInitializerListCleanup(llvm::Value *loc,
const InitListExpr *init);
- void EmitCheck(llvm::Value *, unsigned Size);
+ /// \brief Situations in which we might emit a check for the suitability of a
+ /// pointer or glvalue.
+ enum CheckType {
+ /// Checking the operand of a load. Must be suitably sized and aligned.
+ CT_Load,
+ /// Checking the destination of a store. Must be suitably sized and aligned.
+ CT_Store,
+ /// Checking the bound value in a reference binding. Must be suitably sized
+ /// and aligned, but is not required to refer to an object (until the
+ /// reference is used), per core issue 453.
+ CT_ReferenceBinding,
+ /// Checking the object expression in a non-static data member access. Must
+ /// be an object within its lifetime.
+ CT_MemberAccess,
+ /// Checking the 'this' pointer for a call to a non-static member function.
+ /// Must be an object within its lifetime.
+ CT_MemberCall
+ };
+
+ /// EmitCheck - Emit a check that \p V is the address of storage of the
+ /// appropriate size and alignment for an object of type \p Type.
+ void EmitCheck(CheckType CT, llvm::Value *V,
+ QualType Type, CharUnits Alignment = CharUnits::Zero());
llvm::Value *EmitScalarPrePostIncDec(const UnaryOperator *E, LValue LV,
bool isInc, bool isPre);
@@ -2036,7 +2058,7 @@ public:
/// checking code to guard against undefined behavior. This is only
/// suitable when we know that the address will be used to access the
/// object.
- LValue EmitCheckedLValue(const Expr *E);
+ LValue EmitCheckedLValue(const Expr *E, CheckType CT);
/// EmitToMemory - Change a scalar value from its value
/// representation to its in-memory representation.