[PATCH] D41797: [analyzer] Suppress escape of this-pointer during construction.

Phabricator via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 17 16:46:06 PST 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rC322795: [analyzer] Suppress "this" pointer escape during construction. (authored by dergachev, committed by ).

Repository:
  rC Clang

https://reviews.llvm.org/D41797

Files:
  lib/StaticAnalyzer/Core/CallEvent.cpp
  test/Analysis/NewDeleteLeaks-PR19102.cpp


Index: test/Analysis/NewDeleteLeaks-PR19102.cpp
===================================================================
--- test/Analysis/NewDeleteLeaks-PR19102.cpp
+++ test/Analysis/NewDeleteLeaks-PR19102.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_analyze_cc1 -analyzer-checker=core,cplusplus.NewDeleteLeaks -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,cplusplus.NewDeleteLeaks -analyzer-config c++-allocator-inlining=true -verify %s
 
 class A0 {};
 
Index: lib/StaticAnalyzer/Core/CallEvent.cpp
===================================================================
--- lib/StaticAnalyzer/Core/CallEvent.cpp
+++ lib/StaticAnalyzer/Core/CallEvent.cpp
@@ -672,8 +672,13 @@
 
 void CXXConstructorCall::getExtraInvalidatedValues(ValueList &Values,
                            RegionAndSymbolInvalidationTraits *ETraits) const {
-  if (Data)
-    Values.push_back(loc::MemRegionVal(static_cast<const MemRegion *>(Data)));
+  if (Data) {
+    loc::MemRegionVal MV(static_cast<const MemRegion *>(Data));
+    if (SymbolRef Sym = MV.getAsSymbol(true))
+      ETraits->setTrait(Sym,
+                        RegionAndSymbolInvalidationTraits::TK_SuppressEscape);
+    Values.push_back(MV);
+  }
 }
 
 void CXXConstructorCall::getInitialStackFrameContents(


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D41797.130316.patch
Type: text/x-patch
Size: 1253 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180118/65789331/attachment.bin>


More information about the cfe-commits mailing list