[clang] [clang][ssaf] Add EntityLinkage data structure (PR #181718)
Balázs Benics via cfe-commits
cfe-commits at lists.llvm.org
Mon Feb 16 11:12:11 PST 2026
================
@@ -0,0 +1,50 @@
+//===- EntityLinkage.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_MODEL_ENTITYLINKAGE_H
+#define LLVM_CLANG_ANALYSIS_SCALABLE_MODEL_ENTITYLINKAGE_H
+
+namespace clang::ssaf {
+
+/// Represents the linkage properties of an entity in the program model.
+///
+/// EntityLinkage captures whether an entity has no linkage, internal linkage,
+/// or external linkage, which determines its visibility and accessibility
+/// across translation units.
+class EntityLinkage {
+ friend class SerializationFormat;
+
+public:
+ /// Specifies the type of linkage an entity has.
+ enum class LinkageType {
+ None, ///< No linkage (e.g., local variables, function parameters)
+ Internal, ///< Internal linkage (static functions/variables, anonymous
+ ///< namespace)
+ External ///< External linkage (globally visible across translation units)
+ };
+
+ /// Constructs an EntityLinkage with no linkage (default).
+ EntityLinkage() : Linkage(LinkageType::None) {}
+
+ /// Constructs an EntityLinkage with the specified linkage type.
+ ///
+ /// \param L The linkage type to assign to this entity.
+ explicit EntityLinkage(LinkageType L) : Linkage(L) {}
+
+ /// Returns the linkage type of this entity.
+ ///
+ /// \return The LinkageType indicating the entity's linkage.
+ LinkageType getLinkage() const { return Linkage; }
+
+private:
+ LinkageType Linkage;
----------------
steakhal wrote:
How about we drop the default ctor and initialise this here.
```suggestion
LinkageType Linkage = LinkageType::None;
```
https://github.com/llvm/llvm-project/pull/181718
More information about the cfe-commits
mailing list