Skip to content

Commit

Permalink
Replace getAs with castAs to fix null dereference static analyzer war…
Browse files Browse the repository at this point in the history
…ning.

Use castAs as we know the cast should succeed (and castAs will assert if it doesn't) and we're dereferencing it directly in the BuildRCBlockVarRecordLayout call.
  • Loading branch information
RKSimon committed Mar 12, 2020
1 parent 336530b commit adeb8c5
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions clang/lib/CodeGen/CGObjCMac.cpp
Expand Up @@ -2558,9 +2558,8 @@ void CGObjCCommonMac::BuildRCRecordLayout(const llvm::StructLayout *RecLayout,
}
if (FQT->isRecordType() && ElCount) {
int OldIndex = RunSkipBlockVars.size() - 1;
const RecordType *RT = FQT->getAs<RecordType>();
BuildRCBlockVarRecordLayout(RT, BytePos + FieldOffset,
HasUnion);
auto *RT = FQT->castAs<RecordType>();
BuildRCBlockVarRecordLayout(RT, BytePos + FieldOffset, HasUnion);

// Replicate layout information for each array element. Note that
// one element is already done.
Expand Down

0 comments on commit adeb8c5

Please sign in to comment.