aboutsummaryrefslogtreecommitdiff
path: root/contrib/llvm-project/llvm/lib/TextAPI/SymbolSet.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2023-09-02 21:17:18 +0000
committerDimitry Andric <dim@FreeBSD.org>2023-12-08 17:34:50 +0000
commit06c3fb2749bda94cb5201f81ffdb8fa6c3161b2e (patch)
tree62f873df87c7c675557a179e0c4c83fe9f3087bc /contrib/llvm-project/llvm/lib/TextAPI/SymbolSet.cpp
parentcf037972ea8863e2bab7461d77345367d2c1e054 (diff)
parent7fa27ce4a07f19b07799a767fc29416f3b625afb (diff)
Diffstat (limited to 'contrib/llvm-project/llvm/lib/TextAPI/SymbolSet.cpp')
-rw-r--r--contrib/llvm-project/llvm/lib/TextAPI/SymbolSet.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/contrib/llvm-project/llvm/lib/TextAPI/SymbolSet.cpp b/contrib/llvm-project/llvm/lib/TextAPI/SymbolSet.cpp
new file mode 100644
index 000000000000..157e13749729
--- /dev/null
+++ b/contrib/llvm-project/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;
+}