Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
14 | pmbaty | 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 | : 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 | |||
37 | struct DenseMapInfoByAliasOnly |
||
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 |