Author: rksimon Date: Wed Oct 2 09:03:36 2019 New Revision: 373480 URL: http://llvm.org/viewvc/llvm-project?rev=373480&view=rev Log: Type - 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. Modified: cfe/trunk/lib/AST/Type.cpp Modified: cfe/trunk/lib/AST/Type.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Type.cpp?rev=373480&r1=373479&r2=373480&view=diff ============================================================================== --- cfe/trunk/lib/AST/Type.cpp (original) +++ cfe/trunk/lib/AST/Type.cpp Wed Oct 2 09:03:36 2019 @@ -75,11 +75,11 @@ const IdentifierInfo* QualType::getBaseT if (ty->isPointerType() || ty->isReferenceType()) return ty->getPointeeType().getBaseTypeIdentifier(); else if (ty->isRecordType()) - ND = ty->getAs<RecordType>()->getDecl(); + ND = ty->castAs<RecordType>()->getDecl(); else if (ty->isEnumeralType()) - ND = ty->getAs<EnumType>()->getDecl(); + ND = ty->castAs<EnumType>()->getDecl(); else if (ty->getTypeClass() == Type::Typedef) - ND = ty->getAs<TypedefType>()->getDecl(); + ND = ty->castAs<TypedefType>()->getDecl(); else if (ty->isArrayType()) return ty->castAsArrayTypeUnsafe()-> getElementType().getBaseTypeIdentifier(); _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits