| 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 | |
| 9 | #include "clang/ScalableStaticAnalysis/Core/TUSummary/TUSummaryExtractor.h" |
| 10 | #include "clang/AST/Decl.h" |
| 11 | #include "clang/AST/DeclBase.h" |
| 12 | #include "clang/ScalableStaticAnalysis/Core/ASTEntityMapping.h" |
| 13 | #include "clang/ScalableStaticAnalysis/Core/Model/EntityId.h" |
| 14 | #include "clang/ScalableStaticAnalysis/Core/Model/EntityLinkage.h" |
| 15 | #include "clang/ScalableStaticAnalysis/Core/TUSummary/TUSummaryBuilder.h" |
| 16 | #include "llvm/Support/Casting.h" |
| 17 | #include <optional> |
| 18 | |
| 19 | using namespace clang; |
| 20 | using namespace ssaf; |
| 21 | |
| 22 | std::optional<EntityId> TUSummaryExtractor::addEntity(const NamedDecl *D) { |
| 23 | auto Name = getEntityName(D); |
| 24 | if (!Name) |
| 25 | return std::nullopt; |
| 26 | return SummaryBuilder.addEntity(EN: *Name, Linkage: getLinkageForDecl(D)); |
| 27 | } |
| 28 | |
| 29 | std::optional<EntityId> |
| 30 | TUSummaryExtractor::addEntityForReturn(const FunctionDecl *FD) { |
| 31 | auto Name = getEntityNameForReturn(FD); |
| 32 | if (!Name) |
| 33 | return std::nullopt; |
| 34 | return SummaryBuilder.addEntity(EN: *Name, Linkage: getLinkageForDecl(D: FD)); |
| 35 | } |
| 36 | |
| 37 | const SSAFOptions &TUSummaryExtractor::getOptions() const { |
| 38 | return SummaryBuilder.getOptions(); |
| 39 | } |
| 40 |