clang  15.0.0git
Weak.h
Go to the documentation of this file.
1 //===-- UnresolvedSet.h - Unresolved sets of declarations ------*- 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 // This file defines the WeakInfo class, which is used to store
10 // information about the target of a #pragma weak directive.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_CLANG_SEMA_WEAK_H
15 #define LLVM_CLANG_SEMA_WEAK_H
16 
18 #include "llvm/ADT/DenseMapInfo.h"
19 
20 namespace clang {
21 
22 class IdentifierInfo;
23 
24 /// Captures information about a \#pragma weak directive.
25 class WeakInfo {
26  const IdentifierInfo *alias = nullptr; // alias (optional)
27  SourceLocation loc; // for diagnostics
28 public:
29  WeakInfo() = default;
31  : alias(Alias), loc(Loc) {}
32  inline const IdentifierInfo *getAlias() const { return alias; }
33  inline SourceLocation getLocation() const { return loc; }
34  bool operator==(WeakInfo RHS) const = delete;
35  bool operator!=(WeakInfo RHS) const = delete;
36 
38  : private llvm::DenseMapInfo<const IdentifierInfo *> {
39  static inline WeakInfo getEmptyKey() {
40  return WeakInfo(DenseMapInfo::getEmptyKey(), SourceLocation());
41  }
42  static inline WeakInfo getTombstoneKey() {
43  return WeakInfo(DenseMapInfo::getTombstoneKey(), SourceLocation());
44  }
45  static unsigned getHashValue(const WeakInfo &W) {
46  return DenseMapInfo::getHashValue(W.getAlias());
47  }
48  static bool isEqual(const WeakInfo &LHS, const WeakInfo &RHS) {
49  return DenseMapInfo::isEqual(LHS.getAlias(), RHS.getAlias());
50  }
51  };
52 };
53 
54 } // end namespace clang
55 
56 #endif // LLVM_CLANG_SEMA_WEAK_H
clang::WeakInfo::operator==
bool operator==(WeakInfo RHS) const =delete
clang::WeakInfo::DenseMapInfoByAliasOnly::isEqual
static bool isEqual(const WeakInfo &LHS, const WeakInfo &RHS)
Definition: Weak.h:48
clang::SourceLocation
Encodes a location in the source.
Definition: SourceLocation.h:86
clang::WeakInfo::getAlias
const IdentifierInfo * getAlias() const
Definition: Weak.h:32
clang::WeakInfo::DenseMapInfoByAliasOnly::getTombstoneKey
static WeakInfo getTombstoneKey()
Definition: Weak.h:42
clang::WeakInfo::DenseMapInfoByAliasOnly::getEmptyKey
static WeakInfo getEmptyKey()
Definition: Weak.h:39
clang::WeakInfo::operator!=
bool operator!=(WeakInfo RHS) const =delete
clang::WeakInfo
Captures information about a #pragma weak directive.
Definition: Weak.h:25
SourceLocation.h
clang::WeakInfo::getLocation
SourceLocation getLocation() const
Definition: Weak.h:33
clang::IdentifierInfo
One of these records is kept for each identifier that is lexed.
Definition: IdentifierTable.h:84
clang::WeakInfo::WeakInfo
WeakInfo()=default
clang
Definition: CalledOnceCheck.h:17
clang::WeakInfo::WeakInfo
WeakInfo(const IdentifierInfo *Alias, SourceLocation Loc)
Definition: Weak.h:30
clang::WeakInfo::DenseMapInfoByAliasOnly
Definition: Weak.h:37
clang::WeakInfo::DenseMapInfoByAliasOnly::getHashValue
static unsigned getHashValue(const WeakInfo &W)
Definition: Weak.h:45