clang 24.0.0git
TUSummaryExtractor.cpp
Go to the documentation of this file.
1//===- TUSummaryExtractor.cpp ---------------------------------------------===//
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
10#include "clang/AST/Decl.h"
11#include "clang/AST/DeclBase.h"
16#include "llvm/Support/Casting.h"
17#include <optional>
18
19using namespace clang;
20using namespace ssaf;
21
22std::optional<EntityId> TUSummaryExtractor::addEntity(const NamedDecl *D) {
23 auto Name = getEntityName(D);
24 if (!Name)
25 return std::nullopt;
26 return SummaryBuilder.addEntity(*Name, getLinkageForDecl(D));
27}
28
29std::optional<EntityId>
31 auto Name = getEntityNameForReturn(FD);
32 if (!Name)
33 return std::nullopt;
34 return SummaryBuilder.addEntity(*Name, getLinkageForDecl(FD));
35}
36
38 return SummaryBuilder.getOptions();
39}
Represents a function declaration or definition.
Definition Decl.h:2059
This represents a decl that may have a name.
Definition Decl.h:275
std::optional< EntityId > addEntityForReturn(const FunctionDecl *FD)
Creates EntityName for the return value of FD, registers the entity, and sets its linkage atomically.
const SSAFOptions & getOptions() const
std::optional< EntityId > addEntity(const NamedDecl *D)
Creates EntityName from the Decl, registers the entity, and sets its linkage atomically.
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 > getEntityName(const Decl *D)
Maps a declaration to an EntityName.
Top level wrappers for InstallAPI frontend operations.