LLDB mainline
Identifier.h
Go to the documentation of this file.
1//===-- Identifier.h --------------------------------------------*- 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 LLDB_SOURCE_PLUGINS_TYPESYSTEM_CLIKE_IDENTIFIER_H
10#define LLDB_SOURCE_PLUGINS_TYPESYSTEM_CLIKE_IDENTIFIER_H
11
12#include "llvm/ADT/DenseSet.h"
13#include "llvm/ADT/StringRef.h"
14#include "llvm/Support/Allocator.h"
15
16#include <vector>
17
18namespace lldb_private {
19namespace clike {
20
21class IdentifierMap;
22
23/// Represents a name in TypeSystemClike.
25public:
26 Identifier() = default;
27
28 llvm::StringRef GetName() const { return m_name; }
29
30private:
31 // Only IdentifierMap may build a non-empty Identifier.
32 friend class IdentifierMap;
33 explicit Identifier(llvm::StringRef name) : m_name(name) {}
34
35 llvm::StringRef m_name;
36};
37
38/// Turns strings into unique Identifier objects.
40public:
42
43 /// Returns an Identifier for \p name.
44 ///
45 /// This copies the string into storage owned by this map.
46 Identifier get(llvm::StringRef name);
47
48 /// Returns an Identifier for \p name.
49 ///
50 /// This does not make a copy of the passed string and the string storage
51 /// needs to outlive this IdentifierMap. This is used if `name` is a string
52 /// literal or backed by ConstString.
53 Identifier getWithStaticStorageStr(llvm::StringRef name);
54
55private:
56 /// Owns the copies made by get().
57 llvm::BumpPtrAllocator m_string_storage;
58 /// Set of all created Identifiers strings.
59 llvm::DenseSet<llvm::StringRef> m_names;
60};
61
62} // namespace clike
63} // namespace lldb_private
64
65#endif // LLDB_SOURCE_PLUGINS_TYPESYSTEM_CLIKE_IDENTIFIER_H
Turns strings into unique Identifier objects.
Definition Identifier.h:39
llvm::DenseSet< llvm::StringRef > m_names
Set of all created Identifiers strings.
Definition Identifier.h:59
Identifier get(llvm::StringRef name)
Returns an Identifier for name.
llvm::BumpPtrAllocator m_string_storage
Owns the copies made by get().
Definition Identifier.h:57
Identifier getWithStaticStorageStr(llvm::StringRef name)
Returns an Identifier for name.
Represents a name in TypeSystemClike.
Definition Identifier.h:24
llvm::StringRef GetName() const
Definition Identifier.h:28
Identifier(llvm::StringRef name)
Definition Identifier.h:33
A class that represents a running process on the host machine.