[llvm-commits] CVS: llvm/lib/CodeGen/LiveInterval.cpp MachineBasicBlock.cpp MachineInstr.cpp

Jeff Cohen jeffc at jolt-lang.org
Fri Dec 15 15:58:06 PST 2006


I'll look into making this change.

Part of the problem is that VC++ doesn't like *OS.stream() in a header 
file when <ostream> isn't included, even if the declaration of 
std::basic_ostream shouldn't be needed (but doesn't have a problem with 
it in a .cpp file, probably because it isn't inlined then).  This would 
appear to be a bug, but it also constrains my options.

I could also just undo the change and go back to including <ostream> in 
the header files.  Gcc must be doing it implicitly anyway, as that's the 
only way some of that code can compile (which does need the declaration 
of std::basic_ostream).

Bill Wendling wrote:
> That's reasonable. So then a better solution would be to keep 
> everything in the .h file, but change operator<<(OStream&) to call the 
> "print()" function directly. So something like this:
>
> #include <iosfwd>
>
> // ...
>
> OStream& operator<<(OStream &OS, const MachineBasicBlock &MBB) {
>   if (*OS.stream()) MBB->print(*OS.stream());
>   return OS;
> }
>
> I'm still working on a nice way of implementing something like this:
>
> template <typename StreamTy>
> class BaseStream {
>   StreamTy *stream;
> public:
>   operator StreamTy () { return *stream; }
> };
>
> but I'm having problems figuring out the "null" stream semantics 
> (right now, it uses "stream = 0" as an indication that it's "null"). 
> But the above hack should suffice in the meantime.
>
> -bw




More information about the llvm-commits mailing list