Skip to content

Commit 4df72f0

Browse files
committed
Merge branch 'master' of https://github.com/mozart/mozart2
2 parents a2413d4 + 72ab414 commit 4df72f0

File tree

5 files changed

+23
-17
lines changed

5 files changed

+23
-17
lines changed

vm/generator/main/builtins.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -223,9 +223,10 @@ void handleBuiltinModule(const std::string& outputDir, const ClassDecl* CD,
223223
}
224224

225225
{
226-
std::string err;
227-
llvm::raw_fd_ostream to((outputDir+name+"-builtin.json").c_str(), err);
228-
assert(err == "");
226+
std::error_code err;
227+
llvm::raw_fd_ostream to((outputDir+name+"-builtin.json").c_str(), err,
228+
llvm::sys::fs::F_None);
229+
assert(!err);
229230
definition.makeOutput(to);
230231
}
231232

vm/generator/main/generator.cc

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,7 @@ void processDeclContext(const std::string outputDir, const DeclContext* ds,
7777
}
7878

7979
int main(int argc, char* argv[]) {
80-
llvm::IntrusiveRefCntPtr<DiagnosticsEngine> Diags;
81-
FileSystemOptions FileSystemOpts;
80+
CompilerInstance CI;
8281

8382
std::string modeStr = argv[1];
8483
std::string astFile = argv[2];
@@ -105,9 +104,13 @@ int main(int argc, char* argv[]) {
105104
}
106105

107106
// Parse source file
108-
ASTUnit *unit = ASTUnit::LoadFromASTFile(astFile,
109-
Diags, FileSystemOpts,
110-
false, 0, 0, true);
107+
CI.createDiagnostics();
108+
IntrusiveRefCntPtr<DiagnosticsEngine> Diags(&CI.getDiagnostics());
109+
std::unique_ptr<ASTUnit> unit =
110+
ASTUnit::LoadFromASTFile(astFile,
111+
CI.getPCHContainerReader(),
112+
Diags,
113+
CI.getFileSystemOpts());
111114

112115
// Setup printing policy
113116
// We want the bool type to be printed as "bool"

vm/generator/main/generator.hh

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,24 +29,26 @@
2929

3030
#include <clang/Frontend/ASTUnit.h>
3131
#include <clang/AST/DeclTemplate.h>
32+
#include <clang/Frontend/CompilerInstance.h>
3233

3334
typedef clang::ClassTemplateSpecializationDecl SpecDecl;
3435
typedef clang::CXXRecordDecl ClassDecl;
3536

3637
typedef llvm::raw_fd_ostream ostream;
3738

3839
inline
39-
void checkErrString(const std::string& err) {
40-
if (!err.empty()) {
41-
llvm::errs() << err << "\n";
40+
void checkErrString(const std::error_code& err) {
41+
if (err) {
42+
llvm::errs() << err.message() << "\n";
4243
exit(1);
4344
}
4445
}
4546

4647
inline
4748
std::unique_ptr<ostream> openFileOutputStream(const std::string& fileName) {
48-
std::string err;
49-
auto result = std::unique_ptr<ostream>(new ostream(fileName.c_str(), err));
49+
std::error_code err;
50+
auto result = std::unique_ptr<ostream>(new ostream(fileName.c_str(), err,
51+
llvm::sys::fs::F_None));
5052
checkErrString(err);
5153

5254
return result;
@@ -55,8 +57,8 @@ std::unique_ptr<ostream> openFileOutputStream(const std::string& fileName) {
5557
inline
5658
void withFileOutputStream(const std::string& fileName,
5759
std::function<void (ostream&)> body) {
58-
std::string err;
59-
ostream stream(fileName.c_str(), err);
60+
std::error_code err;
61+
ostream stream(fileName.c_str(), err, llvm::sys::fs::F_None);
6062
checkErrString(err);
6163

6264
body(stream);

vm/generator/main/implementations.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ void ImplementationDef::makeOutput(llvm::raw_fd_ostream& to) {
520520
<< method->formals << ") {\n";
521521

522522
to << " ";
523-
if (!method->function->getResultType().getTypePtr()->isVoidType())
523+
if (!method->function->getReturnType().getTypePtr()->isVoidType())
524524
to << "return ";
525525

526526
to << access << method->name;

vm/generator/main/utils.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ void parseFunction(const clang::FunctionDecl* function,
213213
bool hasSelfParam) {
214214

215215
name = function->getNameAsString();
216-
resultType = typeToString(function->getResultType());
216+
resultType = typeToString(function->getReturnType());
217217

218218
auto param_begin = function->param_begin() + (hasSelfParam ? 1 : 0);
219219
auto param_end = function->param_end();

0 commit comments

Comments
 (0)