From 833e078e81eef3b0520e0e77b41bc474d857a6e2 Mon Sep 17 00:00:00 2001 From: Sylveon Date: Wed, 24 Nov 2021 02:42:15 +0800 Subject: [PATCH] [Misc] update llvm version to 13 --- include/soll/AST/Decl.h | 3 +-- lib/Frontend/ASTConsumers/ASTPrinter.cpp | 12 +++++++++++- lib/Frontend/CompilerInstance.cpp | 7 ++++++- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/include/soll/AST/Decl.h b/include/soll/AST/Decl.h index 5554e8d9..cc1728d4 100644 --- a/include/soll/AST/Decl.h +++ b/include/soll/AST/Decl.h @@ -29,8 +29,7 @@ class Decl { friend class ASTReader; protected: - Decl(SourceRange L, - llvm::StringRef Name = llvm::StringRef::withNullAsEmpty(nullptr), + Decl(SourceRange L, llvm::StringRef Name = llvm::StringRef(""), Visibility vis = Visibility::Default) : Location(L), Name(Name.str()), Vis(vis), UniqueName(Name.str()) {} diff --git a/lib/Frontend/ASTConsumers/ASTPrinter.cpp b/lib/Frontend/ASTConsumers/ASTPrinter.cpp index eda09b83..a48dba92 100644 --- a/lib/Frontend/ASTConsumers/ASTPrinter.cpp +++ b/lib/Frontend/ASTConsumers/ASTPrinter.cpp @@ -2,9 +2,11 @@ #include "soll/AST/AST.h" #include "soll/AST/ASTConsumer.h" #include "soll/Frontend/ASTConsumers.h" +#if LLVM_VERSION_MAJOR >= 13 +#include +#endif #include #include - namespace { std::string ToString(soll::UnaryOperatorKind op) { @@ -136,7 +138,11 @@ std::string ToString(soll::TypePtr type) { return llvm::Twine(ToString(at->getElementType()) + "[" + (at->isDynamicSized() ? "" +#if LLVM_VERSION_MAJOR >= 13 + : toString(at->getLength(), 10, false)) + +#else : at->getLength().toString(10, false)) + +#endif "]") .str(); } @@ -495,7 +501,11 @@ void ASTPrinter::visit(NumberLiteralType &literal) { const bool Signed = dynamic_cast(literal.getType().get())->isSigned(); os() << indent() << "NumberLiteral " +#if LLVM_VERSION_MAJOR >= 13 + << toString(literal.getValue(), 10, Signed) << "\n"; +#else << literal.getValue().toString(10, Signed) << "\n"; +#endif ConstStmtVisitor::visit(literal); unindent(); } diff --git a/lib/Frontend/CompilerInstance.cpp b/lib/Frontend/CompilerInstance.cpp index 75aaec7d..68d1d36e 100644 --- a/lib/Frontend/CompilerInstance.cpp +++ b/lib/Frontend/CompilerInstance.cpp @@ -278,7 +278,12 @@ std::unique_ptr CompilerInstance::createOutputFile( OSFile = OutFile; OS.reset(new llvm::raw_fd_ostream( OSFile, Error, - (Binary ? llvm::sys::fs::F_None : llvm::sys::fs::F_Text))); +#if LLVM_VERSION_MAJOR >= 13 + (Binary ? llvm::sys::fs::OF_None : llvm::sys::fs::OF_Text) +#else + (Binary ? llvm::sys::fs::F_None : llvm::sys::fs::F_Text) +#endif + )); if (Error) return nullptr; }