Coverage Report

Created: 2020-09-22 08:39

/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
3.17M
                             unsigned Base) {
22
3.17M
  IntTy Res = Default;
23
3.17M
  if (Arg *A = Args.getLastArg(Id)) {
24
105k
    if (StringRef(A->getValue()).getAsInteger(Base, Res)) {
25
1
      if (Diags)
26
0
        Diags->Report(diag::err_drv_invalid_int_value)
27
0
            << A->getAsString(Args) << A->getValue();
28
1
    }
29
105k
  }
30
3.17M
  return Res;
31
3.17M
}
OptionUtils.cpp:int (anonymous namespace)::getLastArgIntValueImpl<int>(llvm::opt::ArgList const&, llvm::opt::OptSpecifier, int, clang::DiagnosticsEngine*, unsigned int)
Line
Count
Source
21
3.04M
                             unsigned Base) {
22
3.04M
  IntTy Res = Default;
23
3.04M
  if (Arg *A = Args.getLastArg(Id)) {
24
105k
    if (StringRef(A->getValue()).getAsInteger(Base, Res)) {
25
1
      if (Diags)
26
0
        Diags->Report(diag::err_drv_invalid_int_value)
27
0
            << A->getAsString(Args) << A->getValue();
28
1
    }
29
105k
  }
30
3.04M
  return Res;
31
3.04M
}
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
131k
                             unsigned Base) {
22
131k
  IntTy Res = Default;
23
131k
  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
131k
  return Res;
31
131k
}
32
} // namespace
33
34
namespace clang {
35
36
int getLastArgIntValue(const ArgList &Args, OptSpecifier Id, int Default,
37
3.04M
                       DiagnosticsEngine *Diags, unsigned Base) {
38
3.04M
  return getLastArgIntValueImpl<int>(Args, Id, Default, Diags, Base);
39
3.04M
}
40
41
uint64_t getLastArgUInt64Value(const ArgList &Args, OptSpecifier Id,
42
                               uint64_t Default, DiagnosticsEngine *Diags,
43
131k
                               unsigned Base) {
44
131k
  return getLastArgIntValueImpl<uint64_t>(Args, Id, Default, Diags, Base);
45
131k
}
46
47
} // namespace clang