Skip to content

Commit 3b93af5

Browse files
committed
[LifetimeSafety] Fix a crash caused by nullptr to llvm::isa
1 parent 1b74b7f commit 3b93af5

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

clang/lib/Analysis/LifetimeSafety/FactsGenerator.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@
99
#include "clang/Analysis/Analyses/LifetimeSafety/FactsGenerator.h"
1010
#include "clang/Analysis/Analyses/LifetimeSafety/LifetimeAnnotations.h"
1111
#include "clang/Analysis/Analyses/PostOrderCFGView.h"
12+
#include "llvm/Support/Casting.h"
1213
#include "llvm/Support/TimeProfiler.h"
1314

1415
namespace clang::lifetimes::internal {
16+
using llvm::isa_and_present;
1517

1618
static bool isGslPointerType(QualType QT) {
1719
if (const auto *RD = QT->getAsCXXRecordDecl()) {
@@ -108,7 +110,7 @@ void FactsGenerator::VisitCXXMemberCallExpr(const CXXMemberCallExpr *MCE) {
108110
// Specifically for conversion operators,
109111
// like `std::string_view p = std::string{};`
110112
if (isGslPointerType(MCE->getType()) &&
111-
isa<CXXConversionDecl>(MCE->getCalleeDecl())) {
113+
isa_and_present<CXXConversionDecl>(MCE->getCalleeDecl())) {
112114
// The argument is the implicit object itself.
113115
handleFunctionCall(MCE, MCE->getMethodDecl(),
114116
{MCE->getImplicitObjectArgument()},

0 commit comments

Comments
 (0)