diff options
| author | Richard Smith <richard-llvm@metafoo.co.uk> | 2017-12-08 23:29:59 +0000 |
|---|---|---|
| committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2017-12-08 23:29:59 +0000 |
| commit | 354abec3e6b6132c9456de39951e8de0632771cc (patch) | |
| tree | 191681e24af3adddd85524ec72439ac5c192d3f5 /clang/lib/Sema | |
| parent | a5370fb82c8e2f9e7676a78677d2730b2512a082 (diff) | |
| download | bcm5719-llvm-354abec3e6b6132c9456de39951e8de0632771cc.tar.gz bcm5719-llvm-354abec3e6b6132c9456de39951e8de0632771cc.zip | |
Remove creation of out-of-bounds value of enumeration type (resulting in UB).
Also remove unnecessary initialization of out-parameters with this value, so
that MSan is able to catch errors appropriately.
llvm-svn: 320212
Diffstat (limited to 'clang/lib/Sema')
| -rw-r--r-- | clang/lib/Sema/Sema.cpp | 2 | ||||
| -rw-r--r-- | clang/lib/Sema/SemaExpr.cpp | 10 | ||||
| -rw-r--r-- | clang/lib/Sema/SemaExprCXX.cpp | 4 |
3 files changed, 8 insertions, 8 deletions
diff --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp index 31400e1de89..4e57e5ef81c 100644 --- a/clang/lib/Sema/Sema.cpp +++ b/clang/lib/Sema/Sema.cpp @@ -529,7 +529,7 @@ CastKind Sema::ScalarTypeToBooleanCastKind(QualType ScalarTy) { case Type::STK_IntegralComplex: return CK_IntegralComplexToBoolean; case Type::STK_FloatingComplex: return CK_FloatingComplexToBoolean; } - return CK_Invalid; + llvm_unreachable("unknown scalar type kind"); } /// \brief Used to prune the decls of Sema's UnusedFileScopedDecls vector. diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 7ff533b92c6..3bd88c7176c 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -7511,7 +7511,7 @@ Sema::CheckAssignmentConstraints(SourceLocation Loc, // usually happen on valid code. OpaqueValueExpr RHSExpr(Loc, RHSType, VK_RValue); ExprResult RHSPtr = &RHSExpr; - CastKind K = CK_Invalid; + CastKind K; return CheckAssignmentConstraints(LHSType, RHSPtr, K, /*ConvertRHS=*/false); } @@ -7903,7 +7903,7 @@ Sema::CheckTransparentUnionArgumentConstraints(QualType ArgType, } } - CastKind Kind = CK_Invalid; + CastKind Kind; if (CheckAssignmentConstraints(it->getType(), RHS, Kind) == Compatible) { RHS = ImpCastExprToType(RHS.get(), it->getType(), Kind); @@ -8019,7 +8019,7 @@ Sema::CheckSingleAssignmentConstraints(QualType LHSType, ExprResult &CallerRHS, } } - CastKind Kind = CK_Invalid; + CastKind Kind; Sema::AssignConvertType result = CheckAssignmentConstraints(LHSType, RHS, Kind, ConvertRHS); @@ -8114,7 +8114,7 @@ static bool tryVectorConvertAndSplat(Sema &S, ExprResult *scalar, unsigned &DiagID) { // The conversion to apply to the scalar before splatting it, // if necessary. - CastKind scalarCast = CK_Invalid; + CastKind scalarCast = CK_NoOp; if (vectorEltTy->isIntegralType(S.Context)) { if (S.getLangOpts().OpenCL && (scalarTy->isRealFloatingType() || @@ -8145,7 +8145,7 @@ static bool tryVectorConvertAndSplat(Sema &S, ExprResult *scalar, // Adjust scalar if desired. if (scalar) { - if (scalarCast != CK_Invalid) + if (scalarCast != CK_NoOp) *scalar = S.ImpCastExprToType(scalar->get(), vectorEltTy, scalarCast); *scalar = S.ImpCastExprToType(scalar->get(), vectorTy, CK_VectorSplat); } diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp index e4634d96d1d..cd0d7157415 100644 --- a/clang/lib/Sema/SemaExprCXX.cpp +++ b/clang/lib/Sema/SemaExprCXX.cpp @@ -3840,7 +3840,7 @@ Sema::PerformImplicitConversion(Expr *From, QualType ToType, << From->getSourceRange(); } - CastKind Kind = CK_Invalid; + CastKind Kind; CXXCastPath BasePath; if (CheckPointerConversion(From, ToType, Kind, BasePath, CStyle)) return ExprError(); @@ -3860,7 +3860,7 @@ Sema::PerformImplicitConversion(Expr *From, QualType ToType, } case ICK_Pointer_Member: { - CastKind Kind = CK_Invalid; + CastKind Kind; CXXCastPath BasePath; if (CheckMemberPointerConversion(From, ToType, Kind, BasePath, CStyle)) return ExprError(); |

