From 7fa27ce4a07f19b07799a767fc29416f3b625afb Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Wed, 26 Jul 2023 21:03:47 +0200 Subject: Vendor import of llvm-project main llvmorg-17-init-19304-gd0b54bb50e51, the last commit before the upstream release/17.x branch was created. --- llvm/lib/TextAPI/SymbolSet.cpp | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 llvm/lib/TextAPI/SymbolSet.cpp (limited to 'llvm/lib/TextAPI/SymbolSet.cpp') diff --git a/llvm/lib/TextAPI/SymbolSet.cpp b/llvm/lib/TextAPI/SymbolSet.cpp new file mode 100644 index 000000000000..157e13749729 --- /dev/null +++ b/llvm/lib/TextAPI/SymbolSet.cpp @@ -0,0 +1,36 @@ +//===- lib/TextAPI/SymbolSet.cpp - TAPI Symbol Set ------------*- 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 "llvm/TextAPI/SymbolSet.h" + +using namespace llvm; +using namespace llvm::MachO; + +Symbol *SymbolSet::addGlobalImpl(SymbolKind Kind, StringRef Name, + SymbolFlags Flags) { + Name = copyString(Name); + auto Result = Symbols.try_emplace(SymbolsMapKey{Kind, Name}, nullptr); + if (Result.second) + Result.first->second = + new (Allocator) Symbol{Kind, Name, TargetList(), Flags}; + return Result.first->second; +} + +Symbol *SymbolSet::addGlobal(SymbolKind Kind, StringRef Name, SymbolFlags Flags, + const Target &Targ) { + auto *Sym = addGlobalImpl(Kind, Name, Flags); + Sym->addTarget(Targ); + return Sym; +} + +const Symbol *SymbolSet::findSymbol(SymbolKind Kind, StringRef Name) const { + auto It = Symbols.find({Kind, Name}); + if (It != Symbols.end()) + return It->second; + return nullptr; +} -- cgit v1.2.3