/Users/buildslave/jenkins/workspace/coverage/llvm-project/clang/include/clang/Sema/Weak.h
Line | Count | Source |
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 | | |
17 | | #include "clang/Basic/SourceLocation.h" |
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; |
30 | | WeakInfo(const IdentifierInfo *Alias, SourceLocation Loc) |
31 | 2.65k | : alias(Alias), loc(Loc) {} |
32 | 7.86k | inline const IdentifierInfo *getAlias() const { return alias; } |
33 | 172 | inline SourceLocation getLocation() const { return loc; } |
34 | | bool operator==(WeakInfo RHS) const = delete; |
35 | | bool operator!=(WeakInfo RHS) const = delete; |
36 | | |
37 | | struct DenseMapInfoByAliasOnly |
38 | | : private llvm::DenseMapInfo<const IdentifierInfo *> { |
39 | 1.55k | static inline WeakInfo getEmptyKey() { |
40 | 1.55k | return WeakInfo(DenseMapInfo::getEmptyKey(), SourceLocation()); |
41 | 1.55k | } |
42 | 980 | static inline WeakInfo getTombstoneKey() { |
43 | 980 | return WeakInfo(DenseMapInfo::getTombstoneKey(), SourceLocation()); |
44 | 980 | } |
45 | 120 | static unsigned getHashValue(const WeakInfo &W) { |
46 | 120 | return DenseMapInfo::getHashValue(W.getAlias()); |
47 | 120 | } |
48 | 3.80k | static bool isEqual(const WeakInfo &LHS, const WeakInfo &RHS) { |
49 | 3.80k | return DenseMapInfo::isEqual(LHS.getAlias(), RHS.getAlias()); |
50 | 3.80k | } |
51 | | }; |
52 | | }; |
53 | | |
54 | | } // end namespace clang |
55 | | |
56 | | #endif // LLVM_CLANG_SEMA_WEAK_H |