[clang] [clang][ssaf] Add whole-program analysis execution layer (PR #186813)
Aviral Goel via cfe-commits
cfe-commits at lists.llvm.org
Tue Mar 17 16:01:56 PDT 2026
================
@@ -0,0 +1,96 @@
+//===- WPASuite.h ---------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+//
+// The value returned by AnalysisDriver::run(). Bundles the EntityIdTable
+// with the analysis results keyed by AnalysisName.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CLANG_SCALABLESTATICANALYSISFRAMEWORK_CORE_ANALYSIS_WPASUITE_H
+#define LLVM_CLANG_SCALABLESTATICANALYSISFRAMEWORK_CORE_ANALYSIS_WPASUITE_H
+
+#include "clang/ScalableStaticAnalysisFramework/Core/Analysis/AnalysisName.h"
+#include "clang/ScalableStaticAnalysisFramework/Core/Analysis/AnalysisResult.h"
+#include "clang/ScalableStaticAnalysisFramework/Core/Analysis/AnalysisTraits.h"
+#include "clang/ScalableStaticAnalysisFramework/Core/Model/EntityIdTable.h"
+#include "clang/ScalableStaticAnalysisFramework/Core/Support/ErrorBuilder.h"
+#include "llvm/Support/Error.h"
+#include <map>
+#include <memory>
+
+namespace clang::ssaf {
+
+class AnalysisDriver;
+
+/// Bundles the EntityIdTable (moved from the LUSummary) and the analysis
+/// results produced by one AnalysisDriver::run() call, keyed by AnalysisName.
+///
+/// This is the natural unit of persistence: entity names and analysis results
+/// are self-contained in one object.
+class WPASuite {
+ friend class AnalysisDriver;
+
+ EntityIdTable IdTable;
+ std::map<AnalysisName, std::unique_ptr<AnalysisResult>> Data;
+
+ WPASuite() = default;
+
+public:
+ /// Returns the EntityIdTable that maps EntityId values to their symbolic
+ /// names.
+ const EntityIdTable &idTable() const { return IdTable; }
+
+ /// Returns true if a result for \p ResultT is present.
+ template <typename ResultT> [[nodiscard]] bool contains() const {
+ static_assert(std::is_base_of_v<AnalysisResult, ResultT>,
+ "ResultT must derive from AnalysisResult");
+ static_assert(HasAnalysisName<ResultT>::value,
+ "ResultT must have a static analysisName() method");
----------------
aviralg wrote:
No. Without CRTP for `AnalysisResult`, there is no way for AnalysisResult to assert that its subclasses should provide a static `analysisName()` method. So we need these asserts in this file.
https://github.com/llvm/llvm-project/pull/186813
More information about the cfe-commits
mailing list