mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-03-03 08:02:41 +00:00
Sema - silence static analyzer getAs<> null dereference warnings. NFCI.
The static analyzer is warning about potential null dereferences, but in these cases we should be able to use castAs<> directly and if not assert will fire for us. llvm-svn: 373911
This commit is contained in:
parent
edf5027689
commit
dc4d908d6e
@ -1551,7 +1551,7 @@ Sema::AccessResult Sema::CheckUnresolvedMemberAccess(UnresolvedMemberExpr *E,
|
||||
|
||||
QualType BaseType = E->getBaseType();
|
||||
if (E->isArrow())
|
||||
BaseType = BaseType->getAs<PointerType>()->getPointeeType();
|
||||
BaseType = BaseType->castAs<PointerType>()->getPointeeType();
|
||||
|
||||
AccessTarget Entity(Context, AccessTarget::Member, E->getNamingClass(),
|
||||
Found, BaseType);
|
||||
|
@ -484,7 +484,7 @@ static bool checkOpenCLBlockArgs(Sema &S, Expr *BlockArg) {
|
||||
const BlockPointerType *BPT =
|
||||
cast<BlockPointerType>(BlockArg->getType().getCanonicalType());
|
||||
ArrayRef<QualType> Params =
|
||||
BPT->getPointeeType()->getAs<FunctionProtoType>()->getParamTypes();
|
||||
BPT->getPointeeType()->castAs<FunctionProtoType>()->getParamTypes();
|
||||
unsigned ArgCounter = 0;
|
||||
bool IllegalParams = false;
|
||||
// Iterate through the block parameters until either one is found that is not
|
||||
@ -583,7 +583,7 @@ static bool checkOpenCLEnqueueVariadicArgs(Sema &S, CallExpr *TheCall,
|
||||
const BlockPointerType *BPT =
|
||||
cast<BlockPointerType>(BlockArg->getType().getCanonicalType());
|
||||
unsigned NumBlockParams =
|
||||
BPT->getPointeeType()->getAs<FunctionProtoType>()->getNumParams();
|
||||
BPT->getPointeeType()->castAs<FunctionProtoType>()->getNumParams();
|
||||
unsigned TotalNumArgs = TheCall->getNumArgs();
|
||||
|
||||
// For each argument passed to the block, a corresponding uint needs to
|
||||
@ -676,7 +676,7 @@ static bool SemaOpenCLBuiltinEnqueueKernel(Sema &S, CallExpr *TheCall) {
|
||||
// we have a block type, check the prototype
|
||||
const BlockPointerType *BPT =
|
||||
cast<BlockPointerType>(Arg3->getType().getCanonicalType());
|
||||
if (BPT->getPointeeType()->getAs<FunctionProtoType>()->getNumParams() > 0) {
|
||||
if (BPT->getPointeeType()->castAs<FunctionProtoType>()->getNumParams() > 0) {
|
||||
S.Diag(Arg3->getBeginLoc(),
|
||||
diag::err_opencl_enqueue_kernel_blocks_no_args);
|
||||
return true;
|
||||
@ -4664,7 +4664,7 @@ ExprResult Sema::BuildAtomicExpr(SourceRange CallRange, SourceRange ExprRange,
|
||||
<< Ptr->getSourceRange();
|
||||
return ExprError();
|
||||
}
|
||||
ValType = AtomTy->getAs<AtomicType>()->getValueType();
|
||||
ValType = AtomTy->castAs<AtomicType>()->getValueType();
|
||||
} else if (Form != Load && Form != LoadCopy) {
|
||||
if (ValType.isConstQualified()) {
|
||||
Diag(ExprRange.getBegin(), diag::err_atomic_op_needs_non_const_pointer)
|
||||
@ -5473,7 +5473,7 @@ static bool checkVAStartABI(Sema &S, unsigned BuiltinID, Expr *Fn) {
|
||||
if (IsX64 || IsAArch64) {
|
||||
CallingConv CC = CC_C;
|
||||
if (const FunctionDecl *FD = S.getCurFunctionDecl())
|
||||
CC = FD->getType()->getAs<FunctionType>()->getCallConv();
|
||||
CC = FD->getType()->castAs<FunctionType>()->getCallConv();
|
||||
if (IsMSVAStart) {
|
||||
// Don't allow this in System V ABI functions.
|
||||
if (CC == CC_X86_64SysV || (!IsWindows && CC != CC_Win64))
|
||||
@ -5603,7 +5603,7 @@ bool Sema::SemaBuiltinVAStart(unsigned BuiltinID, CallExpr *TheCall) {
|
||||
return false;
|
||||
if (!Type->isEnumeralType())
|
||||
return true;
|
||||
const EnumDecl *ED = Type->getAs<EnumType>()->getDecl();
|
||||
const EnumDecl *ED = Type->castAs<EnumType>()->getDecl();
|
||||
return !(ED &&
|
||||
Context.typesAreCompatible(ED->getPromotionType(), Type));
|
||||
}()) {
|
||||
@ -10756,7 +10756,7 @@ static bool AnalyzeBitFieldAssignment(Sema &S, FieldDecl *Bitfield, Expr *Init,
|
||||
return false;
|
||||
|
||||
if (BitfieldType->isEnumeralType()) {
|
||||
EnumDecl *BitfieldEnumDecl = BitfieldType->getAs<EnumType>()->getDecl();
|
||||
EnumDecl *BitfieldEnumDecl = BitfieldType->castAs<EnumType>()->getDecl();
|
||||
// If the underlying enum type was not explicitly specified as an unsigned
|
||||
// type and the enum contain only positive values, MSVC++ will cause an
|
||||
// inconsistency by storing this as a signed type.
|
||||
|
@ -83,7 +83,7 @@ static QualType lookupPromiseType(Sema &S, const FunctionDecl *FD,
|
||||
// ref-qualifier or with the & ref-qualifier
|
||||
// -- "rvalue reference to cv X" for functions declared with the &&
|
||||
// ref-qualifier
|
||||
QualType T = MD->getThisType()->getAs<PointerType>()->getPointeeType();
|
||||
QualType T = MD->getThisType()->castAs<PointerType>()->getPointeeType();
|
||||
T = FnType->getRefQualifier() == RQ_RValue
|
||||
? S.Context.getRValueReferenceType(T)
|
||||
: S.Context.getLValueReferenceType(T, /*SpelledAsLValue*/ true);
|
||||
|
@ -2172,7 +2172,7 @@ void Sema::MergeTypedefNameDecl(Scope *S, TypedefNameDecl *New,
|
||||
if (!T->isPointerType())
|
||||
break;
|
||||
if (!T->isVoidPointerType()) {
|
||||
QualType PT = T->getAs<PointerType>()->getPointeeType();
|
||||
QualType PT = T->castAs<PointerType>()->getPointeeType();
|
||||
if (!PT->isStructureType())
|
||||
break;
|
||||
}
|
||||
@ -8152,7 +8152,7 @@ static FunctionDecl *CreateNewFunctionDecl(Sema &SemaRef, Declarator &D,
|
||||
// the class has been completely parsed.
|
||||
if (!DC->isRecord() &&
|
||||
SemaRef.RequireNonAbstractType(
|
||||
D.getIdentifierLoc(), R->getAs<FunctionType>()->getReturnType(),
|
||||
D.getIdentifierLoc(), R->castAs<FunctionType>()->getReturnType(),
|
||||
diag::err_abstract_type_in_decl, SemaRef.AbstractReturnType))
|
||||
D.setInvalidType();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user