[clang] [clang][ssaf] Add UnsafeBufferUsage summary extractor (PR #182941)

Balázs Benics via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 2 05:01:41 PST 2026


================
@@ -1,31 +1,40 @@
-//===- UnsafeBufferUsageBuilder.h -------------------------------*- C++ -*-===//
+//===- UnsafeBufferUsageExtractor.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_ANALYSIS_SCALABLE_ANALYSES_UNSAFEBUFFERUSAGE_UNSAFEBUFFERUSAGEBUILDER_H
-#define LLVM_CLANG_ANALYSIS_SCALABLE_ANALYSES_UNSAFEBUFFERUSAGE_UNSAFEBUFFERUSAGEBUILDER_H
+#ifndef LLVM_CLANG_ANALYSIS_SCALABLE_ANALYSES_UNSAFEBUFFERUSAGE_EXTRACTOR_H
+#define LLVM_CLANG_ANALYSIS_SCALABLE_ANALYSES_UNSAFEBUFFERUSAGE_EXTRACTOR_H
 
 #include "clang/Analysis/Scalable/Analyses/UnsafeBufferUsage/UnsafeBufferUsage.h"
+#include "clang/Analysis/Scalable/Model/EntityId.h"
+#include "clang/Analysis/Scalable/Model/EntityName.h"
 #include "clang/Analysis/Scalable/TUSummary/TUSummaryBuilder.h"
+#include "clang/Analysis/Scalable/TUSummary/TUSummaryExtractor.h"
+#include "llvm/Support/Error.h"
 #include <memory>
 
 namespace clang::ssaf {
-class UnsafeBufferUsageTUSummaryBuilder : public TUSummaryBuilder {
+class UnsafeBufferUsageTUSummaryExtractor : public TUSummaryExtractor {
 public:
+  UnsafeBufferUsageTUSummaryExtractor(TUSummaryBuilder &Builder)
+      : TUSummaryExtractor(Builder) {}
+
   static EntityPointerLevel buildEntityPointerLevel(EntityId Entity,
                                                     unsigned PointerLevel) {
     return {Entity, PointerLevel};
   }
 
-  static std::unique_ptr<UnsafeBufferUsageEntitySummary>
-  buildUnsafeBufferUsageEntitySummary(EntityPointerLevelSet &&UnsafeBuffers) {
-    return std::make_unique<UnsafeBufferUsageEntitySummary>(
-        UnsafeBufferUsageEntitySummary(std::move(UnsafeBuffers)));
-  }
+  EntityId addEntity(EntityName EN) { return SummaryBuilder.addEntity(EN); }
+
+  std::unique_ptr<UnsafeBufferUsageEntitySummary>
+  extractEntitySummary(const Decl *Contributor, ASTContext &Ctx,
+                       llvm::Error &Error);
+
+  virtual void HandleTranslationUnit(ASTContext &Ctx) override;
----------------
steakhal wrote:

The keyword `override` already implies `virtual` for the reader.
```suggestion
 void HandleTranslationUnit(ASTContext &Ctx) override;
```

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


More information about the cfe-commits mailing list