From dcf0b9043f739e139cf49e49f15abcdc70fd00b0 Mon Sep 17 00:00:00 2001 From: Simon Pilgrim Date: Mon, 30 Sep 2019 11:04:12 +0000 Subject: [PATCH] DeclCXX/ExprCXX - 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@373198 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/AST/DeclCXX.h | 6 +++--- include/clang/AST/ExprCXX.h | 3 +-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/include/clang/AST/DeclCXX.h b/include/clang/AST/DeclCXX.h index 7ec391f464..0b835ecd73 100644 --- a/include/clang/AST/DeclCXX.h +++ b/include/clang/AST/DeclCXX.h @@ -2236,7 +2236,7 @@ public: const CXXRecordDecl *Decl); Qualifiers getMethodQualifiers() const { - return getType()->getAs()->getMethodQuals(); + return getType()->castAs()->getMethodQuals(); } /// Retrieve the ref-qualifier associated with this method. @@ -2251,7 +2251,7 @@ public: /// }; /// @endcode RefQualifierKind getRefQualifier() const { - return getType()->getAs()->getRefQualifier(); + return getType()->castAs()->getRefQualifier(); } bool hasInlineBody() const; @@ -2905,7 +2905,7 @@ public: /// Returns the type that this conversion function is converting to. QualType getConversionType() const { - return getType()->getAs()->getReturnType(); + return getType()->castAs()->getReturnType(); } /// Determine whether this conversion function is a conversion from diff --git a/include/clang/AST/ExprCXX.h b/include/clang/AST/ExprCXX.h index e554968cab..bc7d7c0a32 100644 --- a/include/clang/AST/ExprCXX.h +++ b/include/clang/AST/ExprCXX.h @@ -2096,8 +2096,7 @@ public: bool IsParenTypeId); QualType getAllocatedType() const { - assert(getType()->isPointerType()); - return getType()->getAs()->getPointeeType(); + return getType()->castAs()->getPointeeType(); } TypeSourceInfo *getAllocatedTypeSourceInfo() const { -- 2.40.0