[llvm-dev] Compiling llvm+clang v3.5 with Visual Studio 2015

Welson Sun via llvm-dev llvm-dev at lists.llvm.org
Thu Jun 16 16:36:38 PDT 2016


OK, actually not too bad, just need to patch 5 files:

llvm_clang/v3.5/src/include/llvm/ADT/IntrusiveRefCntPtr.h
llvm_clang/v3.5/src/include/llvm/CodeGen/PBQP/CostAllocator.h
llvm_clang/v3.5/src/include/llvm/CodeGen/PBQP/Math.h
llvm_clang/v3.5/src/include/llvm/CodeGen/PBQP/RegAllocSolver.h
llvm_clang/v3.5/src/tools/clang/lib/Serialization/ASTWriter.cpp


--- llvm_clang/v3.5/src/include/llvm/ADT/IntrusiveRefCntPtr.h
2015-10-03 12:00:11.000000000 -0700
+++ llvm_clang/v3.5/src/include/llvm/ADT/IntrusiveRefCntPtr.h  2015-10-03
12:00:11.000000000 -0700
@@ -197,6 +197,9 @@
   private:
     void retain() { if (Obj) IntrusiveRefCntPtrInfo<T>::retain(Obj); }
     void release() { if (Obj) IntrusiveRefCntPtrInfo<T>::release(Obj); }
+
+    template <typename X>
+    friend class IntrusiveRefCntPtr;
   };

   template<class T, class U>
--- llvm_clang/v3.5/src/include/llvm/CodeGen/PBQP/CostAllocator.h
2015-10-03 12:00:11.000000000 -0700
+++ llvm_clang/v3.5/src/include/llvm/CodeGen/PBQP/CostAllocator.h
 2015-10-03 12:00:11.000000000 -0700
@@ -87,10 +87,10 @@
                !std::is_same<PoolEntry*,
                              typename
std::remove_const<CostKeyT>::type>::value,
                bool>::type
-    operator()(const PoolEntry* a, const CostKeyT &b) {
+    operator()(const PoolEntry* a, const CostKeyT &b) const {
       return compare(a->getCost(), b);
     }
-    bool operator()(const PoolEntry* a, const PoolEntry* b) {
+    bool operator()(const PoolEntry* a, const PoolEntry* b) const {
       return compare(a->getCost(), b->getCost());
     }
   private:
--- llvm_clang/v3.5/src/include/llvm/CodeGen/PBQP/Math.h    2015-10-03
12:00:11.000000000 -0700
+++ llvm_clang/v3.5/src/include/llvm/CodeGen/PBQP/Math.h       2015-10-03
12:00:11.000000000 -0700
@@ -138,7 +138,7 @@

 class VectorComparator {
 public:
-  bool operator()(const Vector &A, const Vector &B) {
+  bool operator()(const Vector &A, const Vector &B) const {
     if (A.Length < B.Length)
       return true;
     if (B.Length < A.Length)
@@ -386,7 +386,7 @@

 class MatrixComparator {
 public:
-  bool operator()(const Matrix &A, const Matrix &B) {
+  bool operator()(const Matrix &A, const Matrix &B) const {
     if (A.Rows < B.Rows)
       return true;
     if (B.Rows < A.Rows)
--- llvm_clang/v3.5/src/include/llvm/CodeGen/PBQP/RegAllocSolver.h
 2015-10-03 12:00:11.000000000 -0700
+++ llvm_clang/v3.5/src/include/llvm/CodeGen/PBQP/RegAllocSolver.h
2015-10-03 12:00:11.000000000 -0700
@@ -328,7 +328,7 @@
       class SpillCostComparator {
       public:
         SpillCostComparator(const Graph& G) : G(G) {}
-        bool operator()(NodeId N1Id, NodeId N2Id) {
+        bool operator()(NodeId N1Id, NodeId N2Id) const {
           PBQPNum N1SC = G.getNodeCosts(N1Id)[0] / G.getNodeDegree(N1Id);
           PBQPNum N2SC = G.getNodeCosts(N2Id)[0] / G.getNodeDegree(N2Id);
           return N1SC < N2SC;
--- llvm_clang/v3.5/src/tools/clang/lib/Serialization/ASTWriter.cpp
2015-10-03 12:00:11.000000000 -0700
+++ llvm_clang/v3.5/src/tools/clang/lib/Serialization/ASTWriter.cpp
 2015-10-03 12:00:11.000000000 -0700
@@ -59,14 +59,14 @@
 using namespace clang::serialization;

 template <typename T, typename Allocator>
-static StringRef data(const std::vector<T, Allocator> &v) {
+static StringRef bytes(const std::vector<T, Allocator> &v) {
   if (v.empty()) return StringRef();
   return StringRef(reinterpret_cast<const char*>(&v[0]),
                          sizeof(T) * v.size());
 }

 template <typename T>
-static StringRef data(const SmallVectorImpl<T> &v) {
+static StringRef bytes(const SmallVectorImpl<T> &v) {
   return StringRef(reinterpret_cast<const char*>(v.data()),
                          sizeof(T) * v.size());
 }
@@ -1402,7 +1402,7 @@
   Record.push_back(INPUT_FILE_OFFSETS);
   Record.push_back(InputFileOffsets.size());
   Record.push_back(UserFilesNum);
-  Stream.EmitRecordWithBlob(OffsetsAbbrevCode, Record,
data(InputFileOffsets));
+  Stream.EmitRecordWithBlob(OffsetsAbbrevCode, Record,
bytes(InputFileOffsets));
 }

 //===----------------------------------------------------------------------===//
@@ -1796,7 +1796,7 @@
   Record.push_back(SOURCE_LOCATION_OFFSETS);
   Record.push_back(SLocEntryOffsets.size());
   Record.push_back(SourceMgr.getNextLocalOffset() - 1); // skip dummy
-  Stream.EmitRecordWithBlob(SLocOffsetsAbbrev, Record,
data(SLocEntryOffsets));
+  Stream.EmitRecordWithBlob(SLocOffsetsAbbrev, Record,
bytes(SLocEntryOffsets));

   // Write the source location entry preloads array, telling the AST
   // reader which source locations entries it should load eagerly.
@@ -2122,7 +2122,7 @@
   Record.push_back(MacroOffsets.size());
   Record.push_back(FirstMacroID - NUM_PREDEF_MACRO_IDS);
   Stream.EmitRecordWithBlob(MacroOffsetAbbrev, Record,
-                            data(MacroOffsets));
+                            bytes(MacroOffsets));
 }

 void ASTWriter::WritePreprocessorDetail(PreprocessingRecord &PPRec) {
@@ -2220,7 +2220,7 @@
     Record.push_back(PPD_ENTITIES_OFFSETS);
     Record.push_back(FirstPreprocessorEntityID - NUM_PREDEF_PP_ENTITY_IDS);
     Stream.EmitRecordWithBlob(PPEOffsetAbbrev, Record,
-                              data(PreprocessedEntityOffsets));
+                              bytes(PreprocessedEntityOffsets));
   }
 }

@@ -2583,7 +2583,7 @@
   Record.push_back(CXX_BASE_SPECIFIER_OFFSETS);
   Record.push_back(CXXBaseSpecifiersOffsets.size());
   Stream.EmitRecordWithBlob(BaseSpecifierOffsetAbbrev, Record,
-                            data(CXXBaseSpecifiersOffsets));
+                            bytes(CXXBaseSpecifiersOffsets));
 }

 //===----------------------------------------------------------------------===//
@@ -2657,7 +2657,7 @@
     Decls.push_back(std::make_pair(D->getKind(), GetDeclRef(D)));

   ++NumLexicalDeclContexts;
-  Stream.EmitRecordWithBlob(DeclContextLexicalAbbrev, Record, data(Decls));
+  Stream.EmitRecordWithBlob(DeclContextLexicalAbbrev, Record,
bytes(Decls));
   return Offset;
 }

@@ -2676,7 +2676,7 @@
   Record.push_back(TYPE_OFFSET);
   Record.push_back(TypeOffsets.size());
   Record.push_back(FirstTypeID - NUM_PREDEF_TYPE_IDS);
-  Stream.EmitRecordWithBlob(TypeOffsetAbbrev, Record, data(TypeOffsets));
+  Stream.EmitRecordWithBlob(TypeOffsetAbbrev, Record, bytes(TypeOffsets));

   // Write the declaration offsets array
   Abbrev = new BitCodeAbbrev();
@@ -2689,7 +2689,7 @@
   Record.push_back(DECL_OFFSET);
   Record.push_back(DeclOffsets.size());
   Record.push_back(FirstDeclID - NUM_PREDEF_DECL_IDS);
-  Stream.EmitRecordWithBlob(DeclOffsetAbbrev, Record, data(DeclOffsets));
+  Stream.EmitRecordWithBlob(DeclOffsetAbbrev, Record, bytes(DeclOffsets));
 }

 void ASTWriter::WriteFileDeclIDsMap() {
@@ -2714,7 +2714,7 @@
   unsigned AbbrevCode = Stream.EmitAbbrev(Abbrev);
   Record.push_back(FILE_SORTED_DECLS);
   Record.push_back(FileSortedIDs.size());
-  Stream.EmitRecordWithBlob(AbbrevCode, Record, data(FileSortedIDs));
+  Stream.EmitRecordWithBlob(AbbrevCode, Record, bytes(FileSortedIDs));
 }

 void ASTWriter::WriteComments() {
@@ -2937,7 +2937,7 @@
     Record.push_back(SelectorOffsets.size());
     Record.push_back(FirstSelectorID - NUM_PREDEF_SELECTOR_IDS);
     Stream.EmitRecordWithBlob(SelectorOffsetAbbrev, Record,
-                              data(SelectorOffsets));
+                              bytes(SelectorOffsets));
   }
 }

@@ -3360,7 +3360,7 @@
   Record.push_back(IdentifierOffsets.size());
   Record.push_back(FirstIdentID - NUM_PREDEF_IDENT_IDS);
   Stream.EmitRecordWithBlob(IdentifierOffsetAbbrev, Record,
-                            data(IdentifierOffsets));
+                            bytes(IdentifierOffsets));
 }

 //===----------------------------------------------------------------------===//
@@ -4227,7 +4227,7 @@
   Record.clear();
   Record.push_back(TU_UPDATE_LEXICAL);
   Stream.EmitRecordWithBlob(TuUpdateLexicalAbbrev, Record,
-                            data(NewGlobalDecls));
+                            bytes(NewGlobalDecls));

   // And a visible updates block for the translation unit.
   Abv = new llvm::BitCodeAbbrev();


On Thu, Jun 16, 2016 at 1:29 PM, Welson Sun <welson.sun at gmail.com> wrote:

> I have been using Visual Studio 2012 to compile llvm+clang v3.5 without
> any problems. Recently, the build team decided to upgrade VS2012 to VS2015,
> and now instead of 0 errors, there are 25 errors during VS2015 compilation.
> For example:
>
> v3.5\src\include\llvm/ADT/IntrusiveRefCntPtr.h(158): error C2248:
> 'llvm::IntrusiveRefCntPtr<`anonymous-namespace'::ChainedIncludesSource>::Obj':
> cannot access private member declared in class
> 'llvm::IntrusiveRefCntPtr<`anonymous-namespace'::ChainedIncludesSource>'
>
> Just curious anybody has tried this combination?
>
> Thanks,
> - Welson
>
>


-- 
- Welson
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160616/cc8534e1/attachment-0001.html>


More information about the llvm-dev mailing list