Skip to content

Commit

Permalink
Type - silence static analyzer getAs<> null dereference warnings. NFCI.
Browse files Browse the repository at this point in the history
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@373480 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
RKSimon committed Oct 2, 2019
1 parent 4ac13ca commit aef104a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/AST/Type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,11 @@ const IdentifierInfo* QualType::getBaseTypeIdentifier() const {
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();
Expand Down

0 comments on commit aef104a

Please sign in to comment.