Coverage Report

Created: 2021-01-23 06: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
210k
                             unsigned Base) {
22
210k
  IntTy Res = Default;
23
210k
  if (Arg *A = Args.getLastArg(Id)) {
24
50.4k
    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
50.4k
  }
30
210k
  return Res;
31
210k
}
OptionUtils.cpp:int (anonymous namespace)::getLastArgIntValueImpl<int>(llvm::opt::ArgList const&, llvm::opt::OptSpecifier, int, clang::DiagnosticsEngine*, unsigned int)
Line
Count
Source
21
210k
                             unsigned Base) {
22
210k
  IntTy Res = Default;
23
210k
  if (Arg *A = Args.getLastArg(Id)) {
24
50.4k
    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
50.4k
  }
30
210k
  return Res;
31
210k
}
Unexecuted instantiation: 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)
32
} // namespace
33
34
namespace clang {
35
36
int getLastArgIntValue(const ArgList &Args, OptSpecifier Id, int Default,
37
210k
                       DiagnosticsEngine *Diags, unsigned Base) {
38
210k
  return getLastArgIntValueImpl<int>(Args, Id, Default, Diags, Base);
39
210k
}
40
41
uint64_t getLastArgUInt64Value(const ArgList &Args, OptSpecifier Id,
42
                               uint64_t Default, DiagnosticsEngine *Diags,
43
0
                               unsigned Base) {
44
0
  return getLastArgIntValueImpl<uint64_t>(Args, Id, Default, Diags, Base);
45
0
}
46
47
} // namespace clang