LCOV - code coverage report
Current view: top level - lib/FuzzMutate - OpDescriptor.cpp (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 20 20 100.0 %
Date: 2017-09-14 15:23:50 Functions: 2 2 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //===-- OpDescriptor.cpp --------------------------------------------------===//
       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             : #include "llvm/FuzzMutate/OpDescriptor.h"
      11             : #include "llvm/IR/Constants.h"
      12             : 
      13             : using namespace llvm;
      14             : using namespace fuzzerop;
      15             : 
      16          12 : void fuzzerop::makeConstantsWithType(Type *T, std::vector<Constant *> &Cs) {
      17           5 :   if (auto *IntTy = dyn_cast<IntegerType>(T)) {
      18           5 :     uint64_t W = IntTy->getBitWidth();
      19          20 :     Cs.push_back(ConstantInt::get(IntTy, APInt::getMaxValue(W)));
      20          15 :     Cs.push_back(ConstantInt::get(IntTy, APInt::getMinValue(W)));
      21          15 :     Cs.push_back(ConstantInt::get(IntTy, APInt::getSignedMaxValue(W)));
      22          15 :     Cs.push_back(ConstantInt::get(IntTy, APInt::getSignedMinValue(W)));
      23          15 :     Cs.push_back(ConstantInt::get(IntTy, APInt::getOneBitSet(W, W / 2)));
      24           4 :   } else if (T->isFloatingPointTy()) {
      25           3 :     auto &Ctx = T->getContext();
      26           3 :     auto &Sem = T->getFltSemantics();
      27           9 :     Cs.push_back(ConstantFP::get(Ctx, APFloat::getZero(Sem)));
      28           9 :     Cs.push_back(ConstantFP::get(Ctx, APFloat::getLargest(Sem)));
      29           9 :     Cs.push_back(ConstantFP::get(Ctx, APFloat::getSmallest(Sem)));
      30             :   } else
      31           8 :     Cs.push_back(UndefValue::get(T));
      32          12 : }
      33             : 
      34           4 : std::vector<Constant *> fuzzerop::makeConstantsWithType(Type *T) {
      35           4 :   std::vector<Constant *> Result;
      36           4 :   makeConstantsWithType(T, Result);
      37           4 :   return Result;
      38             : }

Generated by: LCOV version 1.13