Coverage Report

Created: 2019-07-24 05:18

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/tools/clang/include/clang/AST/DeclAccessPair.h
Line
Count
Source
1
//===--- DeclAccessPair.h - A decl bundled with its path access -*- 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 DeclAccessPair class, which provides an
10
//  efficient representation of a pair of a NamedDecl* and an
11
//  AccessSpecifier.  Generally the access specifier gives the
12
//  natural access of a declaration when named in a class, as
13
//  defined in C++ [class.access.base]p1.
14
//
15
//===----------------------------------------------------------------------===//
16
17
#ifndef LLVM_CLANG_AST_DECLACCESSPAIR_H
18
#define LLVM_CLANG_AST_DECLACCESSPAIR_H
19
20
#include "clang/Basic/Specifiers.h"
21
#include "llvm/Support/DataTypes.h"
22
23
namespace clang {
24
25
class NamedDecl;
26
27
/// A POD class for pairing a NamedDecl* with an access specifier.
28
/// Can be put into unions.
29
class DeclAccessPair {
30
  uintptr_t Ptr; // we'd use llvm::PointerUnion, but it isn't trivial
31
32
  enum { Mask = 0x3 };
33
34
public:
35
119M
  static DeclAccessPair make(NamedDecl *D, AccessSpecifier AS) {
36
119M
    DeclAccessPair p;
37
119M
    p.set(D, AS);
38
119M
    return p;
39
119M
  }
40
41
372M
  NamedDecl *getDecl() const {
42
372M
    return reinterpret_cast<NamedDecl*>(~Mask & Ptr);
43
372M
  }
44
13.0M
  AccessSpecifier getAccess() const {
45
13.0M
    return AccessSpecifier(Mask & Ptr);
46
13.0M
  }
47
48
48
  void setDecl(NamedDecl *D) {
49
48
    set(D, getAccess());
50
48
  }
51
51.8k
  void setAccess(AccessSpecifier AS) {
52
51.8k
    set(getDecl(), AS);
53
51.8k
  }
54
119M
  void set(NamedDecl *D, AccessSpecifier AS) {
55
119M
    Ptr = uintptr_t(AS) | reinterpret_cast<uintptr_t>(D);
56
119M
  }
57
58
28.8M
  operator NamedDecl*() const { return getDecl(); }
59
66.9M
  NamedDecl *operator->() const { return getDecl(); }
60
};
61
}
62
63
#endif