Coverage Report

Created: 2018-01-17 21:32

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/tools/lld/Common/Args.cpp
Line
Count
Source (jump to first uncovered line)
1
//===- Args.cpp -----------------------------------------------------------===//
2
//
3
//                             The LLVM Linker
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 "lld/Common/Args.h"
11
#include "lld/Common/ErrorHandler.h"
12
#include "llvm/ADT/SmallVector.h"
13
#include "llvm/ADT/StringExtras.h"
14
#include "llvm/ADT/StringRef.h"
15
#include "llvm/Option/ArgList.h"
16
17
using namespace llvm;
18
using namespace lld;
19
20
5.14k
int lld::args::getInteger(opt::InputArgList &Args, unsigned Key, int Default) {
21
5.14k
  int V = Default;
22
5.14k
  if (auto *Arg = Args.getLastArg(Key)) {
23
16
    StringRef S = Arg->getValue();
24
16
    if (!to_integer(S, V, 10))
25
0
      error(Arg->getSpelling() + ": number expected, but got '" + S + "'");
26
16
  }
27
5.14k
  return V;
28
5.14k
}
29
30
5.14k
std::vector<StringRef> lld::args::getStrings(opt::InputArgList &Args, int Id) {
31
5.14k
  std::vector<StringRef> V;
32
5.14k
  for (auto *Arg : Args.filtered(Id))
33
29
    V.push_back(Arg->getValue());
34
5.14k
  return V;
35
5.14k
}
36
37
uint64_t lld::args::getZOptionValue(opt::InputArgList &Args, int Id,
38
1.99k
                                    StringRef Key, uint64_t Default) {
39
1.99k
  for (auto *Arg : Args.filtered(Id)) {
40
50
    std::pair<StringRef, StringRef> KV = StringRef(Arg->getValue()).split('=');
41
50
    if (KV.first == Key) {
42
7
      uint64_t Result = Default;
43
7
      if (!to_integer(KV.second, Result))
44
1
        error("invalid " + Key + ": " + KV.second);
45
7
      return Result;
46
7
    }
47
50
  }
48
1.99k
  
return Default1.98k
;
49
1.99k
}
50
51
4
std::vector<StringRef> lld::args::getLines(MemoryBufferRef MB) {
52
4
  SmallVector<StringRef, 0> Arr;
53
4
  MB.getBuffer().split(Arr, '\n');
54
4
55
4
  std::vector<StringRef> Ret;
56
11
  for (StringRef S : Arr) {
57
11
    S = S.trim();
58
11
    if (!S.empty() && 
S[0] != '#'6
)
59
6
      Ret.push_back(S);
60
11
  }
61
4
  return Ret;
62
4
}