Skip to content

Commit 1288953

Browse files
author
apple-llvm-mt
committed
Merge clang: [analyzer] Suppress "this" pointer escape during construction.
apple-llvm-split-dir: clang/
2 parents e6d5b35 + 82dddd2 commit 1288953

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

clang/lib/StaticAnalyzer/Core/CallEvent.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -672,8 +672,13 @@ SVal CXXConstructorCall::getCXXThisVal() const {
672672

673673
void CXXConstructorCall::getExtraInvalidatedValues(ValueList &Values,
674674
RegionAndSymbolInvalidationTraits *ETraits) const {
675-
if (Data)
676-
Values.push_back(loc::MemRegionVal(static_cast<const MemRegion *>(Data)));
675+
if (Data) {
676+
loc::MemRegionVal MV(static_cast<const MemRegion *>(Data));
677+
if (SymbolRef Sym = MV.getAsSymbol(true))
678+
ETraits->setTrait(Sym,
679+
RegionAndSymbolInvalidationTraits::TK_SuppressEscape);
680+
Values.push_back(MV);
681+
}
677682
}
678683

679684
void CXXConstructorCall::getInitialStackFrameContents(

clang/test/Analysis/NewDeleteLeaks-PR19102.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// RUN: %clang_analyze_cc1 -analyzer-checker=core,cplusplus.NewDeleteLeaks -verify %s
2+
// RUN: %clang_analyze_cc1 -analyzer-checker=core,cplusplus.NewDeleteLeaks -analyzer-config c++-allocator-inlining=true -verify %s
23

34
class A0 {};
45

0 commit comments

Comments
 (0)