Coverage Report

Created: 2019-07-24 05:18

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/tools/clang/lib/Driver/InputInfo.h
Line
Count
Source (jump to first uncovered line)
1
//===--- InputInfo.h - Input Source & Type Information ----------*- C++ -*-===//
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
#ifndef LLVM_CLANG_LIB_DRIVER_INPUTINFO_H
10
#define LLVM_CLANG_LIB_DRIVER_INPUTINFO_H
11
12
#include "clang/Driver/Action.h"
13
#include "clang/Driver/Types.h"
14
#include "llvm/Option/Arg.h"
15
#include <cassert>
16
#include <string>
17
18
namespace clang {
19
namespace driver {
20
21
/// InputInfo - Wrapper for information about an input source.
22
class InputInfo {
23
  // FIXME: The distinction between filenames and inputarg here is
24
  // gross; we should probably drop the idea of a "linker
25
  // input". Doing so means tweaking pipelining to still create link
26
  // steps when it sees linker inputs (but not treat them as
27
  // arguments), and making sure that arguments get rendered
28
  // correctly.
29
  enum Class {
30
    Nothing,
31
    Filename,
32
    InputArg,
33
    Pipe
34
  };
35
36
  union {
37
    const char *Filename;
38
    const llvm::opt::Arg *InputArg;
39
  } Data;
40
  Class Kind;
41
  const Action* Act;
42
  types::ID Type;
43
  const char *BaseInput;
44
45
230k
  static types::ID GetActionType(const Action *A) {
46
230k
    return A != nullptr ? 
A->getType()84.2k
:
types::TY_Nothing145k
;
47
230k
  }
48
49
public:
50
145k
  InputInfo() : InputInfo(nullptr, nullptr) {}
clang::driver::InputInfo::InputInfo()
Line
Count
Source
50
145k
  InputInfo() : InputInfo(nullptr, nullptr) {}
Unexecuted instantiation: clang::driver::InputInfo::InputInfo()
51
  InputInfo(const Action *A, const char *_BaseInput)
52
154k
      : Kind(Nothing), Act(A), Type(GetActionType(A)), BaseInput(_BaseInput) {}
53
54
  InputInfo(types::ID _Type, const char *_Filename, const char *_BaseInput)
55
29.6k
      : Kind(Filename), Act(nullptr), Type(_Type), BaseInput(_BaseInput) {
56
29.6k
    Data.Filename = _Filename;
57
29.6k
  }
58
  InputInfo(const Action *A, const char *_Filename, const char *_BaseInput)
59
70.1k
      : Kind(Filename), Act(A), Type(GetActionType(A)), BaseInput(_BaseInput) {
60
70.1k
    Data.Filename = _Filename;
61
70.1k
  }
62
63
  InputInfo(types::ID _Type, const llvm::opt::Arg *_InputArg,
64
            const char *_BaseInput)
65
0
      : Kind(InputArg), Act(nullptr), Type(_Type), BaseInput(_BaseInput) {
66
0
    Data.InputArg = _InputArg;
67
0
  }
68
  InputInfo(const Action *A, const llvm::opt::Arg *_InputArg,
69
            const char *_BaseInput)
70
5.53k
      : Kind(InputArg), Act(A), Type(GetActionType(A)), BaseInput(_BaseInput) {
71
5.53k
    Data.InputArg = _InputArg;
72
5.53k
  }
73
74
29.5k
  bool isNothing() const { return Kind == Nothing; }
75
167k
  bool isFilename() const { return Kind == Filename; }
76
4
  bool isInputArg() const { return Kind == InputArg; }
77
302k
  types::ID getType() const { return Type; }
78
71.6k
  const char *getBaseInput() const { return BaseInput; }
79
  /// The action for which this InputInfo was created.  May be null.
80
19.6k
  const Action *getAction() const { return Act; }
81
0
  void setAction(const Action *A) { Act = A; }
82
83
138k
  const char *getFilename() const {
84
138k
    assert(isFilename() && "Invalid accessor.");
85
138k
    return Data.Filename;
86
138k
  }
87
5.53k
  const llvm::opt::Arg &getInputArg() const {
88
5.53k
    assert(isInputArg() && "Invalid accessor.");
89
5.53k
    return *Data.InputArg;
90
5.53k
  }
91
92
  /// getAsString - Return a string name for this input, for
93
  /// debugging.
94
173
  std::string getAsString() const {
95
173
    if (isFilename())
96
169
      return std::string("\"") + getFilename() + '"';
97
4
    else if (isInputArg())
98
0
      return "(input arg)";
99
4
    else
100
4
      return "(nothing)";
101
173
  }
102
};
103
104
} // end namespace driver
105
} // end namespace clang
106
107
#endif