clang 24.0.0git
ASTEntityMapping.h
Go to the documentation of this file.
1//===- ASTEntityMapping.h - AST to SSAF Entity mapping ----------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLVM_CLANG_SCALABLESTATICANALYSIS_CORE_ASTENTITYMAPPING_H
10#define LLVM_CLANG_SCALABLESTATICANALYSIS_CORE_ASTENTITYMAPPING_H
11
12#include "clang/AST/Decl.h"
16#include "llvm/ADT/StringRef.h"
17#include <optional>
18
19namespace clang::ssaf {
20
21/// Maps a declaration to an EntityName.
22///
23/// Supported declaration types for entity mapping:
24/// - Functions and methods
25/// - Global Variables
26/// - Function parameters
27/// - Struct/class/union type definitions
28/// - Struct/class/union fields
29///
30/// Implicit declarations and compiler builtins are not mapped.
31///
32/// \param D The declaration to map. Must not be null.
33///
34/// \return An EntityName if the declaration can be mapped, std::nullopt
35/// otherwise.
36std::optional<EntityName> getEntityName(const Decl *D);
37
38/// Maps return entity of a function to an EntityName.
39/// The returned name uniquely identifies the return value of function \param
40/// FD.
41///
42/// \param FD The function declaration. Must not be null.
43///
44/// \return An EntityName for the function's return entity.
45std::optional<EntityName> getEntityNameForReturn(const FunctionDecl *FD);
46
47/// Computes the SSAF linkage of a declaration.
48///
49/// \param D The declaration to classify. Must not be null.
51
52/// Returns the EntityName qualified with the build namespaces
53/// it would carry after linking into \p LUNamespace.
54///
55/// \param D The declaration to map. Must not be null.
56/// \param TUNamespace The CompilationUnit namespace of a translation unit.
57/// \param LUNamespace The LinkUnit namespace the translation unit links into.
58/// \return The qualified EntityName if the declaration can be mapped,
59/// std::nullopt otherwise.
60std::optional<EntityName>
61getQualifiedEntityName(const Decl *D, const NestedBuildNamespace &TUNamespace,
62 const NestedBuildNamespace &LUNamespace);
63
64/// Similar to `getQualifiedEntityName`, but for entities of function return
65/// values.
66std::optional<EntityName>
67getQualifiedEntityNameForReturn(const FunctionDecl *FD,
68 const NestedBuildNamespace &TUNamespace,
69 const NestedBuildNamespace &LUNamespace);
70
71} // namespace clang::ssaf
72
73#endif // LLVM_CLANG_SCALABLESTATICANALYSIS_CORE_ASTENTITYMAPPING_H
Represents a hierarchical sequence of build namespaces.
std::optional< EntityName > getEntityNameForReturn(const FunctionDecl *FD)
Maps return entity of a function to an EntityName.
EntityLinkageType getLinkageForDecl(const Decl *D)
Computes the SSAF linkage of a declaration.
std::optional< EntityName > getQualifiedEntityNameForReturn(const FunctionDecl *FD, const NestedBuildNamespace &TUNamespace, const NestedBuildNamespace &LUNamespace)
Similar to getQualifiedEntityName, but for entities of function return values.
std::optional< EntityName > getQualifiedEntityName(const Decl *D, const NestedBuildNamespace &TUNamespace, const NestedBuildNamespace &LUNamespace)
Returns the EntityName qualified with the build namespaces it would carry after linking into LUNamesp...
std::optional< EntityName > getEntityName(const Decl *D)
Maps a declaration to an EntityName.