[clang] [LifetimeSafety] Handle escape through function call (PR #186126)

Gábor Horváth via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 1 02:54:29 PDT 2026


================
@@ -632,13 +579,45 @@ void FactsGenerator::handleFunctionCall(const Expr *Call,
                                         ArrayRef<const Expr *> Args,
                                         bool IsGslConstruction) {
   OriginList *CallList = getOriginsList(*Call);
+  SourceManager &SM = AC.getASTContext().getSourceManager();
+  // To avoid over-reporting, we assume the following are noescape:
+  // - All parameters to functions declared in the system headers
+  // - The implicit `this` parameter for member functions
+  auto IsArgNoEscape = [FD, &SM](unsigned I) -> bool {
+    const ParmVarDecl *PVD = nullptr;
+    if (const auto *Method = dyn_cast<CXXMethodDecl>(FD);
+        Method && Method->isInstance()) {
+      // There is currently no way to declare 'this' is noescape for member
+      // functions We therefore return true as the user cannot do anything via
----------------
Xazax-hun wrote:

Nit, here and elsewhere. When comment are sentences, use a full stop at the end. 

```suggestion
      // functions. We therefore return true as the user cannot do anything via
```

https://github.com/llvm/llvm-project/pull/186126


More information about the cfe-commits mailing list