diff options
| author | Richard Smith <richard-llvm@metafoo.co.uk> | 2013-02-24 01:56:24 +0000 |
|---|---|---|
| committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2013-02-24 01:56:24 +0000 |
| commit | 2847b2202978cbe5b4e1fb7799e71176410ccb40 (patch) | |
| tree | 18cfc249fd3efe97e39e1bb2ff8eae96d2d202b5 /clang/lib | |
| parent | 1b4c64c23bc112671c6da3b291aeacdd4ee42afb (diff) | |
| download | bcm5719-llvm-2847b2202978cbe5b4e1fb7799e71176410ccb40.tar.gz bcm5719-llvm-2847b2202978cbe5b4e1fb7799e71176410ccb40.zip | |
PR15338: Don't assert if -fsanitize=bounds sees array indexing on an incomplete
array type.
llvm-svn: 175982
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/CodeGen/CGExpr.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp index a688dbfacbc..85662069ea6 100644 --- a/clang/lib/CodeGen/CGExpr.cpp +++ b/clang/lib/CodeGen/CGExpr.cpp @@ -677,7 +677,7 @@ llvm::Value *getArrayIndexingBound(CodeGenFunction &CGF, const Expr *Base, const ArrayType *AT = IndexedType->castAsArrayTypeUnsafe(); if (const ConstantArrayType *CAT = dyn_cast<ConstantArrayType>(AT)) return CGF.Builder.getInt(CAT->getSize()); - else if (const VariableArrayType *VAT = cast<VariableArrayType>(AT)) + else if (const VariableArrayType *VAT = dyn_cast<VariableArrayType>(AT)) return CGF.getVLASize(VAT).first; } } @@ -688,6 +688,8 @@ llvm::Value *getArrayIndexingBound(CodeGenFunction &CGF, const Expr *Base, void CodeGenFunction::EmitBoundsCheck(const Expr *E, const Expr *Base, llvm::Value *Index, QualType IndexType, bool Accessed) { + assert(SanOpts->Bounds && "should not be called unless adding bounds checks"); + QualType IndexedType; llvm::Value *Bound = getArrayIndexingBound(*this, Base, IndexedType); if (!Bound) |

