Fix the clang tidy's issues in serenec
This commit is contained in:
parent
9850b99607
commit
b79f7a62c1
21
builder
21
builder
|
@ -34,8 +34,10 @@ BUILD_DIR=$ROOT_DIR/build
|
|||
ME=$(cd "$(dirname "$0")/." >/dev/null 2>&1 ; pwd -P)
|
||||
|
||||
CMAKEARGS_DEBUG=" -DCMAKE_BUILD_TYPE=Debug -DSERENE_WITH_MLIR_CL_OPTION=ON"
|
||||
CMAKEARGS="-DSERENE_CCACHE_DIR=${HOME}/.ccache"
|
||||
scanbuild=scan-build
|
||||
CMAKEARGS="-DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DSERENE_CCACHE_DIR=${HOME}/.ccache"
|
||||
|
||||
# The scan-build utility scans the build for bugs checkout the man page
|
||||
scanbuild="scan-build --force-analyze-debug-code --use-analyzer=$(which clang)"
|
||||
|
||||
|
||||
function gen_precompile_header_index() {
|
||||
|
@ -55,6 +57,13 @@ function popd_build() {
|
|||
popd > /dev/null || return
|
||||
}
|
||||
|
||||
function build-gen() {
|
||||
pushed_build
|
||||
echo "Running: "
|
||||
echo "cmake -G Ninja $CMAKEARGS $CMAKEARGS_DEBUG \"$@\" \"$ROOT_DIR\""
|
||||
cmake -G Ninja $CMAKEARGS $CMAKEARGS_DEBUG "$@" "$ROOT_DIR"
|
||||
popd_build
|
||||
}
|
||||
function compile() {
|
||||
pushed_build
|
||||
cmake --build .
|
||||
|
@ -62,10 +71,8 @@ function compile() {
|
|||
}
|
||||
|
||||
function build() {
|
||||
build-gen
|
||||
pushed_build
|
||||
echo "Running: "
|
||||
echo "cmake -G Ninja $CMAKE_CCACHE $CMAKEARGS -DCMAKE_BUILD_TYPE=Debug \"$@\" \"$ROOT_DIR\""
|
||||
cmake -G Ninja $CMAKEARGS $CMAKEARGS_DEBUG "$@" "$ROOT_DIR"
|
||||
cmake --build .
|
||||
popd_build
|
||||
}
|
||||
|
@ -177,9 +184,9 @@ case "$command" in
|
|||
"scan-build")
|
||||
clean
|
||||
mkdir -p "$BUILD_DIR"
|
||||
build-gen
|
||||
pushed_build
|
||||
exec $scanbuild cmake "$ROOT_DIR"
|
||||
exec $scanbuild scan-build make -j 4
|
||||
exec $scanbuild cmake --build .
|
||||
popd_build
|
||||
;;
|
||||
"memcheck")
|
||||
|
|
|
@ -63,7 +63,8 @@ enum Action {
|
|||
// TODO: Remove this option and replace it by a subcommand
|
||||
RunJIT,
|
||||
};
|
||||
}
|
||||
} // namespace
|
||||
|
||||
static std::string banner =
|
||||
llvm::formatv("\n\nSerene Compiler Version {0}"
|
||||
"\nCopyright (C) 2019-2021 "
|
||||
|
@ -123,32 +124,35 @@ int dumpAsObject(Namespace &ns) {
|
|||
module->setTargetTriple(ctx.targetTriple);
|
||||
|
||||
std::string Error;
|
||||
auto target = llvm::TargetRegistry::lookupTarget(ctx.targetTriple, Error);
|
||||
const auto *target =
|
||||
llvm::TargetRegistry::lookupTarget(ctx.targetTriple, Error);
|
||||
|
||||
// Print an error and exit if we couldn't find the requested target.
|
||||
// This generally occurs if we've forgotten to initialise the
|
||||
// TargetRegistry or we have a bogus target triple.
|
||||
if (!target) {
|
||||
if (target == nullptr) {
|
||||
llvm::errs() << Error;
|
||||
return 1;
|
||||
}
|
||||
|
||||
auto cpu = "generic";
|
||||
auto features = "";
|
||||
const auto *cpu = "generic";
|
||||
const auto *features = "";
|
||||
|
||||
llvm::TargetOptions opt;
|
||||
auto rm = llvm::Optional<llvm::Reloc::Model>();
|
||||
auto targetMachinePtr =
|
||||
auto *targetMachinePtr =
|
||||
target->createTargetMachine(ctx.targetTriple, cpu, features, opt, rm);
|
||||
auto targetMachine = std::unique_ptr<llvm::TargetMachine>(targetMachinePtr);
|
||||
|
||||
module->setDataLayout(targetMachine->createDataLayout());
|
||||
|
||||
auto filename =
|
||||
const auto *filename =
|
||||
strcmp(outputFile.c_str(), "-") == 0 ? "output" : outputFile.c_str();
|
||||
|
||||
std::error_code ec;
|
||||
llvm::SmallString<256> destFile(outputDir);
|
||||
const auto pathSize(256);
|
||||
|
||||
llvm::SmallString<pathSize> destFile(outputDir);
|
||||
llvm::sys::path::append(destFile, filename);
|
||||
auto destObjFilePath = llvm::formatv("{0}.o", destFile).str();
|
||||
llvm::raw_fd_ostream dest(destObjFilePath, ec, llvm::sys::fs::OF_None);
|
||||
|
@ -317,7 +321,7 @@ int main(int argc, char *argv[]) {
|
|||
};
|
||||
|
||||
case Action::RunJIT: {
|
||||
auto maybeJIT = JIT::make(*ns.get());
|
||||
auto maybeJIT = JIT::make(*ns);
|
||||
if (!maybeJIT) {
|
||||
// TODO: panic in here: "Couldn't creat the JIT!"
|
||||
return -1;
|
||||
|
|
Loading…
Reference in New Issue