Coverage Report

Created: 2019-07-24 05:18

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/lib/IR/Comdat.cpp
Line
Count
Source (jump to first uncovered line)
1
//===- Comdat.cpp - Implement Metadata classes ----------------------------===//
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 implements the Comdat class (including the C bindings).
10
//
11
//===----------------------------------------------------------------------===//
12
13
#include "llvm-c/Comdat.h"
14
#include "llvm/ADT/StringMap.h"
15
#include "llvm/ADT/StringRef.h"
16
#include "llvm/IR/Comdat.h"
17
#include "llvm/IR/GlobalObject.h"
18
#include "llvm/IR/Module.h"
19
20
using namespace llvm;
21
22
64.6k
Comdat::Comdat(Comdat &&C) : Name(C.Name), SK(C.SK) {}
23
24
32.3k
Comdat::Comdat() = default;
25
26
93.5k
StringRef Comdat::getName() const { return Name->first(); }
27
28
0
LLVMComdatRef LLVMGetOrInsertComdat(LLVMModuleRef M, const char *Name) {
29
0
  return wrap(unwrap(M)->getOrInsertComdat(Name));
30
0
}
31
32
0
LLVMComdatRef LLVMGetComdat(LLVMValueRef V) {
33
0
  GlobalObject *G = unwrap<GlobalObject>(V);
34
0
  return wrap(G->getComdat());
35
0
}
36
37
0
void LLVMSetComdat(LLVMValueRef V, LLVMComdatRef C) {
38
0
  GlobalObject *G = unwrap<GlobalObject>(V);
39
0
  G->setComdat(unwrap(C));
40
0
}
41
42
0
LLVMComdatSelectionKind LLVMGetComdatSelectionKind(LLVMComdatRef C) {
43
0
  switch (unwrap(C)->getSelectionKind()) {
44
0
  case Comdat::Any:
45
0
    return LLVMAnyComdatSelectionKind;
46
0
  case Comdat::ExactMatch:
47
0
    return LLVMExactMatchComdatSelectionKind;
48
0
  case Comdat::Largest:
49
0
    return LLVMLargestComdatSelectionKind;
50
0
  case Comdat::NoDuplicates:
51
0
    return LLVMNoDuplicatesComdatSelectionKind;
52
0
  case Comdat::SameSize:
53
0
    return LLVMSameSizeComdatSelectionKind;
54
0
  }
55
0
  llvm_unreachable("Invalid Comdat SelectionKind!");
56
0
}
57
58
void LLVMSetComdatSelectionKind(LLVMComdatRef C, LLVMComdatSelectionKind kind) {
59
  Comdat *Cd = unwrap(C);
60
  switch (kind) {
61
  case LLVMAnyComdatSelectionKind:
62
    Cd->setSelectionKind(Comdat::Any);
63
    break;
64
  case LLVMExactMatchComdatSelectionKind:
65
    Cd->setSelectionKind(Comdat::ExactMatch);
66
    break;
67
  case LLVMLargestComdatSelectionKind:
68
    Cd->setSelectionKind(Comdat::Largest);
69
    break;
70
  case LLVMNoDuplicatesComdatSelectionKind:
71
    Cd->setSelectionKind(Comdat::NoDuplicates);
72
    break;
73
  case LLVMSameSizeComdatSelectionKind:
74
    Cd->setSelectionKind(Comdat::SameSize);
75
    break;
76
  }
77
}