diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 9de1df5c..9fd543de 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -35,9 +35,6 @@ jobs: - name: Setup llvm & libstdc++ & cmake & ninja if: matrix.os == 'ubuntu-24.04' run: | - sudo apt update - sudo apt install -y software-properties-common - sudo add-apt-repository ppa:ubuntu-toolchain-r/test sudo apt update sudo apt install -y gcc-14 g++-14 libstdc++-14-dev sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-14 100 @@ -69,7 +66,7 @@ jobs: - name: Setup msvc sysroot for cmake if: matrix.os == 'windows-2022' uses: ilammy/msvc-dev-cmd@v1 - + - name: Build clice (debug) if: matrix.os == 'ubuntu-24.04' run: | diff --git a/.github/workflows/xmake.yml b/.github/workflows/xmake.yml index d5124d28..0e81ee1b 100644 --- a/.github/workflows/xmake.yml +++ b/.github/workflows/xmake.yml @@ -30,9 +30,6 @@ jobs: steps: - name: Setup llvm & libstdc++ & cmake & ninja run: | - sudo apt update - sudo apt install -y software-properties-common - sudo add-apt-repository ppa:ubuntu-toolchain-r/test sudo apt update sudo apt install -y gcc-14 g++-14 libstdc++-14-dev sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-14 100 diff --git a/include/Support/Format.h b/include/Support/Format.h index 03c2b0b2..475129a3 100644 --- a/include/Support/Format.h +++ b/include/Support/Format.h @@ -171,7 +171,7 @@ std::string pretty_dump(const Object& object, std::size_t indent = 2) { auto repr = dump(object); auto json = json::parse(repr); if(!json) { - std::terminate(); + std::abort(); } llvm::SmallString<128> buffer = {std::format("{{0:{}}}", indent)}; return llvm::formatv(buffer.c_str(), *json); diff --git a/include/Support/Logger.h b/include/Support/Logger.h index 6161b61c..70c6d883 100644 --- a/include/Support/Logger.h +++ b/include/Support/Logger.h @@ -54,7 +54,7 @@ void trace(std::format_string fmt, Args&&... args) { template void fatal [[noreturn]] (std::format_string fmt, Args&&... args) { log::log(Level::FATAL, fmt.get(), std::forward(args)...); - std::terminate(); + std::abort(); } } // namespace clice::log diff --git a/include/Test/CTest.h b/include/Test/CTest.h index c59811c4..da33c9c1 100644 --- a/include/Test/CTest.h +++ b/include/Test/CTest.h @@ -84,7 +84,7 @@ public: auto info = compile(params); if(!info) { llvm::errs() << "Failed to build AST\n"; - std::terminate(); + std::abort(); } this->info.emplace(std::move(*info)); diff --git a/src/AST/Resolver.cpp b/src/AST/Resolver.cpp index 08ef473e..2c4bafa0 100644 --- a/src/AST/Resolver.cpp +++ b/src/AST/Resolver.cpp @@ -382,7 +382,7 @@ public: case clang::NestedNameSpecifier::NamespaceAlias: case clang::NestedNameSpecifier::Super: { llvm::errs() << "Unexpected name specifier\n"; - std::terminate(); + std::abort(); } } } diff --git a/src/Basic/SourceConverter.cpp b/src/Basic/SourceConverter.cpp index 1eed4eec..de7dad58 100644 --- a/src/Basic/SourceConverter.cpp +++ b/src/Basic/SourceConverter.cpp @@ -226,7 +226,7 @@ static std::string decodePercent(llvm::StringRef content) { proto::DocumentUri SourceConverter::toURI(llvm::StringRef fspath) { if(!path::is_absolute(fspath)) - std::terminate(); + std::abort(); llvm::SmallString<128> path("file://"); #if defined(_WIN32) @@ -265,13 +265,13 @@ std::string SourceConverter::toPath(llvm::StringRef uri) { if(cloned.starts_with("file:///")) { cloned = cloned.drop_front(8); } else { - std::terminate(); + std::abort(); } #elif defined(__unix__) if(cloned.starts_with("file://")) { cloned = cloned.drop_front(7); } else { - std::terminate(); + std::abort(); } #else #error "Unsupported platform" @@ -282,7 +282,7 @@ std::string SourceConverter::toPath(llvm::StringRef uri) { llvm::SmallString<128> result; if(auto err = fs::real_path(decoded, result)) { print("Failed to get real path: {}, Input is {}\n", err.message(), decoded); - std::terminate(); + std::abort(); } return result.str().str(); diff --git a/src/Compiler/Compilation.cpp b/src/Compiler/Compilation.cpp index af902cbe..b0ffad0e 100644 --- a/src/Compiler/Compilation.cpp +++ b/src/Compiler/Compilation.cpp @@ -13,7 +13,7 @@ std::unique_ptr createInvocation(CompilationParams& p llvm::SmallVector args; if(auto result = mangleCommand(params.command, args, buffer); !result) { - std::terminate(); + std::abort(); } clang::CreateInvocationOptions options = {}; @@ -21,7 +21,7 @@ std::unique_ptr createInvocation(CompilationParams& p auto invocation = clang::createInvocation(args, options); if(!invocation) { - std::terminate(); + std::abort(); } auto& frontOpts = invocation->getFrontendOpts(); @@ -70,7 +70,7 @@ std::unique_ptr createInstance(CompilationParams& param } if(!instance->createTarget()) { - std::terminate(); + std::abort(); } auto [pch, bound] = params.pch; diff --git a/src/Compiler/Diagnostic.cpp b/src/Compiler/Diagnostic.cpp index 02bbf57b..83a11116 100644 --- a/src/Compiler/Diagnostic.cpp +++ b/src/Compiler/Diagnostic.cpp @@ -105,7 +105,7 @@ void dumpArg(clang::DiagnosticsEngine::ArgumentKind kind, std::uint64_t value) { } default: { - std::terminate(); + std::abort(); } } diff --git a/src/Feature/CodeCompletion.cpp b/src/Feature/CodeCompletion.cpp index 96f051e6..f3da4ba3 100644 --- a/src/Feature/CodeCompletion.cpp +++ b/src/Feature/CodeCompletion.cpp @@ -108,12 +108,12 @@ std::string getName(const clang::NamedDecl* decl) { return name.getCXXLiteralIdentifier()->getName().str(); } case clang::DeclarationName::CXXUsingDirective: { - std::terminate(); + std::abort(); }; case clang::DeclarationName::ObjCZeroArgSelector: case clang::DeclarationName::ObjCOneArgSelector: case clang::DeclarationName::ObjCMultiArgSelector: { - std::terminate(); + std::abort(); } } } @@ -218,7 +218,7 @@ proto::CompletionResult codeCompletion(CompilationParams& params, for(auto& item: completions) {} return completions; } else { - std::terminate(); + std::abort(); } } diff --git a/src/Index/SymbolIndex.cpp b/src/Index/SymbolIndex.cpp index a44a0704..1e3bd939 100644 --- a/src/Index/SymbolIndex.cpp +++ b/src/Index/SymbolIndex.cpp @@ -15,7 +15,7 @@ namespace { const static clang::NamedDecl* normalize(const clang::NamedDecl* decl) { if(!decl) { - std::terminate(); + std::abort(); } decl = llvm::cast(decl->getCanonicalDecl()); @@ -107,6 +107,11 @@ public: /// to make sure that the data is in the same order even they are in different /// files. + /// Polyfill ranges::iota for libc++ + auto iota = [](auto &r, auto init) { + ranges::generate(r, [init] mutable { return init++; }); + }; + /// Map the old index to new index. std::vector symbolMap(file.symbols.size()); std::vector locationMap(file.ranges.size()); @@ -114,7 +119,7 @@ public: { /// Sort symbols and update the symbolMap. std::vector new2old(file.symbols.size()); - std::ranges::iota(new2old, 0u); + iota(new2old, 0u); ranges::sort(views::zip(file.symbols, new2old), refl::less, [](const auto& element) { auto& symbol = std::get<0>(element); @@ -129,7 +134,7 @@ public: { /// Sort locations and update the locationMap. std::vector new2old(file.ranges.size()); - std::ranges::iota(new2old, 0u); + iota(new2old, 0u); ranges::sort(views::zip(file.ranges, new2old), refl::less, [](const auto& element) { return std::get<0>(element); diff --git a/unittests/Compiler/Module.cpp b/unittests/Compiler/Module.cpp index f182f632..483e0c45 100644 --- a/unittests/Compiler/Module.cpp +++ b/unittests/Compiler/Module.cpp @@ -20,7 +20,7 @@ PCMInfo buildPCM(llvm::StringRef file, llvm::StringRef code) { PCMInfo pcm; if(!compile(params, pcm)) { llvm::errs() << "Failed to build PCM\n"; - std::terminate(); + std::abort(); } return pcm; @@ -35,7 +35,7 @@ ModuleInfo scan(llvm::StringRef content) { auto info = scanModule(params); if(!info) { llvm::errs() << "Failed to scan module\n"; - std::terminate(); + std::abort(); } return std::move(*info); } diff --git a/unittests/Feature/SemanticTokens.cpp b/unittests/Feature/SemanticTokens.cpp index 1e0d3c32..5bc128bd 100644 --- a/unittests/Feature/SemanticTokens.cpp +++ b/unittests/Feature/SemanticTokens.cpp @@ -59,7 +59,7 @@ struct SemanticTokens : ::testing::Test, Tester { void dumpResult() { auto& tokens = result[info->getInterestedFile()]; for(auto& token: tokens) { - println("token: {}", dump(token)); + clice::println("token: {}", dump(token)); } } };