/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 | 38.4k | unsigned Base) { |
22 | 38.4k | IntTy Res = Default; |
23 | 38.4k | if (Arg *A = Args.getLastArg(Id)) { |
24 | 16.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 | 16.1k | } |
30 | 38.4k | return Res; |
31 | 38.4k | } OptionUtils.cpp:int (anonymous namespace)::getLastArgIntValueImpl<int>(llvm::opt::ArgList const&, llvm::opt::OptSpecifier, int, clang::DiagnosticsEngine*, unsigned int) Line | Count | Source | 21 | 38.4k | unsigned Base) { | 22 | 38.4k | IntTy Res = Default; | 23 | 38.4k | if (Arg *A = Args.getLastArg(Id)) { | 24 | 16.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 | 16.1k | } | 30 | 38.4k | return Res; | 31 | 38.4k | } |
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 | 38.4k | DiagnosticsEngine *Diags, unsigned Base) { |
38 | 38.4k | return getLastArgIntValueImpl<int>(Args, Id, Default, Diags, Base); |
39 | 38.4k | } |
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 |