Coverage Report

Created: 2019-07-24 05:18

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/include/llvm/IR/GlobalIndirectSymbol.h
Line
Count
Source (jump to first uncovered line)
1
//===- llvm/GlobalIndirectSymbol.h - GlobalIndirectSymbol class -*- 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 contains the declaration of the GlobalIndirectSymbol class, which
10
// is a base class for GlobalAlias and GlobalIFunc. It contains all common code
11
// for aliases and ifuncs.
12
//
13
//===----------------------------------------------------------------------===//
14
15
#ifndef LLVM_IR_GLOBALINDIRECTSYMBOL_H
16
#define LLVM_IR_GLOBALINDIRECTSYMBOL_H
17
18
#include "llvm/IR/GlobalObject.h"
19
#include "llvm/IR/GlobalValue.h"
20
#include "llvm/IR/OperandTraits.h"
21
#include "llvm/IR/User.h"
22
#include "llvm/IR/Value.h"
23
#include "llvm/Support/Casting.h"
24
#include <cstddef>
25
26
namespace llvm {
27
28
class GlobalIndirectSymbol : public GlobalValue {
29
protected:
30
  GlobalIndirectSymbol(Type *Ty, ValueTy VTy, unsigned AddressSpace,
31
      LinkageTypes Linkage, const Twine &Name, Constant *Symbol);
32
33
public:
34
  GlobalIndirectSymbol(const GlobalIndirectSymbol &) = delete;
35
  GlobalIndirectSymbol &operator=(const GlobalIndirectSymbol &) = delete;
36
37
  // allocate space for exactly one operand
38
3.99k
  void *operator new(size_t s) {
39
3.99k
    return User::operator new(s, 1);
40
3.99k
  }
41
42
  /// Provide fast operand accessors
43
  DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Constant);
44
45
  /// These methods set and retrieve indirect symbol.
46
1.04k
  void setIndirectSymbol(Constant *Symbol) {
47
1.04k
    setOperand(0, Symbol);
48
1.04k
  }
49
23.5k
  const Constant *getIndirectSymbol() const {
50
23.5k
    return getOperand(0);
51
23.5k
  }
52
2.91k
  Constant *getIndirectSymbol() {
53
2.91k
    return const_cast<Constant *>(
54
2.91k
          static_cast<const GlobalIndirectSymbol *>(this)->getIndirectSymbol());
55
2.91k
  }
56
57
8.21k
  const GlobalObject *getBaseObject() const {
58
8.21k
    return dyn_cast<GlobalObject>(getIndirectSymbol()->stripInBoundsOffsets());
59
8.21k
  }
60
106
  GlobalObject *getBaseObject() {
61
106
    return const_cast<GlobalObject *>(
62
106
              static_cast<const GlobalIndirectSymbol *>(this)->getBaseObject());
63
106
  }
64
65
0
  const GlobalObject *getBaseObject(const DataLayout &DL, APInt &Offset) const {
66
0
    return dyn_cast<GlobalObject>(
67
0
        getIndirectSymbol()->stripAndAccumulateInBoundsConstantOffsets(DL,
68
0
                                                                       Offset));
69
0
  }
70
0
  GlobalObject *getBaseObject(const DataLayout &DL, APInt &Offset) {
71
0
    return const_cast<GlobalObject *>(
72
0
                                 static_cast<const GlobalIndirectSymbol *>(this)
73
0
                                   ->getBaseObject(DL, Offset));
74
0
  }
75
76
  // Methods for support type inquiry through isa, cast, and dyn_cast:
77
1.20k
  static bool classof(const Value *V) {
78
1.20k
    return V->getValueID() == Value::GlobalAliasVal ||
79
1.20k
           
V->getValueID() == Value::GlobalIFuncVal224
;
80
1.20k
  }
81
};
82
83
template <>
84
struct OperandTraits<GlobalIndirectSymbol> :
85
  public FixedNumOperandTraits<GlobalIndirectSymbol, 1> {
86
};
87
88
DEFINE_TRANSPARENT_OPERAND_ACCESSORS(GlobalIndirectSymbol, Constant)
89
90
} // end namespace llvm
91
92
#endif // LLVM_IR_GLOBALINDIRECTSYMBOL_H