[clang] [SSAF][UnsafeBufferUsage] Add APIs to the EntityPointerLevel module for UnsafeBufferUsage (PR #191333)

Balázs Benics via cfe-commits cfe-commits at lists.llvm.org
Fri Apr 17 06:41:02 PDT 2026


================
@@ -0,0 +1,33 @@
+//===- EntityPointerLevelFormat.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_SCALABLESTATICANALYSISFRAMEWORK_ANALYSES_ENTITYPOINTERLEVEL_ENTITYPOINTERLEVELFORMAT_H
+#define LLVM_CLANG_SCALABLESTATICANALYSISFRAMEWORK_ANALYSES_ENTITYPOINTERLEVEL_ENTITYPOINTERLEVELFORMAT_H
+#include "clang/ScalableStaticAnalysisFramework/Analyses/EntityPointerLevel/EntityPointerLevel.h"
+#include "clang/ScalableStaticAnalysisFramework/Core/Serialization/JSONFormat.h"
+
+template <typename... Ts>
+static inline llvm::Error makeSawButExpectedError(const llvm::json::Value &Saw,
+                                                  llvm::StringRef Expected,
+                                                  const Ts &...ExpectedArgs) {
+  std::string Fmt = ("saw %s but expected " + Expected).str();
+  std::string SawStr = llvm::formatv("{0:2}", Saw).str();
+
+  return llvm::createStringError(Fmt.c_str(), SawStr.c_str(), ExpectedArgs...);
+}
----------------
steakhal wrote:

I think what I wanted to highlight was that I've never seen templates having internal linkage declared in headers.
I still find it confusing, and it's regardless confusing if we use `static` or anon namespaces to have a symbol internal linkage.
The `inline` part was about turning a symbol "weak" instead of being "strong". However, what I said there was that templates implicitly weak. But I see that you dropped `inline` which makes sense.

What is still confusing is the first aspect. Anyway, I don't think it worths blocking anything.

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


More information about the cfe-commits mailing list