InputInfo.h revision f353c8cc2ee1cc16ff194b399a8d951f707fb129
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 <cassert> 14 15namespace clang { 16namespace driver { 17 class PipedJob; 18 19/// InputInfo - Wrapper for information about an input source. 20class InputInfo { 21 union { 22 const char *Filename; 23 PipedJob *Pipe; 24 } Data; 25 bool IsPipe; 26 types::ID Type; 27 const char *BaseInput; 28 29public: 30 InputInfo() {} 31 InputInfo(const char *Filename, types::ID _Type, const char *_BaseInput) 32 : IsPipe(false), Type(_Type), BaseInput(_BaseInput) { 33 Data.Filename = Filename; 34 } 35 InputInfo(PipedJob *Pipe, types::ID _Type, const char *_BaseInput) 36 : IsPipe(true), Type(_Type), BaseInput(_BaseInput) { 37 Data.Pipe = Pipe; 38 } 39 40 bool isPipe() const { return IsPipe; } 41 types::ID getType() const { return Type; } 42 const char *getBaseInput() const { return BaseInput; } 43 44 const char *getInputFilename() const { 45 assert(!isPipe() && "Invalid accessor."); 46 return Data.Filename; 47 } 48 PipedJob &getPipe() const { 49 assert(isPipe() && "Invalid accessor."); 50 return *Data.Pipe; 51 } 52}; 53 54} // end namespace driver 55} // end namespace clang 56 57#endif 58