Fix "pointer is null" static analyzer warnings. NFCI.
authorSimon Pilgrim <llvm-dev@redking.me.uk>
Mon, 13 Jan 2020 14:31:03 +0000 (14:31 +0000)
committerSimon Pilgrim <llvm-dev@redking.me.uk>
Mon, 13 Jan 2020 15:07:56 +0000 (15:07 +0000)
Use castAs<> instead of getAs<> since the pointers are always dereferenced and castAs will perform the null assertion for us.

clang/lib/AST/ASTContext.cpp

index d26e7f7..0b2d8b4 100644 (file)
@@ -8707,8 +8707,8 @@ QualType ASTContext::mergeFunctionParameterTypes(QualType lhs, QualType rhs,
 QualType ASTContext::mergeFunctionTypes(QualType lhs, QualType rhs,
                                         bool OfBlockPointer,
                                         bool Unqualified) {
-  const auto *lbase = lhs->getAs<FunctionType>();
-  const auto *rbase = rhs->getAs<FunctionType>();
+  const auto *lbase = lhs->castAs<FunctionType>();
+  const auto *rbase = rhs->castAs<FunctionType>();
   const auto *lproto = dyn_cast<FunctionProtoType>(lbase);
   const auto *rproto = dyn_cast<FunctionProtoType>(rbase);
   bool allLTypes = true;