diff options
author | Richard Trieu <rtrieu@google.com> | 2014-07-02 04:39:38 +0000 |
---|---|---|
committer | Richard Trieu <rtrieu@google.com> | 2014-07-02 04:39:38 +0000 |
commit | a262c9464b7765b4583c3226fe4d8c33a96b163e (patch) | |
tree | 2a8642324dd953ac2b4b0806172754b0679a7fa9 /lib/Sema/SemaChecking.cpp | |
parent | 645fd98f93082e43785353887efda870dcb2e1d9 (diff) |
Prevent Clang from crashing on template code.
Fixes PR20110, where Clang hits an assertion failure when it expects that the
sub-expression of a bit cast to pointer to also be a pointer, but gets a value
instead.
Differential Revision: http://reviews.llvm.org/D4280
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@212160 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaChecking.cpp')
-rw-r--r-- | lib/Sema/SemaChecking.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp index 1a49b4ac4f..cd31f72c65 100644 --- a/lib/Sema/SemaChecking.cpp +++ b/lib/Sema/SemaChecking.cpp @@ -4613,7 +4613,6 @@ static Expr *EvalAddr(Expr *E, SmallVectorImpl<DeclRefExpr *> &refVars, case Stmt::CXXReinterpretCastExprClass: { Expr* SubExpr = cast<CastExpr>(E)->getSubExpr(); switch (cast<CastExpr>(E)->getCastKind()) { - case CK_BitCast: case CK_LValueToRValue: case CK_NoOp: case CK_BaseToDerived: @@ -4628,6 +4627,14 @@ static Expr *EvalAddr(Expr *E, SmallVectorImpl<DeclRefExpr *> &refVars, case CK_ArrayToPointerDecay: return EvalVal(SubExpr, refVars, ParentDecl); + case CK_BitCast: + if (SubExpr->getType()->isAnyPointerType() || + SubExpr->getType()->isBlockPointerType() || + SubExpr->getType()->isObjCQualifiedIdType()) + return EvalAddr(SubExpr, refVars, ParentDecl); + else + return nullptr; + default: return nullptr; } |