Fix the deprecated llvm::Optional issue
This commit is contained in:
parent
94b9479c29
commit
636e64825d
|
@ -165,7 +165,7 @@ public:
|
|||
|
||||
// We need to create one empty namespace, so that the JIT can
|
||||
// start it's operation.
|
||||
auto ns = Namespace::make(*this, DEFAULT_NS_NAME, llvm::None);
|
||||
auto ns = Namespace::make(*this, DEFAULT_NS_NAME, std::nullopt);
|
||||
|
||||
insertNS(ns);
|
||||
currentNS = ns->name;
|
||||
|
@ -186,7 +186,7 @@ public:
|
|||
/// Create an empty namespace with the given \p name and optional \p filename
|
||||
/// and then insert it into the context
|
||||
NSPtr makeNamespace(llvm::StringRef name,
|
||||
llvm::Optional<llvm::StringRef> filename);
|
||||
std::optional<llvm::StringRef> filename);
|
||||
|
||||
/// Read a namespace with the given \p name and returns a share pointer
|
||||
/// to the name or an Error.
|
||||
|
|
|
@ -43,7 +43,7 @@ public:
|
|||
Environment(Environment *parent) : parent(parent){};
|
||||
|
||||
/// Look up the given `key` in the environment and return it.
|
||||
llvm::Optional<V> lookup(llvm::StringRef key) {
|
||||
std::optional<V> lookup(llvm::StringRef key) {
|
||||
if (auto value = pairs.lookup(key)) {
|
||||
return value;
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ public:
|
|||
return parent->lookup(key);
|
||||
}
|
||||
|
||||
return llvm::None;
|
||||
return std::nullopt;
|
||||
};
|
||||
|
||||
/// Insert the given `key` with the given `value` into the storage. This
|
||||
|
|
|
@ -55,7 +55,7 @@ public:
|
|||
|
||||
Ast from(uint index);
|
||||
|
||||
llvm::Optional<Expression *> at(uint index);
|
||||
std::optional<Expression *> at(uint index);
|
||||
|
||||
/// Return an iterator to be used with the `for` loop. It's implicitly called
|
||||
/// by the for loop.
|
||||
|
|
|
@ -121,7 +121,7 @@ public:
|
|||
/// pointers to the actual arguments.
|
||||
// llvm::Error
|
||||
// invokePacked(llvm::StringRef name,
|
||||
// llvm::MutableArrayRef<void *> args = llvm::None) const;
|
||||
// llvm::MutableArrayRef<void *> args = std::nullopt) const;
|
||||
|
||||
/// Trait that defines how a given type is passed to the JIT code. This
|
||||
/// defaults to passing the address but can be specialized.
|
||||
|
|
|
@ -78,8 +78,8 @@ using Ast = std::vector<Node>;
|
|||
|
||||
using NSPtr = std::shared_ptr<Namespace>;
|
||||
using MaybeNS = llvm::Expected<NSPtr>;
|
||||
using MaybeModule = llvm::Optional<llvm::orc::ThreadSafeModule>;
|
||||
using MaybeModuleOp = llvm::Optional<mlir::OwningOpRef<mlir::ModuleOp>>;
|
||||
using MaybeModule = std::optional<llvm::orc::ThreadSafeModule>;
|
||||
using MaybeModuleOp = std::optional<mlir::OwningOpRef<mlir::ModuleOp>>;
|
||||
using SemanticEnv = Environment<exprs::Node>;
|
||||
using SemanticEnvPtr = std::unique_ptr<SemanticEnv>;
|
||||
using SemanticEnvironments = std::vector<SemanticEnvPtr>;
|
||||
|
@ -111,15 +111,15 @@ private:
|
|||
|
||||
public:
|
||||
std::string name;
|
||||
llvm::Optional<std::string> filename;
|
||||
std::optional<std::string> filename;
|
||||
|
||||
/// Create a naw namespace with the given `name` and optional `filename` and
|
||||
/// return a shared pointer to it in the given Serene context.
|
||||
static NSPtr make(SereneContext &ctx, llvm::StringRef name,
|
||||
llvm::Optional<llvm::StringRef> filename);
|
||||
std::optional<llvm::StringRef> filename);
|
||||
|
||||
Namespace(SereneContext &ctx, llvm::StringRef ns_name,
|
||||
llvm::Optional<llvm::StringRef> filename);
|
||||
std::optional<llvm::StringRef> filename);
|
||||
|
||||
/// Create a new environment with the give \p parent as the parent,
|
||||
/// push the environment to the internal environment storage and
|
||||
|
|
|
@ -35,7 +35,7 @@ struct Location {
|
|||
/// a namespace in hand
|
||||
llvm::StringRef ns;
|
||||
|
||||
llvm::Optional<llvm::StringRef> filename = llvm::None;
|
||||
std::optional<llvm::StringRef> filename = std::nullopt;
|
||||
/// A pointer to the character that this location is pointing to
|
||||
/// it the input buffer
|
||||
const char *c = nullptr;
|
||||
|
@ -51,7 +51,7 @@ struct Location {
|
|||
|
||||
Location() = default;
|
||||
Location(llvm::StringRef ns,
|
||||
llvm::Optional<llvm::StringRef> fname = llvm::None,
|
||||
std::optional<llvm::StringRef> fname = std::nullopt,
|
||||
const char *c = nullptr, unsigned short int line = 0,
|
||||
unsigned short int col = 0, bool knownLocation = true)
|
||||
: ns(ns), filename(fname), c(c), line(line), col(col),
|
||||
|
@ -63,7 +63,7 @@ struct Location {
|
|||
|
||||
/// Returns an unknown location for the given \p ns.
|
||||
static Location UnknownLocation(llvm::StringRef ns) {
|
||||
return Location(ns, llvm::None, nullptr, 0, 0, false);
|
||||
return Location(ns, std::nullopt, nullptr, 0, 0, false);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -70,7 +70,7 @@ private:
|
|||
SereneContext &ctx;
|
||||
|
||||
llvm::StringRef ns;
|
||||
llvm::Optional<llvm::StringRef> filename;
|
||||
std::optional<llvm::StringRef> filename;
|
||||
|
||||
const char *currentChar = NULL;
|
||||
|
||||
|
@ -110,9 +110,9 @@ private:
|
|||
|
||||
public:
|
||||
Reader(SereneContext &ctx, llvm::StringRef buf, llvm::StringRef ns,
|
||||
llvm::Optional<llvm::StringRef> filename);
|
||||
std::optional<llvm::StringRef> filename);
|
||||
Reader(SereneContext &ctx, llvm::MemoryBufferRef buf, llvm::StringRef ns,
|
||||
llvm::Optional<llvm::StringRef> filename);
|
||||
std::optional<llvm::StringRef> filename);
|
||||
|
||||
// void setInput(const llvm::StringRef string);
|
||||
|
||||
|
@ -127,11 +127,11 @@ public:
|
|||
/// which may contains an AST or an `llvm::Error`
|
||||
SERENE_EXPORT exprs::MaybeAst read(SereneContext &ctx, llvm::StringRef input,
|
||||
llvm::StringRef ns,
|
||||
llvm::Optional<llvm::StringRef> filename);
|
||||
std::optional<llvm::StringRef> filename);
|
||||
SERENE_EXPORT exprs::MaybeAst read(SereneContext &ctx,
|
||||
llvm::MemoryBufferRef input,
|
||||
llvm::StringRef ns,
|
||||
llvm::Optional<llvm::StringRef> filename);
|
||||
std::optional<llvm::StringRef> filename);
|
||||
} // namespace serene::reader
|
||||
|
||||
#endif
|
||||
|
|
|
@ -31,7 +31,7 @@ namespace slir {
|
|||
// std::unique_ptr<llvm::Module> compileToLLVMIR(serene::SereneContext &ctx,
|
||||
// mlir::ModuleOp &module);
|
||||
|
||||
llvm::Optional<llvm::orc::ThreadSafeModule>
|
||||
std::optional<llvm::orc::ThreadSafeModule>
|
||||
compileToLLVMIR(serene::SereneContext &ctx, mlir::ModuleOp &module);
|
||||
} // namespace slir
|
||||
} // namespace serene
|
||||
|
|
|
@ -52,8 +52,8 @@ class TypeConverter : public mlir::TypeConverter {
|
|||
|
||||
using mlir::TypeConverter::convertType;
|
||||
|
||||
using MaybeType = llvm::Optional<mlir::Type>;
|
||||
using MaybeValue = llvm::Optional<mlir::Value>;
|
||||
using MaybeType = std::optional<mlir::Type>;
|
||||
using MaybeValue = std::optional<mlir::Value>;
|
||||
using ConverterFn = std::function<MaybeType(mlir::Type)>;
|
||||
|
||||
std::function<MaybeValue(mlir::OpBuilder &, SymbolType, mlir::ValueRange,
|
||||
|
|
|
@ -91,7 +91,7 @@ int SereneContext::getOptimizatioLevel() {
|
|||
}
|
||||
|
||||
NSPtr SereneContext::makeNamespace(llvm::StringRef name,
|
||||
llvm::Optional<llvm::StringRef> filename) {
|
||||
std::optional<llvm::StringRef> filename) {
|
||||
auto ns = Namespace::make(*this, name, filename);
|
||||
|
||||
if (ns != nullptr) {
|
||||
|
|
|
@ -97,12 +97,12 @@ std::vector<Node>::iterator List::end() { return elements.end(); }
|
|||
|
||||
size_t List::count() const { return elements.size(); }
|
||||
|
||||
llvm::Optional<Expression *> List::at(uint index) {
|
||||
std::optional<Expression *> List::at(uint index) {
|
||||
if (index >= elements.size()) {
|
||||
return llvm::None;
|
||||
}
|
||||
|
||||
return llvm::Optional<Expression *>(this->elements[index].get());
|
||||
return std::optional<Expression *>(this->elements[index].get());
|
||||
}
|
||||
|
||||
Ast List::from(uint index) {
|
||||
|
|
|
@ -42,7 +42,7 @@ using namespace llvm;
|
|||
namespace serene {
|
||||
|
||||
Namespace::Namespace(SereneContext &ctx, llvm::StringRef ns_name,
|
||||
llvm::Optional<llvm::StringRef> filename)
|
||||
std::optional<llvm::StringRef> filename)
|
||||
: ctx(ctx), name(ns_name) {
|
||||
if (filename.hasValue()) {
|
||||
this->filename.emplace(filename.getValue().str());
|
||||
|
@ -119,7 +119,7 @@ MaybeModuleOp Namespace::generate(unsigned offset) {
|
|||
|
||||
// TODO: Fix the unknown location by pointing to the `ns` form
|
||||
auto module = mlir::ModuleOp::create(builder.getUnknownLoc(),
|
||||
llvm::Optional<llvm::StringRef>(name));
|
||||
std::optional<llvm::StringRef>(name));
|
||||
|
||||
auto treeSize = getTree().size();
|
||||
|
||||
|
@ -211,7 +211,7 @@ MaybeModule Namespace::compileToLLVMFromOffset(unsigned offset) {
|
|||
};
|
||||
|
||||
NSPtr Namespace::make(SereneContext &ctx, llvm::StringRef name,
|
||||
llvm::Optional<llvm::StringRef> filename) {
|
||||
std::optional<llvm::StringRef> filename) {
|
||||
return std::make_shared<Namespace>(ctx, name, filename);
|
||||
};
|
||||
|
||||
|
|
|
@ -106,7 +106,7 @@ void decLocation(Location &loc, const char *c) {
|
|||
}
|
||||
|
||||
Reader::Reader(SereneContext &ctx, llvm::StringRef buffer, llvm::StringRef ns,
|
||||
llvm::Optional<llvm::StringRef> filename)
|
||||
std::optional<llvm::StringRef> filename)
|
||||
: ctx(ctx), ns(ns), filename(filename), buf(buffer),
|
||||
currentLocation(Location(ns, filename)) {
|
||||
UNUSED(this->ctx);
|
||||
|
@ -118,7 +118,7 @@ Reader::Reader(SereneContext &ctx, llvm::StringRef buffer, llvm::StringRef ns,
|
|||
};
|
||||
|
||||
Reader::Reader(SereneContext &ctx, llvm::MemoryBufferRef buffer,
|
||||
llvm::StringRef ns, llvm::Optional<llvm::StringRef> filename)
|
||||
llvm::StringRef ns, std::optional<llvm::StringRef> filename)
|
||||
: Reader(ctx, buffer.getBuffer(), ns, filename){};
|
||||
|
||||
Reader::~Reader() { READER_LOG("Destroying the reader"); }
|
||||
|
@ -420,7 +420,7 @@ exprs::MaybeAst Reader::read() {
|
|||
|
||||
exprs::MaybeAst read(SereneContext &ctx, const llvm::StringRef input,
|
||||
llvm::StringRef ns,
|
||||
llvm::Optional<llvm::StringRef> filename) {
|
||||
std::optional<llvm::StringRef> filename) {
|
||||
reader::Reader r(ctx, input, ns, filename);
|
||||
auto ast = r.read();
|
||||
return ast;
|
||||
|
@ -428,7 +428,7 @@ exprs::MaybeAst read(SereneContext &ctx, const llvm::StringRef input,
|
|||
|
||||
exprs::MaybeAst read(SereneContext &ctx, const llvm::MemoryBufferRef input,
|
||||
llvm::StringRef ns,
|
||||
llvm::Optional<llvm::StringRef> filename) {
|
||||
std::optional<llvm::StringRef> filename) {
|
||||
reader::Reader r(ctx, input, ns, filename);
|
||||
|
||||
auto ast = r.read();
|
||||
|
|
|
@ -95,7 +95,7 @@ SERENE_EXPORT exprs::MaybeAst read(SereneContext &ctx, std::string &input) {
|
|||
auto filename =
|
||||
!currentNS.filename.hasValue()
|
||||
? llvm::None
|
||||
: llvm::Optional<llvm::StringRef>(currentNS.filename.getValue());
|
||||
: std::optional<llvm::StringRef>(currentNS.filename.getValue());
|
||||
|
||||
return reader::read(ctx, input, currentNS.name, filename);
|
||||
};
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
namespace serene {
|
||||
namespace slir {
|
||||
|
||||
llvm::Optional<llvm::orc::ThreadSafeModule>
|
||||
std::optional<llvm::orc::ThreadSafeModule>
|
||||
compileToLLVMIR(serene::SereneContext &ctx, mlir::ModuleOp &module) {
|
||||
|
||||
auto llvmContext = serene::SereneContext::genLLVMContext();
|
||||
|
|
|
@ -102,7 +102,7 @@ MaybeNS SourceMgr::readNamespace(SereneContext &ctx, std::string name,
|
|||
|
||||
// Read the content of the buffer by passing it the reader
|
||||
auto maybeAst = reader::read(ctx, buf->getBuffer(), name,
|
||||
llvm::Optional(llvm::StringRef(importedFile)));
|
||||
std::optional(llvm::StringRef(importedFile)));
|
||||
|
||||
if (!maybeAst) {
|
||||
SMGR_LOG("Couldn't Read namespace: " + name);
|
||||
|
@ -111,7 +111,7 @@ MaybeNS SourceMgr::readNamespace(SereneContext &ctx, std::string name,
|
|||
|
||||
// Create the NS and set the AST
|
||||
auto ns =
|
||||
ctx.makeNamespace(name, llvm::Optional(llvm::StringRef(importedFile)));
|
||||
ctx.makeNamespace(name, std::optional(llvm::StringRef(importedFile)));
|
||||
|
||||
if (auto errs = ns->addTree(*maybeAst)) {
|
||||
SMGR_LOG("Couldn't set the AST for namespace: " + name);
|
||||
|
|
|
@ -101,7 +101,7 @@ using MaybeJitAddress = llvm::Expected<JitWrappedAddress>;
|
|||
using Dylib = llvm::orc::JITDylib;
|
||||
using DylibPtr = Dylib *;
|
||||
using MaybeDylibPtr = llvm::Expected<DylibPtr>;
|
||||
using MaybeNSFileTypeArr = llvm::Optional<llvm::ArrayRef<fs::NSFileType>>;
|
||||
using MaybeNSFileTypeArr = std::optional<llvm::ArrayRef<fs::NSFileType>>;
|
||||
|
||||
/// A simple object cache following Lang's LLJITWithObjectCache example and
|
||||
/// MLIR's SimpelObjectCache.
|
||||
|
@ -227,7 +227,7 @@ public:
|
|||
/// pointers to the actual arguments.
|
||||
llvm::Error
|
||||
invokePacked(const types::Symbol &name,
|
||||
llvm::MutableArrayRef<void *> args = llvm::None) const;
|
||||
llvm::MutableArrayRef<void *> args = std::nullopt) const;
|
||||
|
||||
llvm::Error loadModule(const char *nsName, const char *file);
|
||||
void dumpToObjectFile(llvm::StringRef filename);
|
||||
|
|
|
@ -151,7 +151,7 @@ static std::string banner =
|
|||
// const auto *features = "";
|
||||
|
||||
// llvm::TargetOptions opt;
|
||||
// auto rm = llvm::Optional<llvm::Reloc::Model>();
|
||||
// auto rm = std::optional<llvm::Reloc::Model>();
|
||||
// auto *targetMachinePtr =
|
||||
// target->createTargetMachine(ctx.targetTriple, cpu, features, opt, rm);
|
||||
// auto targetMachine =
|
||||
|
|
Loading…
Reference in New Issue