comparison gen/logger.h @ 1650:40bd4a0d4870

Update to work with LLVM 2.7. Removed use of dyn_cast, llvm no compiles without exceptions and rtti by default. We do need exceptions for the libconfig stuff, but rtti isn't necessary (anymore). Debug info needs to be rewritten, as in LLVM 2.7 the format has completely changed. To have something to look at while rewriting, the old code has been wrapped inside #ifndef DISABLE_DEBUG_INFO , this means that you have to define this to compile at the moment. Updated tango 0.99.9 patch to include updated EH runtime code, which is needed for LLVM 2.7 as well.
author Tomas Lindquist Olsen
date Wed, 19 May 2010 12:42:32 +0200
parents 2292878925f4
children
comparison
equal deleted inserted replaced
1649:36da40ecbbe0 1650:40bd4a0d4870
18 18
19 struct Loc; 19 struct Loc;
20 20
21 class Stream { 21 class Stream {
22 std::ostream* OS; 22 std::ostream* OS;
23 23
24 public: 24 public:
25 Stream() : OS(0) {} 25 Stream() : OS(0) {}
26 Stream(std::ostream* S) : OS(S) {} 26 Stream(std::ostream* S) : OS(S) {}
27 Stream(std::ostream& S) : OS(&S) {} 27 Stream(std::ostream& S) : OS(&S) {}
28 28
29 /*
29 Stream operator << (std::ios_base &(*Func)(std::ios_base&)) { 30 Stream operator << (std::ios_base &(*Func)(std::ios_base&)) {
30 if (OS) *OS << Func; 31 if (OS) *OS << Func;
31 return *this; 32 return *this;
32 } 33 }
33 34 */
35
34 Stream operator << (std::ostream &(*Func)(std::ostream&)) { 36 Stream operator << (std::ostream &(*Func)(std::ostream&)) {
35 if (OS) *OS << Func; 37 if (OS) Func(*OS);
36 return *this; 38 return *this;
37 } 39 }
38 40
39 template<typename Ty> 41 template<typename Ty>
40 Stream& operator << (const Ty& Thing) { 42 Stream& operator << (const Ty& Thing) {
41 if (OS) 43 if (OS)
42 Writer<Ty, sizeof(sfinae_bait(Thing))>::write(*OS, Thing); 44 Writer<Ty, sizeof(sfinae_bait(Thing))>::write(*OS, Thing);
43 return *this; 45 return *this;
44 } 46 }
45 47
46 private: 48 private:
47 // Implementation details to treat llvm::Value, llvm::Type and their 49 // Implementation details to treat llvm::Value, llvm::Type and their
48 // subclasses specially (to pretty-print types). 50 // subclasses specially (to pretty-print types).
49 51
50 static void writeType(std::ostream& OS, const llvm::Type& Ty); 52 static void writeType(std::ostream& OS, const llvm::Type& Ty);
51 static void writeValue(std::ostream& OS, const llvm::Value& Ty); 53 static void writeValue(std::ostream& OS, const llvm::Value& Ty);
52 54
53 template<typename Ty, int N> friend struct Writer; 55 template<typename Ty, int N> friend struct Writer;
54 // error: function template partial specialization is not allowed 56 // error: function template partial specialization is not allowed
55 // So I guess type partial specialization + member function will have to do... 57 // So I guess type partial specialization + member function will have to do...
56 template<typename Ty, int N> 58 template<typename Ty, int N>
57 struct Writer { 59 struct Writer {
58 static void write(std::ostream& OS, const Ty& Thing) { 60 static void write(std::ostream& OS, const Ty& Thing) {
59 OS << Thing; 61 OS << Thing;
60 } 62 }
61 }; 63 };
62 64
63 template<typename Ty> 65 template<typename Ty>
64 struct Writer<Ty, 1> { 66 struct Writer<Ty, 1> {
65 static void write(std::ostream& OS, const llvm::Type& Thing) { 67 static void write(std::ostream& OS, const llvm::Type& Thing) {
66 Stream::writeType(OS, Thing); 68 Stream::writeType(OS, Thing);
67 } 69 }
68 static void write(std::ostream& OS, const llvm::Value& Thing) { 70 static void write(std::ostream& OS, const llvm::Value& Thing) {
69 Stream::writeValue(OS, Thing); 71 Stream::writeValue(OS, Thing);
70 } 72 }
71 }; 73 };
72 74
73 // NOT IMPLEMENTED 75 // NOT IMPLEMENTED
74 char sfinae_bait(const llvm::Type&); 76 char sfinae_bait(const llvm::Type&);
75 char sfinae_bait(const llvm::Value&); 77 char sfinae_bait(const llvm::Value&);
76 short sfinae_bait(...); 78 short sfinae_bait(...);
77 }; 79 };