 |
|
 |
|
| Files: |
1 |
|
Branches Taken: |
66.7% |
8 / 12 |
| Generated: |
2010-02-10 01:31 |
|
Branches Executed: |
100.0% |
12 / 12 |
| |
|
Line Coverage: |
97.5% |
39 / 40 |
| |
 |
|
 |
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 CLANG_LIB_DRIVER_INPUTINFO_H_
11 : #define CLANG_LIB_DRIVER_INPUTINFO_H_
12 :
13 : #include "clang/Driver/Types.h"
14 :
15 : #include <cassert>
16 : #include <string>
17 :
18 : namespace clang {
19 : namespace driver {
20 : class PipedJob;
21 :
22 : /// InputInfo - Wrapper for information about an input source.
23 266: 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 Arg *InputArg;
40 : PipedJob *Pipe;
41 : } Data;
42 : Class Kind;
43 : types::ID Type;
44 : const char *BaseInput;
45 :
46 : public:
47 484: InputInfo() {}
48 86: InputInfo(types::ID _Type, const char *_BaseInput)
49 86: : Kind(Nothing), Type(_Type), BaseInput(_BaseInput) {
50 86: }
51 377: InputInfo(const char *_Filename, types::ID _Type, const char *_BaseInput)
52 377: : Kind(Filename), Type(_Type), BaseInput(_BaseInput) {
53 377: Data.Filename = _Filename;
54 377: }
55 7: InputInfo(const Arg *_InputArg, types::ID _Type, const char *_BaseInput)
56 7: : Kind(InputArg), Type(_Type), BaseInput(_BaseInput) {
57 7: Data.InputArg = _InputArg;
58 7: }
59 14: InputInfo(PipedJob *_Pipe, types::ID _Type, const char *_BaseInput)
60 14: : Kind(Pipe), Type(_Type), BaseInput(_BaseInput) {
61 14: Data.Pipe = _Pipe;
62 14: }
63 :
64 82: bool isNothing() const { return Kind == Nothing; }
65 921: bool isFilename() const { return Kind == Filename; }
66 12: bool isInputArg() const { return Kind == InputArg; }
67 742: bool isPipe() const { return Kind == Pipe; }
68 696: types::ID getType() const { return Type; }
69 494: const char *getBaseInput() const { return BaseInput; }
70 :
71 430: const char *getFilename() const {
430: branch 1 taken
0: branch 2 not taken
72 430: assert(isFilename() && "Invalid accessor.");
73 430: return Data.Filename;
74 : }
75 7: const Arg &getInputArg() const {
7: branch 1 taken
0: branch 2 not taken
76 7: assert(isInputArg() && "Invalid accessor.");
77 7: return *Data.InputArg;
78 : }
79 2: PipedJob &getPipe() const {
2: branch 1 taken
0: branch 2 not taken
80 2: assert(isPipe() && "Invalid accessor.");
81 2: return *Data.Pipe;
82 : }
83 :
84 : /// getAsString - Return a string name for this input, for
85 : /// debugging.
86 56: std::string getAsString() const {
4: branch 1 taken
52: branch 2 taken
87 56: if (isPipe())
88 4: return "(pipe)";
47: branch 1 taken
5: branch 2 taken
89 52: else if (isFilename())
90 47: return std::string("\"") + getFilename() + '"';
0: branch 1 not taken
5: branch 2 taken
91 5: else if (isInputArg())
92 0: return "(input arg)";
93 : else
94 5: return "(nothing)";
95 : }
96 : };
97 :
98 : } // end namespace driver
99 : } // end namespace clang
100 :
101 : #endif
Generated: 2010-02-10 01:31 by zcov