Fix all the tidy issues
This commit is contained in:
parent
55e0788bae
commit
fd66e47cd7
|
@ -42,7 +42,7 @@ namespace serene {
|
|||
|
||||
namespace reader {
|
||||
class LocationRange;
|
||||
}
|
||||
} // namespace reader
|
||||
|
||||
namespace exprs {
|
||||
class Expression;
|
||||
|
|
|
@ -20,8 +20,10 @@
|
|||
#define SERENE_ERRORS_CONSTANTS_H
|
||||
|
||||
#include <llvm/Support/FormatVariadic.h>
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
namespace serene {
|
||||
namespace errors {
|
||||
|
@ -50,7 +52,8 @@ struct ErrorVariant {
|
|||
std::string longDescription;
|
||||
|
||||
ErrorVariant(ErrID id, std::string desc, std::string longDesc)
|
||||
: id(id), description(desc), longDescription(longDesc){};
|
||||
: id(id), description(std::move(desc)),
|
||||
longDescription(std::move(longDesc)){};
|
||||
|
||||
std::string getErrId() { return llvm::formatv("E{0:d}", id); };
|
||||
};
|
||||
|
|
|
@ -16,8 +16,8 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef ERRORS_TRAITS_H
|
||||
#define ERRORS_TRAITS_H
|
||||
#ifndef SERENE_ERRORS_TRAITS_H
|
||||
#define SERENE_ERRORS_TRAITS_H
|
||||
|
||||
#include "serene/context.h"
|
||||
#include "serene/errors/constants.h"
|
||||
|
|
|
@ -16,8 +16,8 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef EXPRS_CALL_H
|
||||
#define EXPRS_CALL_H
|
||||
#ifndef SERENE_EXPRS_CALL_H
|
||||
#define SERENE_EXPRS_CALL_H
|
||||
|
||||
#include "serene/context.h"
|
||||
#include "serene/errors/error.h"
|
||||
|
@ -26,6 +26,7 @@
|
|||
|
||||
#include <llvm/ADT/StringRef.h>
|
||||
#include <llvm/Support/Error.h>
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
|
@ -49,8 +50,9 @@ public:
|
|||
|
||||
ExprType getType() const override;
|
||||
std::string toString() const override;
|
||||
MaybeNode analyze(SereneContext &) override;
|
||||
void generateIR(serene::Namespace &, mlir::ModuleOp &) override{};
|
||||
MaybeNode analyze(SereneContext & /*ctx*/) override;
|
||||
void generateIR(serene::Namespace & /*ns*/,
|
||||
mlir::ModuleOp & /*m*/) override{};
|
||||
|
||||
static bool classof(const Expression *e);
|
||||
|
||||
|
|
|
@ -16,8 +16,8 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef EXPRS_DEF_H
|
||||
#define EXPRS_DEF_H
|
||||
#ifndef SERENE_EXPRS_DEF_H
|
||||
#define SERENE_EXPRS_DEF_H
|
||||
|
||||
#include "serene/context.h"
|
||||
#include "serene/errors/error.h"
|
||||
|
@ -25,6 +25,7 @@
|
|||
|
||||
#include <llvm/ADT/StringRef.h>
|
||||
#include <llvm/Support/Error.h>
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
|
@ -48,8 +49,8 @@ public:
|
|||
|
||||
ExprType getType() const override;
|
||||
std::string toString() const override;
|
||||
MaybeNode analyze(SereneContext &) override;
|
||||
void generateIR(serene::Namespace &, mlir::ModuleOp &) override;
|
||||
MaybeNode analyze(SereneContext & /*ctx*/) override;
|
||||
void generateIR(serene::Namespace & /*ns*/, mlir::ModuleOp & /*m*/) override;
|
||||
|
||||
static bool classof(const Expression *e);
|
||||
|
||||
|
|
|
@ -16,8 +16,8 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef EXPRS_EXPRESSION_H
|
||||
#define EXPRS_EXPRESSION_H
|
||||
#ifndef SERENE_EXPRS_EXPRESSION_H
|
||||
#define SERENE_EXPRS_EXPRESSION_H
|
||||
|
||||
#include "serene/context.h"
|
||||
#include "serene/errors/error.h"
|
||||
|
@ -25,9 +25,10 @@
|
|||
#include "serene/reader/location.h"
|
||||
#include "serene/utils.h"
|
||||
|
||||
#include <memory>
|
||||
#include <mlir/IR/BuiltinOps.h>
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace serene {
|
||||
|
||||
/// Contains all the builtin AST expressions including those which do not appear
|
||||
|
|
|
@ -16,8 +16,8 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef EXPRS_FN_H
|
||||
#define EXPRS_FN_H
|
||||
#ifndef SERENE_EXPRS_FN_H
|
||||
#define SERENE_EXPRS_FN_H
|
||||
|
||||
#include "serene/context.h"
|
||||
#include "serene/errors/error.h"
|
||||
|
@ -27,6 +27,7 @@
|
|||
|
||||
#include <llvm/ADT/StringRef.h>
|
||||
#include <llvm/Support/Error.h>
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
|
@ -52,8 +53,8 @@ public:
|
|||
|
||||
ExprType getType() const override;
|
||||
std::string toString() const override;
|
||||
MaybeNode analyze(SereneContext &) override;
|
||||
void generateIR(serene::Namespace &, mlir::ModuleOp &) override;
|
||||
MaybeNode analyze(SereneContext & /*ctx*/) override;
|
||||
void generateIR(serene::Namespace & /*ns*/, mlir::ModuleOp & /*m*/) override;
|
||||
|
||||
static bool classof(const Expression *e);
|
||||
|
||||
|
|
|
@ -16,8 +16,8 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef EXPRS_LIST_H
|
||||
#define EXPRS_LIST_H
|
||||
#ifndef SERENE_EXPRS_LIST_H
|
||||
#define SERENE_EXPRS_LIST_H
|
||||
|
||||
#include "serene/context.h"
|
||||
#include "serene/exprs/expression.h"
|
||||
|
|
|
@ -16,8 +16,8 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef EXPRS_NUMBER_H
|
||||
#define EXPRS_NUMBER_H
|
||||
#ifndef SERENE_EXPRS_NUMBER_H
|
||||
#define SERENE_EXPRS_NUMBER_H
|
||||
|
||||
#include "serene/context.h"
|
||||
#include "serene/exprs/expression.h"
|
||||
|
@ -48,7 +48,7 @@ struct Number : public Expression {
|
|||
std::string toString() const override;
|
||||
|
||||
MaybeNode analyze(SereneContext &ctx) override;
|
||||
void generateIR(serene::Namespace &, mlir::ModuleOp &) override;
|
||||
void generateIR(serene::Namespace & /*ns*/, mlir::ModuleOp & /*m*/) override;
|
||||
|
||||
// TODO: This is horrible, we need to fix it after the mvp
|
||||
int toI64() const;
|
||||
|
|
|
@ -16,13 +16,14 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef EXPRS_SYMBOL_H
|
||||
#define EXPRS_SYMBOL_H
|
||||
#ifndef SERENE_EXPRS_SYMBOL_H
|
||||
#define SERENE_EXPRS_SYMBOL_H
|
||||
|
||||
#include "serene/context.h"
|
||||
#include "serene/exprs/expression.h"
|
||||
|
||||
#include <llvm/ADT/StringRef.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace serene {
|
||||
|
@ -44,8 +45,9 @@ public:
|
|||
ExprType getType() const override;
|
||||
std::string toString() const override;
|
||||
|
||||
MaybeNode analyze(SereneContext &) override;
|
||||
void generateIR(serene::Namespace &, mlir::ModuleOp &) override{};
|
||||
MaybeNode analyze(SereneContext & /*ctx*/) override;
|
||||
void generateIR(serene::Namespace & /*ns*/,
|
||||
mlir::ModuleOp & /*m*/) override{};
|
||||
|
||||
~Symbol() = default;
|
||||
|
||||
|
|
|
@ -16,8 +16,8 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef EXPRS_TRAITS_H
|
||||
#define EXPRS_TRAITS_H
|
||||
#ifndef SERENE_EXPRS_TRAITS_H
|
||||
#define SERENE_EXPRS_TRAITS_H
|
||||
|
||||
#include "serene/context.h"
|
||||
#include "serene/reader/location.h"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#ifndef SERENE_LLVM_VALUE_H
|
||||
#define SERENE_LLVM_VALUE_H
|
||||
#ifndef LLVM_IR_VALUE_H
|
||||
#define LLVM_IR_VALUE_H
|
||||
|
||||
#pragma clang diagnostic ignored "-Wunused-parameter"
|
||||
#include <llvm/IR/Value.h>
|
||||
|
|
|
@ -16,8 +16,8 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef SERENE_LLVM_PATCHES_H
|
||||
#define SERENE_LLVM_PATCHES_H
|
||||
#ifndef LLVM_PATCHES_H
|
||||
#define LLVM_PATCHES_H
|
||||
|
||||
#include <llvm/ADT/DenseMap.h>
|
||||
|
||||
|
@ -34,17 +34,19 @@ struct DenseMapInfo<std::string> {
|
|||
return "0TOMBED";
|
||||
}
|
||||
|
||||
static unsigned getHashValue(std::string Val) {
|
||||
static unsigned getHashValue(const std::string &Val) {
|
||||
assert(Val != getEmptyKey() && "Cannot hash the empty key!");
|
||||
assert(Val != getTombstoneKey() && "Cannot hash the tombstone key!");
|
||||
return (unsigned)(llvm::hash_value(Val));
|
||||
}
|
||||
|
||||
static bool isEqual(std::string LHS, std::string RHS) {
|
||||
if (RHS == getEmptyKey())
|
||||
static bool isEqual(const std::string &LHS, const std::string &RHS) {
|
||||
if (RHS == getEmptyKey()) {
|
||||
return LHS == getEmptyKey();
|
||||
if (RHS == getTombstoneKey())
|
||||
}
|
||||
if (RHS == getTombstoneKey()) {
|
||||
return LHS == getTombstoneKey();
|
||||
}
|
||||
return LHS == RHS;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -34,17 +34,18 @@
|
|||
#include "serene/traits.h"
|
||||
#include "serene/utils.h"
|
||||
|
||||
#include <atomic>
|
||||
#include <llvm/ADT/SmallString.h>
|
||||
#include <llvm/ADT/StringRef.h>
|
||||
#include <llvm/ADT/Twine.h>
|
||||
#include <llvm/IR/Module.h>
|
||||
#include <memory>
|
||||
#include <mlir/IR/Builders.h>
|
||||
#include <mlir/IR/BuiltinOps.h>
|
||||
#include <mlir/IR/OwningOpRef.h>
|
||||
#include <mlir/IR/Value.h>
|
||||
#include <mlir/Support/LogicalResult.h>
|
||||
|
||||
#include <atomic>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#define NAMESPACE_LOG(...) \
|
||||
|
|
|
@ -16,8 +16,8 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef SERENE_LOCATION_H
|
||||
#define SERENE_LOCATION_H
|
||||
#ifndef SERENE_READER_LOCATION_H
|
||||
#define SERENE_READER_LOCATION_H
|
||||
|
||||
#include <mlir/IR/Diagnostics.h>
|
||||
#include <mlir/IR/Location.h>
|
||||
|
@ -77,7 +77,7 @@ public:
|
|||
LocationRange(Location _start, Location _end) : start(_start), end(_end){};
|
||||
// LocationRange(const LocationRange &);
|
||||
|
||||
bool isKnownLocation() { return start.knownLocation; };
|
||||
bool isKnownLocation() const { return start.knownLocation; };
|
||||
|
||||
static LocationRange UnknownLocation(llvm::StringRef ns) {
|
||||
return LocationRange(Location::UnknownLocation(ns));
|
||||
|
|
|
@ -31,8 +31,8 @@
|
|||
|
||||
*/
|
||||
|
||||
#ifndef READER_H
|
||||
#define READER_H
|
||||
#ifndef SERENE_READER_READER_H
|
||||
#define SERENE_READER_READER_H
|
||||
|
||||
#include "serene/errors.h"
|
||||
#include "serene/exprs/expression.h"
|
||||
|
@ -121,10 +121,10 @@ public:
|
|||
|
||||
/// Parses the given `input` string and returns a `Result<ast>`
|
||||
/// which may contains an AST or an `llvm::Error`
|
||||
Result<exprs::Ast> read(SereneContext &ctx, const llvm::StringRef input,
|
||||
Result<exprs::Ast> read(SereneContext &ctx, llvm::StringRef input,
|
||||
llvm::StringRef ns,
|
||||
llvm::Optional<llvm::StringRef> filename);
|
||||
Result<exprs::Ast> read(SereneContext &ctx, const llvm::MemoryBufferRef input,
|
||||
Result<exprs::Ast> read(SereneContext &ctx, llvm::MemoryBufferRef input,
|
||||
llvm::StringRef ns,
|
||||
llvm::Optional<llvm::StringRef> filename);
|
||||
} // namespace serene::reader
|
||||
|
|
|
@ -16,8 +16,8 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef READER_SEMANTICS_H
|
||||
#define READER_SEMANTICS_H
|
||||
#ifndef SERENE_READER_SEMANTICS_H
|
||||
#define SERENE_READER_SEMANTICS_H
|
||||
|
||||
#include "serene/context.h"
|
||||
#include "serene/errors/error.h"
|
||||
|
|
|
@ -16,8 +16,8 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef READER_TRAITS_H
|
||||
#define READER_TRAITS_H
|
||||
#ifndef SERENE_READER_TRAITS_H
|
||||
#define SERENE_READER_TRAITS_H
|
||||
|
||||
#include "serene/reader/location.h"
|
||||
#include "serene/traits.h"
|
||||
|
|
|
@ -15,8 +15,8 @@
|
|||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#ifndef SERENE_SLIR_DIALECT_H_
|
||||
#define SERENE_SLIR_DIALECT_H_
|
||||
#ifndef SERENE_SLIR_DIALECT_H
|
||||
#define SERENE_SLIR_DIALECT_H
|
||||
|
||||
#include <mlir/IR/BuiltinOps.h>
|
||||
#include <mlir/IR/Dialect.h>
|
||||
|
@ -34,4 +34,4 @@
|
|||
|
||||
#include "serene/slir/ops.h.inc"
|
||||
|
||||
#endif // DIALECT_H_
|
||||
#endif // SERENE_SLIR_DIALECT_H
|
||||
|
|
|
@ -15,15 +15,16 @@
|
|||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#ifndef SERENE_SLIR_H
|
||||
#define SERENE_SLIR_H
|
||||
#ifndef SERENE_SLIR_SLIR_H
|
||||
#define SERENE_SLIR_SLIR_H
|
||||
|
||||
#include "serene/exprs/expression.h"
|
||||
|
||||
#include <memory>
|
||||
#include <mlir/IR/BuiltinOps.h>
|
||||
#include <mlir/IR/MLIRContext.h>
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace serene {
|
||||
namespace slir {
|
||||
std::unique_ptr<llvm::Module> compileToLLVMIR(serene::SereneContext &ctx,
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
namespace serene {
|
||||
class Namespace;
|
||||
}
|
||||
} // namespace serene
|
||||
|
||||
namespace serene::slir {
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef TRAITS_LOCATABLE_H
|
||||
#define TRAITS_LOCATABLE_H
|
||||
#ifndef SERENE_TRAITS_LOCATABLE_H
|
||||
#define SERENE_TRAITS_LOCATABLE_H
|
||||
|
||||
#endif
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include "serene/export.h"
|
||||
|
||||
#include <llvm/Support/Error.h>
|
||||
|
||||
#include <variant>
|
||||
|
||||
// Sometimes we need this to make both analyzer happy
|
||||
|
@ -92,33 +93,6 @@ public:
|
|||
bool ok() const { return std::holds_alternative<T>(contents); };
|
||||
|
||||
operator bool() const { return ok(); }
|
||||
|
||||
const T &getValueOrFail(llvm::StringRef msg, int exitCode = 1) const & {
|
||||
if (ok()) {
|
||||
return getValue();
|
||||
}
|
||||
|
||||
llvm::errs() << msg << "\n";
|
||||
exit(exitCode);
|
||||
}
|
||||
|
||||
T &getValueOrFail(llvm::StringRef msg, int exitCode = 1) & {
|
||||
if (ok()) {
|
||||
return getValue();
|
||||
}
|
||||
|
||||
llvm::errs() << msg << "\n";
|
||||
exit(exitCode);
|
||||
}
|
||||
|
||||
T &&getValueOrFail(llvm::StringRef msg, int exitCode = 1) && {
|
||||
if (ok()) {
|
||||
return std::move(getValue());
|
||||
}
|
||||
|
||||
llvm::errs() << msg << "\n";
|
||||
exit(exitCode);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace serene
|
||||
|
|
|
@ -42,6 +42,7 @@
|
|||
#include <llvm/Support/raw_ostream.h>
|
||||
#include <llvm/Target/TargetMachine.h>
|
||||
#include <llvm/Target/TargetOptions.h>
|
||||
|
||||
#include <memory>
|
||||
|
||||
using namespace std;
|
||||
|
|
Loading…
Reference in New Issue