Browse code

c++11 / g++ 6 compatibility fix, based on commit 73992eb2fab83075dac06f47da8850ef07bc2dd2 that applies patch from Keith Jones.

Micah Snyder authored on 2018/02/17 06:30:16
Showing 6 changed files
... ...
@@ -167,7 +167,7 @@ public:
167 167
 
168 168
     unsigned AllocSize = static_cast<unsigned>(sizeof(StringMapEntry))+
169 169
       KeyLength+1;
170
-    unsigned Alignment = alignof<StringMapEntry>();
170
+    unsigned Alignment = alignofLLVM<StringMapEntry>();
171 171
 
172 172
     StringMapEntry *NewItem =
173 173
       static_cast<StringMapEntry*>(Allocator.Allocate(AllocSize,Alignment));
... ...
@@ -18,6 +18,7 @@
18 18
 #define LLVM_CODEGEN_JITCODEEMITTER_H
19 19
 
20 20
 #include <string>
21
+#include <algorithm>
21 22
 #include "llvm/System/DataTypes.h"
22 23
 #include "llvm/Support/MathExtras.h"
23 24
 #include "llvm/CodeGen/MachineCodeEmitter.h"
... ...
@@ -415,7 +415,7 @@ namespace llvm {
415 415
       IndexListEntry *entry =
416 416
         static_cast<IndexListEntry*>(
417 417
           ileAllocator.Allocate(sizeof(IndexListEntry),
418
-          alignof<IndexListEntry>()));
418
+          alignofLLVM<IndexListEntry>()));
419 419
 
420 420
       new (entry) IndexListEntry(mi, index);
421 421
 
... ...
@@ -49,12 +49,13 @@ struct AlignOf {
49 49
 
50 50
 };
51 51
 
52
+// This is a built in function in C++11.  We have to rename this.
52 53
 /// alignof - A templated function that returns the mininum alignment of
53 54
 ///  of a type.  This provides no extra functionality beyond the AlignOf
54 55
 ///  class besides some cosmetic cleanliness.  Example usage:
55 56
 ///  alignof<int>() returns the alignment of an int.
56 57
 template <typename T>
57
-static inline unsigned alignof() { return AlignOf<T>::Alignment; }
58
+static inline unsigned alignofLLVM() { return AlignOf<T>::Alignment; }
58 59
 
59 60
 } // end namespace llvm
60 61
 #endif
... ...
@@ -201,7 +201,7 @@ public:
201 201
       char *End = Slab == Allocator.CurSlab ? Allocator.CurPtr :
202 202
                                               (char *)Slab + Slab->Size;
203 203
       for (char *Ptr = (char*)(Slab+1); Ptr < End; Ptr += sizeof(T)) {
204
-        Ptr = Allocator.AlignPtr(Ptr, alignof<T>());
204
+        Ptr = Allocator.AlignPtr(Ptr, alignofLLVM<T>());
205 205
         if (Ptr + sizeof(T) <= End)
206 206
           reinterpret_cast<T*>(Ptr)->~T();
207 207
       }
... ...
@@ -11,6 +11,7 @@
11 11
 //
12 12
 //===----------------------------------------------------------------------===//
13 13
 
14
+#include <algorithm>
14 15
 #include "llvm/Support/Debug.h"
15 16
 #include "llvm/Support/FormattedStream.h"
16 17