LCOV - code coverage report
Current view: top level - lib/IR - Comdat.cpp (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 2 19 10.5 %
Date: 2018-10-20 13:21:21 Functions: 2 7 28.6 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //===- Comdat.cpp - Implement Metadata classes ----------------------------===//
       2             : //
       3             : //                     The LLVM Compiler Infrastructure
       4             : //
       5             : // This file is distributed under the University of Illinois Open Source
       6             : // License. See LICENSE.TXT for details.
       7             : //
       8             : //===----------------------------------------------------------------------===//
       9             : //
      10             : // This file implements the Comdat class (including the C bindings).
      11             : //
      12             : //===----------------------------------------------------------------------===//
      13             : 
      14             : #include "llvm-c/Comdat.h"
      15             : #include "llvm/ADT/StringMap.h"
      16             : #include "llvm/ADT/StringRef.h"
      17             : #include "llvm/IR/Comdat.h"
      18             : #include "llvm/IR/GlobalObject.h"
      19             : #include "llvm/IR/Module.h"
      20             : 
      21             : using namespace llvm;
      22             : 
      23     1434104 : Comdat::Comdat(Comdat &&C) : Name(C.Name), SK(C.SK) {}
      24             : 
      25             : Comdat::Comdat() = default;
      26             : 
      27      624418 : StringRef Comdat::getName() const { return Name->first(); }
      28             : 
      29           0 : LLVMComdatRef LLVMGetOrInsertComdat(LLVMModuleRef M, const char *Name) {
      30           0 :   return wrap(unwrap(M)->getOrInsertComdat(Name));
      31             : }
      32             : 
      33           0 : LLVMComdatRef LLVMGetComdat(LLVMValueRef V) {
      34             :   GlobalObject *G = unwrap<GlobalObject>(V);
      35           0 :   return wrap(G->getComdat());
      36             : }
      37             : 
      38           0 : void LLVMSetComdat(LLVMValueRef V, LLVMComdatRef C) {
      39             :   GlobalObject *G = unwrap<GlobalObject>(V);
      40             :   G->setComdat(unwrap(C));
      41           0 : }
      42             : 
      43           0 : LLVMComdatSelectionKind LLVMGetComdatSelectionKind(LLVMComdatRef C) {
      44           0 :   switch (unwrap(C)->getSelectionKind()) {
      45             :   case Comdat::Any:
      46             :     return LLVMAnyComdatSelectionKind;
      47             :   case Comdat::ExactMatch:
      48             :     return LLVMExactMatchComdatSelectionKind;
      49             :   case Comdat::Largest:
      50             :     return LLVMLargestComdatSelectionKind;
      51             :   case Comdat::NoDuplicates:
      52             :     return LLVMNoDuplicatesComdatSelectionKind;
      53             :   case Comdat::SameSize:
      54             :     return LLVMSameSizeComdatSelectionKind;
      55             :   }
      56           0 :   llvm_unreachable("Invalid Comdat SelectionKind!");
      57             : }
      58             : 
      59           0 : void LLVMSetComdatSelectionKind(LLVMComdatRef C, LLVMComdatSelectionKind kind) {
      60             :   Comdat *Cd = unwrap(C);
      61           0 :   switch (kind) {
      62           0 :   case LLVMAnyComdatSelectionKind:
      63             :     Cd->setSelectionKind(Comdat::Any);
      64             :     break;
      65           0 :   case LLVMExactMatchComdatSelectionKind:
      66             :     Cd->setSelectionKind(Comdat::ExactMatch);
      67             :     break;
      68           0 :   case LLVMLargestComdatSelectionKind:
      69             :     Cd->setSelectionKind(Comdat::Largest);
      70             :     break;
      71           0 :   case LLVMNoDuplicatesComdatSelectionKind:
      72             :     Cd->setSelectionKind(Comdat::NoDuplicates);
      73             :     break;
      74           0 :   case LLVMSameSizeComdatSelectionKind:
      75             :     Cd->setSelectionKind(Comdat::SameSize);
      76             :     break;
      77             :   }
      78           0 : }

Generated by: LCOV version 1.13