Skip to content

Commit 7b2fe84

Browse files
committed
Don't run the lifetime analysis for pointer assignment if the warning is
disabled.
1 parent 6e68fa9 commit 7b2fe84

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

clang/lib/Sema/CheckExprLifetime.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1297,7 +1297,10 @@ void checkExprLifetime(Sema &SemaRef, const AssignedEntity &Entity,
12971297
Expr *Init) {
12981298
bool EnableLifetimeWarnings = !SemaRef.getDiagnostics().isIgnored(
12991299
diag::warn_dangling_lifetime_pointer, SourceLocation());
1300-
bool RunAnalysis = Entity.LHS->getType()->isPointerType() ||
1300+
bool EnableDanglingPointerAssignment = !SemaRef.getDiagnostics().isIgnored(
1301+
diag::warn_dangling_pointer_assignment, SourceLocation());
1302+
bool RunAnalysis = (EnableDanglingPointerAssignment &&
1303+
Entity.LHS->getType()->isPointerType()) ||
13011304
(EnableLifetimeWarnings &&
13021305
isRecordWithAttr<PointerAttr>(Entity.LHS->getType()));
13031306

0 commit comments

Comments
 (0)