Jan Korous 4c6aa8fd8a
[clang][ssaf] Introduce entity abstraction for SSAF (#169131)
Add core abstractions for identifying program entities across
compilation and link unit boundaries in the Scalable Static Analysis
Framework (SSAF).

Introduces three key components:
- BuildNamespace: Represents build artifacts (compilation units, link
units)
- EntityName: Globally unique entity identifiers across compilation
boundaries
- AST mapping: Functions to map Clang AST declarations to EntityNames

Entity identification uses Unified Symbol Resolution (USR) as the
underlying mechanism, with extensions for sub-entities (parameters,
return values) via suffixes. The abstraction allows whole-program
analysis by providing stable identifiers that persist across separately
compiled translation units.
2025-12-10 09:34:40 -08:00

37 lines
1.1 KiB
C++

//===- EntityName.cpp -------------------------------------------*- 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
//
//===----------------------------------------------------------------------===//
#include "clang/Analysis/Scalable/Model/EntityName.h"
namespace clang::ssaf {
EntityName::EntityName(llvm::StringRef USR, llvm::StringRef Suffix,
NestedBuildNamespace Namespace)
: USR(USR.str()), Suffix(Suffix), Namespace(std::move(Namespace)) {}
bool EntityName::operator==(const EntityName &Other) const {
return asTuple() == Other.asTuple();
}
bool EntityName::operator!=(const EntityName &Other) const {
return !(*this == Other);
}
bool EntityName::operator<(const EntityName &Other) const {
return asTuple() < Other.asTuple();
}
EntityName EntityName::makeQualified(NestedBuildNamespace Namespace) const {
auto Copy = *this;
Copy.Namespace = Copy.Namespace.makeQualified(Namespace);
return Copy;
}
} // namespace clang::ssaf