[clang] [SSAF] Extract the virtual method override relation per TU (PR #213316)
Balázs Benics via cfe-commits
cfe-commits at lists.llvm.org
Fri Aug 7 04:26:04 PDT 2026
================
@@ -0,0 +1,51 @@
+//===- VirtualMethodFamily.h ------------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CLANG_SCALABLESTATICANALYSIS_ANALYSES_VIRTUALMETHODFAMILY_VIRTUALMETHODFAMILY_H
+#define LLVM_CLANG_SCALABLESTATICANALYSIS_ANALYSES_VIRTUALMETHODFAMILY_VIRTUALMETHODFAMILY_H
+
+#include "clang/ScalableStaticAnalysis/Core/Model/EntityId.h"
+#include "clang/ScalableStaticAnalysis/Core/Model/SummaryName.h"
+#include "clang/ScalableStaticAnalysis/Core/TUSummary/EntitySummary.h"
+#include "llvm/ADT/StringRef.h"
+#include <optional>
+#include <tuple>
+#include <vector>
+
+namespace clang::ssaf {
+
+struct VirtualMethodSummary final : public EntitySummary {
+ static constexpr llvm::StringLiteral Name = "VirtualMethod";
+
+ static SummaryName summaryName() { return SummaryName(Name.str()); }
+
+ SummaryName getSummaryName() const override { return summaryName(); }
+
+ /// EntityIds of each ParmVarDecl, in source order.
+ std::vector<EntityId> ParamEntities;
+
+ /// EntityId of the synthetic return-slot entity for this method.
+ std::optional<EntityId> ReturnEntity;
----------------
steakhal wrote:
Let's look at the `EdgeCovariantReturnOverride` test case.
There we have a covariant `clone()` method that allocates. During the reforge rewrite we would need to apply changes to that pointer declaration, right? Along with the callsites where we capture that return value.
>From how I understand, we must be able to describe the constraint that if we wanted to change the return type of a virtual method, then that must apply to all methods that possibly land in the same vtable slot (aka. this overrides, or gets overridden by).
https://github.com/llvm/llvm-project/pull/213316
More information about the cfe-commits
mailing list