summarylogtreecommitdiffstats
path: root/llvm-3.7.patch
blob: cdea92c66034aae20d664eedcaace15e6f85a87e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
diff --git a/vm/generator/main/builtins.cc b/vm/generator/main/builtins.cc
index a488fcd..ac29863 100644
--- a/vm/generator/main/builtins.cc
+++ b/vm/generator/main/builtins.cc
@@ -223,9 +223,10 @@ void handleBuiltinModule(const std::string& outputDir, const ClassDecl* CD,
   }
 
   {
-    std::string err;
-    llvm::raw_fd_ostream to((outputDir+name+"-builtin.json").c_str(), err);
-    assert(err == "");
+    std::error_code err;
+    llvm::raw_fd_ostream to((outputDir+name+"-builtin.json").c_str(), err,
+                            llvm::sys::fs::F_None);
+    assert(!err);
     definition.makeOutput(to);
   }
 
diff --git a/vm/generator/main/generator.cc b/vm/generator/main/generator.cc
index 156ff3a..b9a9a67 100644
--- a/vm/generator/main/generator.cc
+++ b/vm/generator/main/generator.cc
@@ -77,8 +77,7 @@ void processDeclContext(const std::string outputDir, const DeclContext* ds,
 }
 
 int main(int argc, char* argv[]) {
-  llvm::IntrusiveRefCntPtr<DiagnosticsEngine> Diags;
-  FileSystemOptions FileSystemOpts;
+  CompilerInstance CI;
 
   std::string modeStr = argv[1];
   std::string astFile = argv[2];
@@ -105,9 +104,13 @@ int main(int argc, char* argv[]) {
   }
 
   // Parse source file
-  ASTUnit *unit = ASTUnit::LoadFromASTFile(astFile,
-                                           Diags, FileSystemOpts,
-                                           false, 0, 0, true);
+  CI.createDiagnostics();
+  IntrusiveRefCntPtr<DiagnosticsEngine> Diags(&CI.getDiagnostics());
+  std::unique_ptr<ASTUnit> unit =
+      ASTUnit::LoadFromASTFile(astFile,
+                               CI.getPCHContainerReader(),
+                               Diags,
+                               CI.getFileSystemOpts());
 
   // Setup printing policy
   // We want the bool type to be printed as "bool"
diff --git a/vm/generator/main/generator.hh b/vm/generator/main/generator.hh
index 73b67e4..1f809c2 100644
--- a/vm/generator/main/generator.hh
+++ b/vm/generator/main/generator.hh
@@ -29,6 +29,7 @@
 
 #include <clang/Frontend/ASTUnit.h>
 #include <clang/AST/DeclTemplate.h>
+#include <clang/Frontend/CompilerInstance.h>
 
 typedef clang::ClassTemplateSpecializationDecl SpecDecl;
 typedef clang::CXXRecordDecl ClassDecl;
@@ -36,17 +37,18 @@ typedef clang::CXXRecordDecl ClassDecl;
 typedef llvm::raw_fd_ostream ostream;
 
 inline
-void checkErrString(const std::string& err) {
-  if (!err.empty()) {
-    llvm::errs() << err << "\n";
+void checkErrString(const std::error_code& err) {
+  if (err) {
+    llvm::errs() << err.message() << "\n";
     exit(1);
   }
 }
 
 inline
 std::unique_ptr<ostream> openFileOutputStream(const std::string& fileName) {
-  std::string err;
-  auto result = std::unique_ptr<ostream>(new ostream(fileName.c_str(), err));
+  std::error_code err;
+  auto result = std::unique_ptr<ostream>(new ostream(fileName.c_str(), err,
+                                                     llvm::sys::fs::F_None));
   checkErrString(err);
 
   return result;
@@ -55,8 +57,8 @@ std::unique_ptr<ostream> openFileOutputStream(const std::string& fileName) {
 inline
 void withFileOutputStream(const std::string& fileName,
                           std::function<void (ostream&)> body) {
-  std::string err;
-  ostream stream(fileName.c_str(), err);
+  std::error_code err;
+  ostream stream(fileName.c_str(), err, llvm::sys::fs::F_None);
   checkErrString(err);
 
   body(stream);
diff --git a/vm/generator/main/implementations.cc b/vm/generator/main/implementations.cc
index 2961625..b08c2af 100644
--- a/vm/generator/main/implementations.cc
+++ b/vm/generator/main/implementations.cc
@@ -520,7 +520,7 @@ void ImplementationDef::makeOutput(llvm::raw_fd_ostream& to) {
        << method->formals << ") {\n";
 
     to << "  ";
-    if (!method->function->getResultType().getTypePtr()->isVoidType())
+    if (!method->function->getReturnType().getTypePtr()->isVoidType())
       to << "return ";
 
     to << access << method->name;
diff --git a/vm/generator/main/utils.cc b/vm/generator/main/utils.cc
index 2932686..1cadec5 100644
--- a/vm/generator/main/utils.cc
+++ b/vm/generator/main/utils.cc
@@ -213,7 +213,7 @@ void parseFunction(const clang::FunctionDecl* function,
                    bool hasSelfParam) {
 
   name = function->getNameAsString();
-  resultType = typeToString(function->getResultType());
+  resultType = typeToString(function->getReturnType());
 
   auto param_begin = function->param_begin() + (hasSelfParam ? 1 : 0);
   auto param_end = function->param_end();