https://github.com/NeKon69 updated https://github.com/llvm/llvm-project/pull/187853
>From 43a4f3b73d719a30a65d2ee3f033953566b6c9e7 Mon Sep 17 00:00:00 2001 From: NeKon69 <[email protected]> Date: Sat, 21 Mar 2026 11:57:27 +0300 Subject: [PATCH 1/3] apply basic fix --- clang/lib/Analysis/LifetimeSafety/FactsGenerator.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/clang/lib/Analysis/LifetimeSafety/FactsGenerator.cpp b/clang/lib/Analysis/LifetimeSafety/FactsGenerator.cpp index 3259505584c9f..954f051914989 100644 --- a/clang/lib/Analysis/LifetimeSafety/FactsGenerator.cpp +++ b/clang/lib/Analysis/LifetimeSafety/FactsGenerator.cpp @@ -20,6 +20,7 @@ #include "clang/Analysis/Analyses/LifetimeSafety/Origins.h" #include "clang/Analysis/Analyses/PostOrderCFGView.h" #include "clang/Analysis/CFG.h" +#include "clang/Basic/OperatorKinds.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/STLExtras.h" #include "llvm/Support/Casting.h" @@ -655,6 +656,13 @@ void FactsGenerator::handleFunctionCall(const Expr *Call, // All arguments to a function are a use of the corresponding expressions. for (const Expr *Arg : Args) handleUse(Arg); + + if (const auto *OCE = dyn_cast<CXXOperatorCallExpr>(Call); + OCE && OCE->getOperator() == OO_Call && FD->isStatic()) { + // Ignore first element + Args = Args.slice(1); + } + handleInvalidatingCall(Call, FD, Args); handleMovedArgsInCall(FD, Args); if (!CallList) >From 8a828b75150c4f05ab0e33df93495e78298d7b2b Mon Sep 17 00:00:00 2001 From: NeKon69 <[email protected]> Date: Sat, 21 Mar 2026 13:33:40 +0300 Subject: [PATCH 2/3] add test --- clang/test/Sema/warn-lifetime-safety.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/clang/test/Sema/warn-lifetime-safety.cpp b/clang/test/Sema/warn-lifetime-safety.cpp index bd09bb70e9a11..974a0b4a32b2a 100644 --- a/clang/test/Sema/warn-lifetime-safety.cpp +++ b/clang/test/Sema/warn-lifetime-safety.cpp @@ -2101,4 +2101,13 @@ void pointer_in_array_use_after_scope() { (void)*arr[0]; // Should warn. } +struct S { + static S operator()(int, int&&); +}; + +void indexing_with_static_operator() { + // no warnings expected + S()(1, 2); +} + } // namespace array >From c9ee4ef628214ef55c01bd7ee010931b54591ddf Mon Sep 17 00:00:00 2001 From: NeKon69 <[email protected]> Date: Sat, 21 Mar 2026 14:36:27 +0300 Subject: [PATCH 3/3] move test to a new file --- .../warn-lifetime-safety-static-call-operator.cpp | 11 +++++++++++ clang/test/Sema/warn-lifetime-safety.cpp | 9 --------- 2 files changed, 11 insertions(+), 9 deletions(-) create mode 100644 clang/test/Sema/warn-lifetime-safety-static-call-operator.cpp diff --git a/clang/test/Sema/warn-lifetime-safety-static-call-operator.cpp b/clang/test/Sema/warn-lifetime-safety-static-call-operator.cpp new file mode 100644 index 0000000000000..68016aa7bf564 --- /dev/null +++ b/clang/test/Sema/warn-lifetime-safety-static-call-operator.cpp @@ -0,0 +1,11 @@ +// RUN: %clang_cc1 -fsyntax-only -std=c++23 -Wlifetime-safety -Wno-dangling -verify %s +// RUN: %clang_cc1 -fsyntax-only -std=c++23 -flifetime-safety-inference -fexperimental-lifetime-safety-tu-analysis -Wlifetime-safety -Wno-dangling -verify %s + +// expected-no-diagnostics +struct S { + static S operator()(int, int&&); +}; + +void indexing_with_static_operator() { + S()(1, 2); +} diff --git a/clang/test/Sema/warn-lifetime-safety.cpp b/clang/test/Sema/warn-lifetime-safety.cpp index 974a0b4a32b2a..bd09bb70e9a11 100644 --- a/clang/test/Sema/warn-lifetime-safety.cpp +++ b/clang/test/Sema/warn-lifetime-safety.cpp @@ -2101,13 +2101,4 @@ void pointer_in_array_use_after_scope() { (void)*arr[0]; // Should warn. } -struct S { - static S operator()(int, int&&); -}; - -void indexing_with_static_operator() { - // no warnings expected - S()(1, 2); -} - } // namespace array _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
