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