From: Simon Pilgrim Date: Thu, 12 Mar 2020 14:56:32 +0000 (+0000) Subject: Replace getAs with castAs to fix null dereference static analyzer warnings. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7c2b3c9dda37ab25a6849a3670f1bfda6aa17e5e;p=platform%2Fupstream%2Fllvm.git Replace getAs with castAs to fix null dereference static analyzer warnings. 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 getThisType/getThisObjectType calls. --- diff --git a/clang/lib/AST/DeclCXX.cpp b/clang/lib/AST/DeclCXX.cpp index 3645169..8e9258a 100644 --- a/clang/lib/AST/DeclCXX.cpp +++ b/clang/lib/AST/DeclCXX.cpp @@ -2364,17 +2364,15 @@ QualType CXXMethodDecl::getThisType() const { // volatile X*, and if the member function is declared const volatile, // the type of this is const volatile X*. assert(isInstance() && "No 'this' for static methods!"); - - return CXXMethodDecl::getThisType(getType()->getAs(), + return CXXMethodDecl::getThisType(getType()->castAs(), getParent()); } QualType CXXMethodDecl::getThisObjectType() const { // Ditto getThisType. assert(isInstance() && "No 'this' for static methods!"); - - return CXXMethodDecl::getThisObjectType(getType()->getAs(), - getParent()); + return CXXMethodDecl::getThisObjectType( + getType()->castAs(), getParent()); } bool CXXMethodDecl::hasInlineBody() const {