Coverage Report

Created: 2020-02-18 08:44

/Users/buildslave/jenkins/workspace/coverage/llvm-project/clang/lib/Driver/OptionUtils.cpp
Line
Count
Source (jump to first uncovered line)
1
//===--- OptionUtils.cpp - Utilities for command line arguments -----------===//
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
#include "clang/Basic/Diagnostic.h"
10
#include "clang/Basic/DiagnosticDriver.h"
11
#include "clang/Driver/OptionUtils.h"
12
#include "llvm/Option/ArgList.h"
13
14
using namespace clang;
15
using namespace llvm::opt;
16
17
namespace {
18
template <typename IntTy>
19
IntTy getLastArgIntValueImpl(const ArgList &Args, OptSpecifier Id,
20
                             IntTy Default, DiagnosticsEngine *Diags,
21
2.01M
                             unsigned Base) {
22
2.01M
  IntTy Res = Default;
23
2.01M
  if (Arg *A = Args.getLastArg(Id)) {
24
94.2k
    if (StringRef(A->getValue()).getAsInteger(Base, Res)) {
25
0
      if (Diags)
26
0
        Diags->Report(diag::err_drv_invalid_int_value)
27
0
            << A->getAsString(Args) << A->getValue();
28
0
    }
29
94.2k
  }
30
2.01M
  return Res;
31
2.01M
}
OptionUtils.cpp:int (anonymous namespace)::getLastArgIntValueImpl<int>(llvm::opt::ArgList const&, llvm::opt::OptSpecifier, int, clang::DiagnosticsEngine*, unsigned int)
Line
Count
Source
21
1.92M
                             unsigned Base) {
22
1.92M
  IntTy Res = Default;
23
1.92M
  if (Arg *A = Args.getLastArg(Id)) {
24
94.1k
    if (StringRef(A->getValue()).getAsInteger(Base, Res)) {
25
0
      if (Diags)
26
0
        Diags->Report(diag::err_drv_invalid_int_value)
27
0
            << A->getAsString(Args) << A->getValue();
28
0
    }
29
94.1k
  }
30
1.92M
  return Res;
31
1.92M
}
OptionUtils.cpp:unsigned long long (anonymous namespace)::getLastArgIntValueImpl<unsigned long long>(llvm::opt::ArgList const&, llvm::opt::OptSpecifier, unsigned long long, clang::DiagnosticsEngine*, unsigned int)
Line
Count
Source
21
89.4k
                             unsigned Base) {
22
89.4k
  IntTy Res = Default;
23
89.4k
  if (Arg *A = Args.getLastArg(Id)) {
24
18
    if (StringRef(A->getValue()).getAsInteger(Base, Res)) {
25
0
      if (Diags)
26
0
        Diags->Report(diag::err_drv_invalid_int_value)
27
0
            << A->getAsString(Args) << A->getValue();
28
0
    }
29
18
  }
30
89.4k
  return Res;
31
89.4k
}
32
} // namespace
33
34
namespace clang {
35
36
int getLastArgIntValue(const ArgList &Args, OptSpecifier Id, int Default,
37
1.92M
                       DiagnosticsEngine *Diags, unsigned Base) {
38
1.92M
  return getLastArgIntValueImpl<int>(Args, Id, Default, Diags, Base);
39
1.92M
}
40
41
uint64_t getLastArgUInt64Value(const ArgList &Args, OptSpecifier Id,
42
                               uint64_t Default, DiagnosticsEngine *Diags,
43
89.4k
                               unsigned Base) {
44
89.4k
  return getLastArgIntValueImpl<uint64_t>(Args, Id, Default, Diags, Base);
45
89.4k
}
46
47
} // namespace clang