From 9370dfaccfb5dc1c3c90113b0fa72019a9076d29 Mon Sep 17 00:00:00 2001 From: Vladislav Kalugin Date: Mon, 15 Jan 2024 15:42:35 +0300 Subject: [PATCH] Update to llvm 14 (#664) * Build docker with llvm 14 * Add "Free disk space on runner" in publish base env * Change dwarf to 4 version --- .github/workflows/matrix.json | 4 +- .github/workflows/publish-base-env.yml | 11 + docker/Dockerfile_base | 35 +- docker/building_dependencies/clean_release.sh | 2 +- .../llvm_gold_plugin/plugin-api.h | 574 ------------------ docker/building_dependencies/runtime_env.sh | 8 +- .../utbot_run_system.sh | 2 + server/src/BordersFinder.cpp | 7 +- server/src/BordersFinder.h | 11 +- server/src/building/IRParser.cpp | 2 +- server/src/clang-utils/ASTPrinter.cpp | 7 +- server/src/clang-utils/AlignmentFetcher.cpp | 1 + .../SourceToHeaderMatchCallback.cpp | 1 + .../src/printers/DefaultMakefilePrinter.cpp | 2 +- server/src/printers/HeaderPrinter.cpp | 8 +- .../src/printers/KleeConstraintsPrinter.cpp | 2 +- server/src/printers/KleePrinter.cpp | 18 +- server/src/printers/Printer.cpp | 42 +- server/src/printers/Printer.h | 12 +- server/src/printers/SourceWrapperPrinter.cpp | 4 +- server/src/printers/StubsPrinter.cpp | 20 +- server/src/printers/TestsPrinter.cpp | 60 +- server/src/types/TypeVisitor.cpp | 3 +- server/src/utils/path/FileSystemPath.h | 4 + .../visitors/ParametrizedAssertsVisitor.cpp | 6 +- .../VerboseAssertsReturnValueVisitor.cpp | 2 +- server/src/visitors/VerboseAssertsVisitor.cpp | 2 +- .../src/visitors/VerboseParameterVisitor.cpp | 2 +- server/test/framework/Server_Tests.cpp | 8 +- server/test/framework/Syntax_Tests.cpp | 6 +- server/test/suites/server/keywords.c | 3 +- submodules/build-klee.sh | 1 - 32 files changed, 164 insertions(+), 706 deletions(-) delete mode 100644 docker/building_dependencies/llvm_gold_plugin/plugin-api.h diff --git a/.github/workflows/matrix.json b/.github/workflows/matrix.json index 08a8be0b9..584945c31 100644 --- a/.github/workflows/matrix.json +++ b/.github/workflows/matrix.json @@ -1,9 +1,9 @@ { "include": [ { - "DOCKER_TAG": "2023.10.0", + "DOCKER_TAG": "2023.12.0", "OPERATING_SYSTEM_TAG": "18.04", - "LLVM_VERSION_MAJOR": "10" + "LLVM_VERSION_MAJOR": "14" } ] } diff --git a/.github/workflows/publish-base-env.yml b/.github/workflows/publish-base-env.yml index a1f662e61..99f984cf1 100644 --- a/.github/workflows/publish-base-env.yml +++ b/.github/workflows/publish-base-env.yml @@ -31,6 +31,17 @@ jobs: steps: - uses: actions/checkout@v3 + - name: Free Disk Space (Ubuntu) + uses: jlumbroso/free-disk-space@main + with: + tool-cache: true + android: true + dotnet: true + haskell: true + large-packages: true + docker-images: true + swap-storage: true + - name: Log in to the Container registry uses: docker/login-action@v2 with: diff --git a/docker/Dockerfile_base b/docker/Dockerfile_base index 57b047184..1403462d5 100644 --- a/docker/Dockerfile_base +++ b/docker/Dockerfile_base @@ -23,8 +23,9 @@ RUN echo "check_certificate = off" > /etc/wgetrc # We use C++ 17 for UnitTestBot, it is available in gcc-9; default gcc for ubuntu:18.04 is gcc-7 RUN add-apt-repository ppa:ubuntu-toolchain-r/test -RUN apt update && apt install -y --no-install-recommends gcc-9 g++-9 -# Skip 32bits libs installation before LLVM compilation +RUN apt update && apt install -y --no-install-recommends gcc-9 g++-9 gcc-multilib g++-multilib gcc-9-multilib g++-9-multilib + +# Set gcc-9 as default gcc version RUN sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 100 RUN sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-9 100 RUN sudo update-alternatives --install /usr/bin/gcov gcov /usr/bin/gcov-9 100 @@ -69,22 +70,24 @@ WORKDIR /home/utbot USER root ARG LLVM_VERSION_MAJOR RUN mkdir $UTBOT_ALL/llvm_gold_plugin -COPY building_dependencies/llvm_gold_plugin/plugin-api.h $UTBOT_ALL/llvm_gold_plugin +RUN wget -P $UTBOT_ALL/llvm_gold_plugin https://raw.githubusercontent.com/bminor/binutils-gdb/fd67aa1129fd006ad49ed5ecb2b063705211553a/include/plugin-api.h RUN git clone --single-branch --branch "release/${LLVM_VERSION_MAJOR}.x" --depth 1 "https://github.com/llvm/llvm-project.git" $UTBOT_ALL/llvm-project WORKDIR $UTBOT_ALL/llvm-project RUN mkdir build && cd build \ && $UTBOT_CMAKE_BINARY \ - -DCMAKE_BUILD_TYPE=MinSizeRel \ + -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_INSTALL_PREFIX=$UTBOT_INSTALL_DIR \ -DLLVM_INCLUDE_TESTS=OFF \ -DLLVM_BINUTILS_INCDIR=$UTBOT_ALL/llvm_gold_plugin \ -DLLVM_ENABLE_RTTI=ON \ -DLLVM_ENABLE_EH=ON \ -DLLVM_TARGETS_TO_BUILD="host" \ - -DLLVM_ENABLE_PROJECTS="clang;compiler-rt;libc;libclc;libcxx;libcxxabi;lld;lldb;clang-tools-extra" -G "Ninja" ../llvm \ + -DLLVM_INSTALL_UTILS=ON \ + -DLLVM_ENABLE_PROJECTS="clang;libclc;lld;lldb;clang-tools-extra" \ + -DLLVM_ENABLE_RUNTIMES="compiler-rt;libc;libcxx;libcxxabi" \ + -G "Ninja" ../llvm \ && $UTBOT_CMAKE_BINARY --build . --target install - # Install KLEE dependencies ENV CURL_CA_BUNDLE="" RUN sudo -E pip3 install tabulate==0.8.7 \ @@ -92,6 +95,9 @@ RUN sudo -E pip3 install tabulate==0.8.7 \ lit==0.11.0.post1 \ wllvm==1.3.1 +ENV CFLAGS="-gdwarf-4" +ENV CXXFLAGS="-gdwarf-4" + WORKDIR $UTBOT_ALL/llvm-project RUN mkdir libcxx_build && cd libcxx_build \ && export CC=wllvm \ @@ -125,7 +131,7 @@ RUN cd $UTBOT_ALL/grpc && git submodule update --init RUN cd $UTBOT_ALL/grpc \ && mkdir -p cmake/build \ && cd cmake/build \ - && $UTBOT_CMAKE_BINARY -DgRPC_INSTALL=ON -DgRPC_BUILD_TESTS=OFF -DCMAKE_BUILD_TYPE=MinSizeRel -DCMAKE_INSTALL_PREFIX=$UTBOT_INSTALL_DIR ../.. \ + && $UTBOT_CMAKE_BINARY -DgRPC_INSTALL=ON -DgRPC_BUILD_TESTS=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$UTBOT_INSTALL_DIR ../.. \ && make -j`nproc` \ && make install \ && cd $UTBOT_ALL \ @@ -205,13 +211,16 @@ RUN wget https://github.com/agauniyal/rang/releases/download/v3.1.0/rang.hpp -P COPY building_dependencies/runtime_env.sh /home/utbot/.bashrc COPY building_dependencies/runtime_env.sh /root/.bashrc -# Install uclibc -RUN git clone -b klee_uclibc_v1.2 https://github.com/klee/klee-uclibc.git $UTBOT_ALL/klee-uclibc -WORKDIR $UTBOT_ALL/klee-uclibc -RUN ./configure --make-llvm-lib && make -j`nproc` +# We need to install version 32 and 64 for klee. +# Install uclibc-32 +RUN git clone -b klee_uclibc_v1.2 https://github.com/klee/klee-uclibc.git $UTBOT_ALL/klee-uclibc-32 +WORKDIR $UTBOT_ALL/klee-uclibc-32 +RUN ./configure --make-llvm-lib && make KLEE_CFLAGS="-m32" -j`nproc` -# Install 32bits libs AFTER LLVM compilation -RUN apt update && apt install -y --no-install-recommends gcc-multilib g++-multilib gcc-9-multilib g++-9-multilib +# Install uclibc-64 +RUN git clone -b klee_uclibc_v1.2 https://github.com/klee/klee-uclibc.git $UTBOT_ALL/klee-uclibc-64 +WORKDIR $UTBOT_ALL/klee-uclibc-64 +RUN ./configure --make-llvm-lib && make -j`nproc` # Download library for access private members RUN git clone https://github.com/martong/access_private.git $UTBOT_ALL/access_private diff --git a/docker/building_dependencies/clean_release.sh b/docker/building_dependencies/clean_release.sh index f35f9690f..57401f10a 100644 --- a/docker/building_dependencies/clean_release.sh +++ b/docker/building_dependencies/clean_release.sh @@ -1,7 +1,7 @@ # This script clears out all the unnecessary files from the release build # Need just clang-10, llvm-cov, llvm-profdata and cmake in $UTBOT_INSTALL_DIR/bin -cd $UTBOT_INSTALL_DIR/bin && find -type f \( -name "*" ! -name "llvm-cov" ! -name "llvm-profdata" ! -name "llvm-nm" ! -name "clang" ! -name "clang++" ! -name "clang-10" ! -name cmake \) -delete +cd $UTBOT_INSTALL_DIR/bin && find -type f \( -name "*" ! -name "llvm-cov" ! -name "llvm-profdata" ! -name "llvm-nm" ! -name "clang" ! -name "clang++" ! -name "clang-14" ! -name cmake \) -delete # Delete all broken links. Don't need to delete clang which is a link (not broken) to clang-10 find $UTBOT_INSTALL_DIR/bin/ -xtype l -delete diff --git a/docker/building_dependencies/llvm_gold_plugin/plugin-api.h b/docker/building_dependencies/llvm_gold_plugin/plugin-api.h deleted file mode 100644 index 6f8e348d2..000000000 --- a/docker/building_dependencies/llvm_gold_plugin/plugin-api.h +++ /dev/null @@ -1,574 +0,0 @@ -/* This file is a copy of https://github.com/bminor/binutils-gdb/blob/master/include/plugin-api.h and it is needed to build LLVM gold plugin */ - -/* plugin-api.h -- External linker plugin API. */ - -/* Copyright (C) 2009-2020 Free Software Foundation, Inc. - Written by Cary Coutant . - - This file is part of binutils. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, - MA 02110-1301, USA. */ - -/* This file defines the interface for writing a linker plugin, which is - described at < http://gcc.gnu.org/wiki/whopr/driver >. */ - -#ifndef PLUGIN_API_H -#define PLUGIN_API_H - -#ifdef HAVE_STDINT_H -#include -#elif defined(HAVE_INTTYPES_H) -#include -#endif -#include -#if !defined(HAVE_STDINT_H) && !defined(HAVE_INTTYPES_H) && \ - !defined(UINT64_MAX) && !defined(uint64_t) -#error cannot find uint64_t type -#endif - -/* Detect endianess based on __BYTE_ORDER__ macro. */ -#if defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && \ - defined(__ORDER_LITTLE_ENDIAN__) && defined(__ORDER_PDP_ENDIAN__) -#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ -#define PLUGIN_LITTLE_ENDIAN 1 -#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ -#define PLUGIN_BIG_ENDIAN 1 -#elif __BYTE_ORDER__ == __ORDER_PDP_ENDIAN__ -#define PLUGIN_PDP_ENDIAN 1 -#endif -#else -/* Older GCC releases (<4.6.0) can make detection from glibc macros. */ -#if defined(__GLIBC__) || defined(__GNU_LIBRARY__) || defined(__ANDROID__) -#include -#ifdef __BYTE_ORDER -#if __BYTE_ORDER == __LITTLE_ENDIAN -#define PLUGIN_LITTLE_ENDIAN 1 -#elif __BYTE_ORDER == __BIG_ENDIAN -#define PLUGIN_BIG_ENDIAN 1 -#endif -#endif -#endif -/* Include all necessary header files based on target. */ -#if defined(__SVR4) && defined(__sun) -#include -#endif -#if defined(__FreeBSD__) || defined(__NetBSD__) || \ - defined(__DragonFly__) || defined(__minix) -#include -#endif -#if defined(__OpenBSD__) -#include -#endif -/* Detect endianess based on _BYTE_ORDER. */ -#ifdef _BYTE_ORDER -#if _BYTE_ORDER == _LITTLE_ENDIAN -#define PLUGIN_LITTLE_ENDIAN 1 -#elif _BYTE_ORDER == _BIG_ENDIAN -#define PLUGIN_BIG_ENDIAN 1 -#endif -#endif -/* Detect based on _WIN32. */ -#if defined(_WIN32) -#define PLUGIN_LITTLE_ENDIAN 1 -#endif -/* Detect based on __BIG_ENDIAN__ and __LITTLE_ENDIAN__ */ -#ifdef __LITTLE_ENDIAN__ -#define PLUGIN_LITTLE_ENDIAN 1 -#endif -#ifdef __BIG_ENDIAN__ -#define PLUGIN_BIG_ENDIAN 1 -#endif -#endif - -#ifdef __cplusplus -extern "C" -{ -#endif - -/* Status code returned by most API routines. */ - -enum ld_plugin_status -{ - LDPS_OK = 0, - LDPS_NO_SYMS, /* Attempt to get symbols that haven't been added. */ - LDPS_BAD_HANDLE, /* No claimed object associated with given handle. */ - LDPS_ERR - /* Additional Error codes TBD. */ -}; - -/* The version of the API specification. */ - -enum ld_plugin_api_version -{ - LD_PLUGIN_API_VERSION = 1 -}; - -/* The type of output file being generated by the linker. */ - -enum ld_plugin_output_file_type -{ - LDPO_REL, - LDPO_EXEC, - LDPO_DYN, - LDPO_PIE -}; - -/* An input file managed by the plugin library. */ - -struct ld_plugin_input_file -{ - const char *name; - int fd; - off_t offset; - off_t filesize; - void *handle; -}; - -/* A symbol belonging to an input file managed by the plugin library. */ - -struct ld_plugin_symbol -{ - char *name; - char *version; - /* This is for compatibility with older ABIs. The older ABI defined - only 'def' field. */ -#if PLUGIN_BIG_ENDIAN == 1 - char unused; - char section_kind; - char symbol_type; - char def; -#elif PLUGIN_LITTLE_ENDIAN == 1 - char def; - char symbol_type; - char section_kind; - char unused; -#elif PLUGIN_PDP_ENDIAN == 1 - char symbol_type; - char def; - char unused; - char section_kind; -#else -#error "Could not detect architecture endianess" -#endif - int visibility; - uint64_t size; - char *comdat_key; - int resolution; -}; - -/* An object's section. */ - -struct ld_plugin_section -{ - const void* handle; - unsigned int shndx; -}; - -/* Whether the symbol is a definition, reference, or common, weak or not. */ - -enum ld_plugin_symbol_kind -{ - LDPK_DEF, - LDPK_WEAKDEF, - LDPK_UNDEF, - LDPK_WEAKUNDEF, - LDPK_COMMON -}; - -/* The visibility of the symbol. */ - -enum ld_plugin_symbol_visibility -{ - LDPV_DEFAULT, - LDPV_PROTECTED, - LDPV_INTERNAL, - LDPV_HIDDEN -}; - -/* The type of the symbol. */ - -enum ld_plugin_symbol_type -{ - LDST_UNKNOWN, - LDST_FUNCTION, - LDST_VARIABLE -}; - -enum ld_plugin_symbol_section_kind -{ - LDSSK_DEFAULT, - LDSSK_BSS -}; - -/* How a symbol is resolved. */ - -enum ld_plugin_symbol_resolution -{ - LDPR_UNKNOWN = 0, - - /* Symbol is still undefined at this point. */ - LDPR_UNDEF, - - /* This is the prevailing definition of the symbol, with references from - regular object code. */ - LDPR_PREVAILING_DEF, - - /* This is the prevailing definition of the symbol, with no - references from regular objects. It is only referenced from IR - code. */ - LDPR_PREVAILING_DEF_IRONLY, - - /* This definition was pre-empted by a definition in a regular - object file. */ - LDPR_PREEMPTED_REG, - - /* This definition was pre-empted by a definition in another IR file. */ - LDPR_PREEMPTED_IR, - - /* This symbol was resolved by a definition in another IR file. */ - LDPR_RESOLVED_IR, - - /* This symbol was resolved by a definition in a regular object - linked into the main executable. */ - LDPR_RESOLVED_EXEC, - - /* This symbol was resolved by a definition in a shared object. */ - LDPR_RESOLVED_DYN, - - /* This is the prevailing definition of the symbol, with no - references from regular objects. It is only referenced from IR - code, but the symbol is exported and may be referenced from - a dynamic object (not seen at link time). */ - LDPR_PREVAILING_DEF_IRONLY_EXP -}; - -/* The plugin library's "claim file" handler. */ - -typedef -enum ld_plugin_status -(*ld_plugin_claim_file_handler) ( - const struct ld_plugin_input_file *file, int *claimed); - -/* The plugin library's "all symbols read" handler. */ - -typedef -enum ld_plugin_status -(*ld_plugin_all_symbols_read_handler) (void); - -/* The plugin library's cleanup handler. */ - -typedef -enum ld_plugin_status -(*ld_plugin_cleanup_handler) (void); - -/* The linker's interface for registering the "claim file" handler. */ - -typedef -enum ld_plugin_status -(*ld_plugin_register_claim_file) (ld_plugin_claim_file_handler handler); - -/* The linker's interface for registering the "all symbols read" handler. */ - -typedef -enum ld_plugin_status -(*ld_plugin_register_all_symbols_read) ( - ld_plugin_all_symbols_read_handler handler); - -/* The linker's interface for registering the cleanup handler. */ - -typedef -enum ld_plugin_status -(*ld_plugin_register_cleanup) (ld_plugin_cleanup_handler handler); - -/* The linker's interface for adding symbols from a claimed input file. */ - -typedef -enum ld_plugin_status -(*ld_plugin_add_symbols) (void *handle, int nsyms, - const struct ld_plugin_symbol *syms); - -/* The linker's interface for getting the input file information with - an open (possibly re-opened) file descriptor. */ - -typedef -enum ld_plugin_status -(*ld_plugin_get_input_file) (const void *handle, - struct ld_plugin_input_file *file); - -typedef -enum ld_plugin_status -(*ld_plugin_get_view) (const void *handle, const void **viewp); - -/* The linker's interface for releasing the input file. */ - -typedef -enum ld_plugin_status -(*ld_plugin_release_input_file) (const void *handle); - -/* The linker's interface for retrieving symbol resolution information. */ - -typedef -enum ld_plugin_status -(*ld_plugin_get_symbols) (const void *handle, int nsyms, - struct ld_plugin_symbol *syms); - -/* The linker's interface for adding a compiled input file. */ - -typedef -enum ld_plugin_status -(*ld_plugin_add_input_file) (const char *pathname); - -/* The linker's interface for adding a library that should be searched. */ - -typedef -enum ld_plugin_status -(*ld_plugin_add_input_library) (const char *libname); - -/* The linker's interface for adding a library path that should be searched. */ - -typedef -enum ld_plugin_status -(*ld_plugin_set_extra_library_path) (const char *path); - -/* The linker's interface for issuing a warning or error message. */ - -typedef -enum ld_plugin_status -(*ld_plugin_message) (int level, const char *format, ...); - -/* The linker's interface for retrieving the number of sections in an object. - The handle is obtained in the claim_file handler. This interface should - only be invoked in the claim_file handler. This function sets *COUNT to - the number of sections in the object. */ - -typedef -enum ld_plugin_status -(*ld_plugin_get_input_section_count) (const void* handle, unsigned int *count); - -/* The linker's interface for retrieving the section type of a specific - section in an object. This interface should only be invoked in the - claim_file handler. This function sets *TYPE to an ELF SHT_xxx value. */ - -typedef -enum ld_plugin_status -(*ld_plugin_get_input_section_type) (const struct ld_plugin_section section, - unsigned int *type); - -/* The linker's interface for retrieving the name of a specific section in - an object. This interface should only be invoked in the claim_file handler. - This function sets *SECTION_NAME_PTR to a null-terminated buffer allocated - by malloc. The plugin must free *SECTION_NAME_PTR. */ - -typedef -enum ld_plugin_status -(*ld_plugin_get_input_section_name) (const struct ld_plugin_section section, - char **section_name_ptr); - -/* The linker's interface for retrieving the contents of a specific section - in an object. This interface should only be invoked in the claim_file - handler. This function sets *SECTION_CONTENTS to point to a buffer that is - valid until clam_file handler returns. It sets *LEN to the size of the - buffer. */ - -typedef -enum ld_plugin_status -(*ld_plugin_get_input_section_contents) (const struct ld_plugin_section section, - const unsigned char **section_contents, - size_t* len); - -/* The linker's interface for specifying the desired order of sections. - The sections should be specifed using the array SECTION_LIST in the - order in which they should appear in the final layout. NUM_SECTIONS - specifies the number of entries in each array. This should be invoked - in the all_symbols_read handler. */ - -typedef -enum ld_plugin_status -(*ld_plugin_update_section_order) (const struct ld_plugin_section *section_list, - unsigned int num_sections); - -/* The linker's interface for specifying that reordering of sections is - desired so that the linker can prepare for it. This should be invoked - before update_section_order, preferably in the claim_file handler. */ - -typedef -enum ld_plugin_status -(*ld_plugin_allow_section_ordering) (void); - -/* The linker's interface for specifying that a subset of sections is - to be mapped to a unique segment. If the plugin wants to call - unique_segment_for_sections, it must call this function from a - claim_file_handler or when it is first loaded. */ - -typedef -enum ld_plugin_status -(*ld_plugin_allow_unique_segment_for_sections) (void); - -/* The linker's interface for specifying that a specific set of sections - must be mapped to a unique segment. ELF segments do not have names - and the NAME is used as the name of the newly created output section - that is then placed in the unique PT_LOAD segment. FLAGS is used to - specify if any additional segment flags need to be set. For instance, - a specific segment flag can be set to identify this segment. Unsetting - segment flags that would be set by default is not possible. The - parameter SEGMENT_ALIGNMENT when non-zero will override the default. */ - -typedef -enum ld_plugin_status -(*ld_plugin_unique_segment_for_sections) ( - const char* segment_name, - uint64_t segment_flags, - uint64_t segment_alignment, - const struct ld_plugin_section * section_list, - unsigned int num_sections); - -/* The linker's interface for retrieving the section alignment requirement - of a specific section in an object. This interface should only be invoked in the - claim_file handler. This function sets *ADDRALIGN to the ELF sh_addralign - value of the input section. */ - -typedef -enum ld_plugin_status -(*ld_plugin_get_input_section_alignment) (const struct ld_plugin_section section, - unsigned int *addralign); - -/* The linker's interface for retrieving the section size of a specific section - in an object. This interface should only be invoked in the claim_file handler. - This function sets *SECSIZE to the ELF sh_size - value of the input section. */ - -typedef -enum ld_plugin_status -(*ld_plugin_get_input_section_size) (const struct ld_plugin_section section, - uint64_t *secsize); - -typedef -enum ld_plugin_status -(*ld_plugin_new_input_handler) (const struct ld_plugin_input_file *file); - -/* The linker's interface for registering the "new_input" handler. This handler - will be notified when a new input file has been added after the - all_symbols_read event, allowing the plugin to, for example, set a unique - segment for sections in plugin-generated input files. */ - -typedef -enum ld_plugin_status -(*ld_plugin_register_new_input) (ld_plugin_new_input_handler handler); - -/* The linker's interface for getting the list of wrapped symbols using the - --wrap option. This sets *NUM_SYMBOLS to number of wrapped symbols and - *WRAP_SYMBOL_LIST to the list of wrapped symbols. */ - -typedef -enum ld_plugin_status -(*ld_plugin_get_wrap_symbols) (uint64_t *num_symbols, - const char ***wrap_symbol_list); - -enum ld_plugin_level -{ - LDPL_INFO, - LDPL_WARNING, - LDPL_ERROR, - LDPL_FATAL -}; - -/* Values for the tv_tag field of the transfer vector. */ - -enum ld_plugin_tag -{ - LDPT_NULL = 0, - LDPT_API_VERSION = 1, - LDPT_GOLD_VERSION = 2, - LDPT_LINKER_OUTPUT = 3, - LDPT_OPTION = 4, - LDPT_REGISTER_CLAIM_FILE_HOOK = 5, - LDPT_REGISTER_ALL_SYMBOLS_READ_HOOK = 6, - LDPT_REGISTER_CLEANUP_HOOK = 7, - LDPT_ADD_SYMBOLS = 8, - LDPT_GET_SYMBOLS = 9, - LDPT_ADD_INPUT_FILE = 10, - LDPT_MESSAGE = 11, - LDPT_GET_INPUT_FILE = 12, - LDPT_RELEASE_INPUT_FILE = 13, - LDPT_ADD_INPUT_LIBRARY = 14, - LDPT_OUTPUT_NAME = 15, - LDPT_SET_EXTRA_LIBRARY_PATH = 16, - LDPT_GNU_LD_VERSION = 17, - LDPT_GET_VIEW = 18, - LDPT_GET_INPUT_SECTION_COUNT = 19, - LDPT_GET_INPUT_SECTION_TYPE = 20, - LDPT_GET_INPUT_SECTION_NAME = 21, - LDPT_GET_INPUT_SECTION_CONTENTS = 22, - LDPT_UPDATE_SECTION_ORDER = 23, - LDPT_ALLOW_SECTION_ORDERING = 24, - LDPT_GET_SYMBOLS_V2 = 25, - LDPT_ALLOW_UNIQUE_SEGMENT_FOR_SECTIONS = 26, - LDPT_UNIQUE_SEGMENT_FOR_SECTIONS = 27, - LDPT_GET_SYMBOLS_V3 = 28, - LDPT_GET_INPUT_SECTION_ALIGNMENT = 29, - LDPT_GET_INPUT_SECTION_SIZE = 30, - LDPT_REGISTER_NEW_INPUT_HOOK = 31, - LDPT_GET_WRAP_SYMBOLS = 32, - LDPT_ADD_SYMBOLS_V2 = 33 -}; - -/* The plugin transfer vector. */ - -struct ld_plugin_tv -{ - enum ld_plugin_tag tv_tag; - union - { - int tv_val; - const char *tv_string; - ld_plugin_register_claim_file tv_register_claim_file; - ld_plugin_register_all_symbols_read tv_register_all_symbols_read; - ld_plugin_register_cleanup tv_register_cleanup; - ld_plugin_add_symbols tv_add_symbols; - ld_plugin_get_symbols tv_get_symbols; - ld_plugin_add_input_file tv_add_input_file; - ld_plugin_message tv_message; - ld_plugin_get_input_file tv_get_input_file; - ld_plugin_get_view tv_get_view; - ld_plugin_release_input_file tv_release_input_file; - ld_plugin_add_input_library tv_add_input_library; - ld_plugin_set_extra_library_path tv_set_extra_library_path; - ld_plugin_get_input_section_count tv_get_input_section_count; - ld_plugin_get_input_section_type tv_get_input_section_type; - ld_plugin_get_input_section_name tv_get_input_section_name; - ld_plugin_get_input_section_contents tv_get_input_section_contents; - ld_plugin_update_section_order tv_update_section_order; - ld_plugin_allow_section_ordering tv_allow_section_ordering; - ld_plugin_allow_unique_segment_for_sections tv_allow_unique_segment_for_sections; - ld_plugin_unique_segment_for_sections tv_unique_segment_for_sections; - ld_plugin_get_input_section_alignment tv_get_input_section_alignment; - ld_plugin_get_input_section_size tv_get_input_section_size; - ld_plugin_register_new_input tv_register_new_input; - ld_plugin_get_wrap_symbols tv_get_wrap_symbols; - } tv_u; -}; - -/* The plugin library's "onload" entry point. */ - -typedef -enum ld_plugin_status -(*ld_plugin_onload) (struct ld_plugin_tv *tv); - -#ifdef __cplusplus -} -#endif - -#endif /* !defined(PLUGIN_API_H) */ diff --git a/docker/building_dependencies/runtime_env.sh b/docker/building_dependencies/runtime_env.sh index 508dda0f5..d6c4a2b68 100644 --- a/docker/building_dependencies/runtime_env.sh +++ b/docker/building_dependencies/runtime_env.sh @@ -4,7 +4,7 @@ export UTBOT_ALL=/utbot_distr export UTBOT_INSTALL_DIR=$UTBOT_ALL/install export UTBOT_CMAKE_BINARY=$UTBOT_INSTALL_DIR/bin/cmake -export C_INCLUDE_PATH=$UTBOT_INSTALL_DIR/lib/clang/10.0.0/include/:$UTBOT_ALL/gtest/googletest/include +export C_INCLUDE_PATH=$UTBOT_ALL/gtest/googletest/include export LLVM_INCLUDE_DIRS=$UTBOT_ALL/llvm/llvm export CMAKE_CXX_STANDARD=17 export CMAKE_CXX_STANDARD_REQUIRED=ON @@ -15,7 +15,7 @@ export NODE_TLS_REJECT_UNAUTHORIZED=0 # KLEE env export COVERAGE=0 export USE_TCMALLOC=1 -export LLVM_VERSION=10.0 +export LLVM_VERSION=14.0 export ENABLE_OPTIMIZED=1 export ENABLE_DEBUG=1 export DISABLE_ASSERTIONS=0 @@ -33,9 +33,11 @@ export CXX=$UTBOT_INSTALL_DIR/bin/clang++ export CPATH=$CPATH:$UTBOT_ALL/klee/include export LD_LIBRARY_PATH=$UTBOT_INSTALL_DIR/lib export LDFLAGS='-fuse-ld=gold' +export CFLAGS="$CFLAGS -gdwarf-4" +export CXXFLAGS="$CXXFLAGS -gdwarf-4" export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$UTBOT_ALL/bear/bin:$UTBOT_ALL/klee/bin:$UTBOT_INSTALL_DIR/bin:$PATH if [ -z "${VERSION}" ] then export VERSION=$(date '+%Y.%-m').0 -fi \ No newline at end of file +fi diff --git a/docker/release_distribution_scripts/utbot_run_system.sh b/docker/release_distribution_scripts/utbot_run_system.sh index 843c486c7..11213c9e9 100644 --- a/docker/release_distribution_scripts/utbot_run_system.sh +++ b/docker/release_distribution_scripts/utbot_run_system.sh @@ -52,6 +52,8 @@ export LD_LIBRARY_PATH=$UTBOT_ALL/install/lib:$UTBOT_ALL/debs-install/lib/x86_64 export GENERAL_INCLUDES=$UTBOT_ALL/debs-install/usr/lib/gcc/x86_64-linux-gnu/9/include:$UTBOT_ALL/debs-install/usr/local/include:$UTBOT_ALL/debs-install/usr/include/x86_64-linux-gnu:$UTBOT_ALL/debs-install/usr/include export C_INCLUDE_PATH=GENERAL_INCLUDES${C_INCLUDE_PATH:+:${C_INCLUDE_PATH}} export CPLUS_INCLUDE_PATH=$UTBOT_ALL/debs-install/usr/include/c++/9:$UTBOT_ALL/debs-install/usr/include/x86_64-linux-gnu/c++/9:$UTBOT_ALL/debs-install/usr/include/c++/9/backward:GENERAL_INCLUDES${CPLUS_INCLUDE_PATH:+:${CPLUS_INCLUDE_PATH}} +export CFLAGS="$CFLAGS -gdwarf-4" +export CXXFLAGS="$CXXFLAGS -gdwarf-4" export LDFLAGS="-fuse-ld=gold $LDFLAGS" # This function moves dev version of libc into $UTBOT_ALL/debs-install directory diff --git a/server/src/BordersFinder.cpp b/server/src/BordersFinder.cpp index 97ec94381..5cb440392 100644 --- a/server/src/BordersFinder.cpp +++ b/server/src/BordersFinder.cpp @@ -1,11 +1,10 @@ #include "BordersFinder.h" -#include "Paths.h" #include "clang-utils/ASTPrinter.h" #include "clang-utils/Matchers.h" +#include "clang-utils/ClangUtils.h" #include "utils/CollectionUtils.h" #include "utils/CompilationUtils.h" -#include "clang-utils/ClangUtils.h" #include "loguru.h" @@ -117,11 +116,11 @@ BordersFinder::Borders BordersFinder::getFunctionBordersLines(const SourceManage } BordersFinder::Borders BordersFinder::getStmtBordersLines(const SourceManager &srcMng, const Stmt *st) { - return getStmtBordersLinesDynamic(srcMng, clang::ast_type_traits::DynTypedNode::create(*st)); + return getStmtBordersLinesDynamic(srcMng, clang::DynTypedNode::create(*st)); } BordersFinder::Borders BordersFinder::getStmtBordersLinesDynamic(const SourceManager &srcMng, - const clang::ast_type_traits::DynTypedNode st) { + const clang::DynTypedNode st) { auto sourceRange = st.getSourceRange(); return getBorders(srcMng, sourceRange); } diff --git a/server/src/BordersFinder.h b/server/src/BordersFinder.h index 71fd76f61..d6e635440 100644 --- a/server/src/BordersFinder.h +++ b/server/src/BordersFinder.h @@ -5,6 +5,7 @@ #include "LineInfo.h" #include "building/CompilationDatabase.h" +#include #include #include #include @@ -31,6 +32,7 @@ class BordersFinder : public clang::ast_matchers::MatchFinder::MatchCallback { private: unsigned line; LineInfo lineInfo{}; + struct Borders { struct Position { unsigned line; @@ -39,13 +41,14 @@ class BordersFinder : public clang::ast_matchers::MatchFinder::MatchCallback { Position start; Position end; - friend bool operator<(const Borders& lhs, const Borders& rhs) { + friend bool operator<(const Borders &lhs, const Borders &rhs) { return (rhs.start.line < lhs.start.line || - (rhs.start.line == lhs.start.line && rhs.start.column <= lhs.start.column)) && + (rhs.start.line == lhs.start.line && rhs.start.column <= lhs.start.column)) && (rhs.end.line > lhs.start.line || - (rhs.end.line == lhs.start.line && rhs.end.column >= lhs.start.column)); + (rhs.end.line == lhs.start.line && rhs.end.column >= lhs.start.column)); } }; + std::optional classBorder; ClangToolRunner clangToolRunner; @@ -53,7 +56,7 @@ class BordersFinder : public clang::ast_matchers::MatchFinder::MatchCallback { Borders getStmtBordersLines(const clang::SourceManager &srcMng, const clang::Stmt *st); - Borders getStmtBordersLinesDynamic(const clang::SourceManager &srcMng, clang::ast_type_traits::DynTypedNode st); + Borders getStmtBordersLinesDynamic(const clang::SourceManager &srcMng, clang::DynTypedNode st); [[nodiscard]] bool containsLine(Borders b) const; diff --git a/server/src/building/IRParser.cpp b/server/src/building/IRParser.cpp index 2b8c95075..35fd9fdc1 100644 --- a/server/src/building/IRParser.cpp +++ b/server/src/building/IRParser.cpp @@ -67,7 +67,7 @@ std::unique_ptr IRParser::getModule(const fs::path &rootBitcode, try { // catch Fatal error into LLVM IR parser llvm::ScopedFatalErrorHandler scopedHandler([](void *user_data, - const std::string &reason, + const char *reason, bool gen_crash_diag) { LOG_S(ERROR) << "Fatal error into LLVM. " << reason; throw LLVMException(reason); diff --git a/server/src/clang-utils/ASTPrinter.cpp b/server/src/clang-utils/ASTPrinter.cpp index 119c12759..22ead049e 100644 --- a/server/src/clang-utils/ASTPrinter.cpp +++ b/server/src/clang-utils/ASTPrinter.cpp @@ -16,8 +16,8 @@ std::string ASTPrinter::getSourceText(clang::SourceRange sourceRange, } std::string ASTPrinter::getSourceTextMacro(clang::SourceRange sourceRange, - const clang::SourceManager &sourceManager, - const clang::LangOptions &langOpts) { + const clang::SourceManager &sourceManager, + const clang::LangOptions &langOpts) { auto charRange = clang::Lexer::getAsCharRange(sourceRange, sourceManager, langOpts); auto stringRep = clang::Lexer::getSourceText(charRange, sourceManager, langOpts); return stringRep.str(); @@ -27,5 +27,6 @@ std::string ASTPrinter::getSourceTextRaw(clang::SourceRange sourceRange, const clang::SourceManager &sourceManager, const clang::LangOptions &langOpts) { - return clang::Lexer::getSourceText(clang::CharSourceRange::getCharRange(sourceRange), sourceManager, langOpts); + return clang::Lexer::getSourceText(clang::CharSourceRange::getCharRange(sourceRange), sourceManager, + langOpts).str(); } diff --git a/server/src/clang-utils/AlignmentFetcher.cpp b/server/src/clang-utils/AlignmentFetcher.cpp index 50c8d7a88..ba06521ab 100644 --- a/server/src/clang-utils/AlignmentFetcher.cpp +++ b/server/src/clang-utils/AlignmentFetcher.cpp @@ -1,5 +1,6 @@ #include "AlignmentFetcher.h" +#include #include using namespace clang; diff --git a/server/src/clang-utils/SourceToHeaderMatchCallback.cpp b/server/src/clang-utils/SourceToHeaderMatchCallback.cpp index 13968c98f..4d4b5b758 100644 --- a/server/src/clang-utils/SourceToHeaderMatchCallback.cpp +++ b/server/src/clang-utils/SourceToHeaderMatchCallback.cpp @@ -484,6 +484,7 @@ void SourceToHeaderMatchCallback::renameAnonymousReturnTypeDecl(const TagDecl *t void SourceToHeaderMatchCallback::replaceAnonymousEnumTypeName(std::string &strDecl, const std::string &typeName) const { StringUtils::replaceFirst(strDecl, "enum (anonymous)", typeName); + StringUtils::replaceFirst(strDecl, "enum (unnamed)", typeName); } bool SourceToHeaderMatchCallback::isAnonymousEnumDecl(const clang::TagDecl *tagDecl) const { diff --git a/server/src/printers/DefaultMakefilePrinter.cpp b/server/src/printers/DefaultMakefilePrinter.cpp index 1ca4f00dc..2e3c6c853 100644 --- a/server/src/printers/DefaultMakefilePrinter.cpp +++ b/server/src/printers/DefaultMakefilePrinter.cpp @@ -46,7 +46,7 @@ void DefaultMakefilePrinter::declareInclude(const std::string &otherMakefileName } void DefaultMakefilePrinter::writeCopyrightHeader() { - ss << Copyright::GENERATED_MAKEFILE_HEADER << NL; + ss << Copyright::GENERATED_MAKEFILE_HEADER << printer::NL; } } diff --git a/server/src/printers/HeaderPrinter.cpp b/server/src/printers/HeaderPrinter.cpp index f7b00aa81..57636d1d7 100644 --- a/server/src/printers/HeaderPrinter.cpp +++ b/server/src/printers/HeaderPrinter.cpp @@ -11,10 +11,10 @@ namespace printer { processHeader(Include(true, "cstring")); processHeader(Include(true, "unistd.h")); processHeader(Include(true, "stdio.h")); - ss << NL; - ss << PrinterUtils::redirectStdin << NL; - ss << PrinterUtils::writeToFile << NL; - ss << PrinterUtils::fromBytes << NL; + ss << printer::NL; + ss << PrinterUtils::redirectStdin << printer::NL; + ss << PrinterUtils::writeToFile << printer::NL; + ss << PrinterUtils::fromBytes << printer::NL; ss << PrinterUtils::constCast; headerCode += ss.str(); FileSystemUtils::writeToFile(testHeaderFilePath, headerCode); diff --git a/server/src/printers/KleeConstraintsPrinter.cpp b/server/src/printers/KleeConstraintsPrinter.cpp index 105fd1145..819ffc943 100644 --- a/server/src/printers/KleeConstraintsPrinter.cpp +++ b/server/src/printers/KleeConstraintsPrinter.cpp @@ -55,7 +55,7 @@ void KleeConstraintsPrinter::genConstraintsForPrimitive(const ConstraintsState & } void KleeConstraintsPrinter::noConstraints(const std::string &cause) { - ss << LINE_INDENT() << "// No constraints for " << cause << NL; + ss << LINE_INDENT() << "// No constraints for " << cause << printer::NL; } void KleeConstraintsPrinter::genConstraintsForEnum(const ConstraintsState &state) { diff --git a/server/src/printers/KleePrinter.cpp b/server/src/printers/KleePrinter.cpp index 91d305450..89bdf0169 100644 --- a/server/src/printers/KleePrinter.cpp +++ b/server/src/printers/KleePrinter.cpp @@ -46,7 +46,7 @@ void KleePrinter::writePosixWrapper(const Tests &tests, strFunctionCall(PrinterUtils::POSIX_CHECK_STDIN_READ, {}); strReturn(KleeUtils::RESULT_VARIABLE_NAME); closeBrackets(1); - ss << NL; + ss << printer::NL; } void KleePrinter::genOpenFiles(const tests::Tests::MethodDescription &testMethod) { @@ -94,7 +94,7 @@ void KleePrinter::writeTestedFunction(const Tests &tests, genPostParamsKleeAssumes(testMethod, filterAllWithoutFile); strReturn("0"); closeBrackets(1); - ss << NL; + ss << printer::NL; } fs::path KleePrinter::writeTmpKleeFile( @@ -142,8 +142,8 @@ fs::path KleePrinter::writeTmpKleeFile( strDeclareVar("int", PrinterUtils::KLEE_PATH_FLAG, "0"); } - strInclude("klee/klee.h") << NL; - ss << CALLOC_DECLARATION << NL; + strInclude("klee/klee.h") << printer::NL; + ss << CALLOC_DECLARATION << printer::NL; writeStubsForStructureFields(tests); writeAccessPrivateMacros(typesHandler, tests, false, [methodFilter, onlyForOneClass, onlyForOneFunction, testedMethod, testedClass]( @@ -156,7 +156,7 @@ fs::path KleePrinter::writeTmpKleeFile( }); strDeclareSetOfVars(tests.externVariables); - ss << NL; + ss << printer::NL; for (const auto &[methodName, testMethod]: tests.methods) { if (!methodFilter(testMethod)) { @@ -305,19 +305,19 @@ std::string KleePrinter::addTestLineFlag(const std::shared_ptr &lineIn } if (lineCounter == lineInfo->begin + lineInfo->insertAfter + 1) { if (lineInfo->wrapInBrackets) { - ss << "}" << NL; + ss << "}" << printer::NL; } } if (lineCounter == lineInfo->begin) { if (needAssertion) { ss << "#pragma push_macro(\"assert\")\n"; - ss << "#define assert(expr) if (!(expr)) {" << PrinterUtils::KLEE_PATH_FLAG << " = 1;}" << NL; + ss << "#define assert(expr) if (!(expr)) {" << PrinterUtils::KLEE_PATH_FLAG << " = 1;}" << printer::NL; } } - ss << currentLine << NL; + ss << currentLine << printer::NL; if (lineCounter == lineInfo->begin) { if (needAssertion) { - ss << "#pragma pop_macro(\"assert\")" << NL; + ss << "#pragma pop_macro(\"assert\")" << printer::NL; } } lineCounter++; diff --git a/server/src/printers/Printer.cpp b/server/src/printers/Printer.cpp index a9df671dd..1e9e238fa 100644 --- a/server/src/printers/Printer.cpp +++ b/server/src/printers/Printer.cpp @@ -39,12 +39,12 @@ namespace printer { Printer::Stream &printer::Printer::strInclude(const std::string &header, bool isAngled) { char begin = isAngled ? '<' : '\"'; char end = isAngled ? '>' : '\"'; - ss << LINE_INDENT() << "#include " << begin << header << end << NL; + ss << LINE_INDENT() << "#include " << begin << header << end << printer::NL; return ss; } std::stringstream &printer::Printer::strDefine(std::string_view from, std::string_view to) { - ss << "#define " << from << " " << to << NL; + ss << "#define " << from << " " << to << printer::NL; return ss; } @@ -53,7 +53,7 @@ namespace printer { } Printer::Stream &printer::Printer::strIncludeSystem(const std::string &header) { - ss << LINE_INDENT() << "#include <" << header << ">" << NL; + ss << LINE_INDENT() << "#include <" << header << ">" << printer::NL; return ss; } @@ -116,7 +116,7 @@ namespace printer { } Printer::Stream &printer::Printer::strDeclareAbsError(const std::string &name) { - ss << LINE_INDENT() << "static const float " << name << " = 1e-6;" << NL; + ss << LINE_INDENT() << "static const float " << name << " = 1e-6;" << printer::NL; return ss; } @@ -290,12 +290,12 @@ namespace printer { } Printer::Stream &Printer::strComment(const std::string &comment) { - ss << LINE_INDENT() << "// " << comment << NL; + ss << LINE_INDENT() << "// " << comment << printer::NL; return ss; } Printer::Stream &Printer::commentBlockSeparator() { - ss << LINE_INDENT() << "//////////////////////////////////////////// " << NL; + ss << LINE_INDENT() << "//////////////////////////////////////////// " << printer::NL; return ss; } @@ -389,9 +389,9 @@ namespace printer { std::stringstream& Printer::checkOverflowStubArray(const std::string &cntCall) { ss << LINE_INDENT() << "if (" << cntCall << " == " << - types::TypesHandler::getElementsNumberInPointerOneDim(types::PointerUsage::PARAMETER) << ") {" << NL; + types::TypesHandler::getElementsNumberInPointerOneDim(types::PointerUsage::PARAMETER) << ") {" << printer::NL; tabsDepth++; - ss << LINE_INDENT() << cntCall << "--;" << NL; + ss << LINE_INDENT() << cntCall << "--;" << printer::NL; ss << RB(); return ss; } @@ -427,7 +427,7 @@ namespace printer { std::string returnValue; if (types::TypesHandler::omitMakeSymbolic(method.returnType)) { returnValue = typesHandler.getDefaultValueForType(methodCopy.returnType, getLanguage()); - strReturn(returnValue) << RB() << NL; + strReturn(returnValue) << RB() << printer::NL; return ss; } @@ -435,7 +435,7 @@ namespace printer { strDeclareVar("static int", firstTimeCallVar, "1"); const std::string cntCall = "cntCall"; strDeclareVar("static int", cntCall, "0"); - ss << LINE_INDENT() << "#ifdef " << PrinterUtils::KLEE_MODE << NL; + ss << LINE_INDENT() << "#ifdef " << PrinterUtils::KLEE_MODE << printer::NL; tabsDepth++; ss << LINE_INDENT() << "if (" << firstTimeCallVar << " == 1)" << LB(); strAssignVar(firstTimeCallVar, "0"); @@ -450,12 +450,12 @@ namespace printer { ss << preferWriter.ss.str(); ss << RB(); tabsDepth--; - ss << LINE_INDENT() << "#endif" << NL; + ss << LINE_INDENT() << "#endif" << printer::NL; checkOverflowStubArray(cntCall); returnValue = stubSymbolicVarName + "[" + cntCall + "++]"; - strReturn(returnValue) << RB() << NL; + strReturn(returnValue) << RB() << printer::NL; return ss; } @@ -476,7 +476,7 @@ namespace printer { tabsDepth++; strAssignVar(arrayName + "[i]", stubFunctionName); tabsDepth--; - ss << LINE_INDENT() << "}" << NL; + ss << LINE_INDENT() << "}" << printer::NL; return ss; } @@ -584,9 +584,9 @@ namespace printer { const std::function &methodFilter) { if (srcLanguage == utbot::Language::CXX) { - ss << NL; + ss << printer::NL; strInclude("access_private.hpp"); - ss << NL; + ss << printer::NL; std::unordered_set checkedOnPrivate; for (const auto &[methodName, testMethod]: tests.methods) { if (!methodFilter(testMethod)) { @@ -602,7 +602,7 @@ namespace printer { } } } - ss << NL; + ss << printer::NL; } } @@ -622,7 +622,7 @@ namespace printer { type.typeName(), field.type.typeName(), field.name); - ss << NL; + ss << printer::NL; } addAccessor(typesHandler, field.type, checkedOnPrivate); } @@ -646,12 +646,12 @@ namespace printer { std::string name = structName + "." + field.name + "[i]"; strAssignVar(name, stubName); tabsDepth--; - ss << LINE_INDENT() << "}" << NL; + ss << LINE_INDENT() << "}" << printer::NL; } void Printer::writeStubsForStructureFields(const Tests &tests) { if (!tests.stubs.empty()) { - ss << tests.stubs << NL; + ss << tests.stubs << printer::NL; } } @@ -660,7 +660,7 @@ namespace printer { if (methodDescription.stubsText.empty()) { continue; } - ss << methodDescription.stubsText << NL; + ss << methodDescription.stubsText << printer::NL; } } @@ -679,7 +679,7 @@ namespace printer { } void Printer::writeCopyrightHeader() { - ss << Copyright::GENERATED_C_CPP_FILE_HEADER << NL; + ss << Copyright::GENERATED_C_CPP_FILE_HEADER << printer::NL; } Printer::Stream Printer::strDeclareSetOfVars(const std::set &vars) { diff --git a/server/src/printers/Printer.h b/server/src/printers/Printer.h index 0520a7a79..792a2efc7 100644 --- a/server/src/printers/Printer.h +++ b/server/src/printers/Printer.h @@ -14,13 +14,13 @@ #include #include -#define NL "\n" -#define SCNL ";" NL -#define BNL "{" NL -#define IND "i" -#define TAB " " - namespace printer { + const std::string NL = "\n"; + const std::string SCNL = ";" + NL; + const std::string BNL = "{" + NL; + const std::string IND = "i"; + const std::string TAB = " "; + using tests::Tests; class Printer { diff --git a/server/src/printers/SourceWrapperPrinter.cpp b/server/src/printers/SourceWrapperPrinter.cpp index 886ee5f60..51e6ae242 100644 --- a/server/src/printers/SourceWrapperPrinter.cpp +++ b/server/src/printers/SourceWrapperPrinter.cpp @@ -24,11 +24,11 @@ namespace printer { strInclude(Include(false, projectDirRelativeToWrapperFile / sourcePathRelativeToProjectDir)); - ss << "#pragma GCC visibility push (default)" << NL; + ss << "#pragma GCC visibility push (default)" << printer::NL; ss << wrapperDefinitions; - ss << "#pragma GCC visibility pop" << NL; + ss << "#pragma GCC visibility pop" << printer::NL; FileSystemUtils::writeToFile(wrapperFilePath, ss.str()); } diff --git a/server/src/printers/StubsPrinter.cpp b/server/src/printers/StubsPrinter.cpp index cf7b6c2b4..8b2ae5c0c 100644 --- a/server/src/printers/StubsPrinter.cpp +++ b/server/src/printers/StubsPrinter.cpp @@ -18,15 +18,15 @@ Stubs printer::StubsPrinter::genStubFile(const tests::Tests &tests, .time_since_epoch() .count(); strComment(std::to_string(creationTime)); - strComment("Please, do not change the line above") << NL; + strComment("Please, do not change the line above") << printer::NL; writeCopyrightHeader(); - ss << "#ifdef " << PrinterUtils::KLEE_MODE << NL; - ss << LINE_INDENT() << "extern void klee_make_symbolic(void *addr, unsigned long long nbytes, const char *name);" << NL; - ss << "#endif" << NL; + ss << "#ifdef " << PrinterUtils::KLEE_MODE << printer::NL; + ss << LINE_INDENT() << "extern void klee_make_symbolic(void *addr, unsigned long long nbytes, const char *name);" << printer::NL; + ss << "#endif" << printer::NL; strInclude(Paths::sourcePathToHeaderInclude(tests.sourceFilePath)); - ss << NL; - ss << "#pragma GCC visibility push (default)" << NL; - strDefine(PrinterUtils::C_NULL, "((void*)0)") << NL; + ss << printer::NL; + ss << "#pragma GCC visibility push (default)" << printer::NL; + strDefine(PrinterUtils::C_NULL, "((void*)0)") << printer::NL; for (const auto &[_, method] : tests.methods) { auto methodCopy = method; auto returnMangledName = PrinterUtils::getReturnMangledName(methodCopy.name); @@ -55,13 +55,13 @@ Stubs printer::StubsPrinter::genStubFile(const tests::Tests &tests, if (methodCopy.sourceBody) { strFunctionDecl(methodCopy, " "); - ss << methodCopy.sourceBody.value() << NL; + ss << methodCopy.sourceBody.value() << printer::NL; } else { strStubForMethod(methodCopy, typesHandler, "", "", "", false); }; - ss << NL; + ss << printer::NL; } - ss << "#pragma GCC visibility pop" << NL; + ss << "#pragma GCC visibility pop" << printer::NL; stubFile.code = ss.str(); return stubFile; } diff --git a/server/src/printers/TestsPrinter.cpp b/server/src/printers/TestsPrinter.cpp index a187af0e1..9f36f01e3 100644 --- a/server/src/printers/TestsPrinter.cpp +++ b/server/src/printers/TestsPrinter.cpp @@ -62,19 +62,19 @@ void TestsPrinter::joinToFinalCode(Tests &tests, const fs::path& generatedHeader resetStream(); writeCopyrightHeader(); genHeaders(tests, generatedHeaderPath); - ss << NL; + ss << printer::NL; strDeclareSetOfVars(tests.externVariables); ss << "namespace " << PrinterUtils::TEST_NAMESPACE << " {\n"; for (const auto &commentBlock : tests.commentBlocks) { - strComment(commentBlock) << NL; + strComment(commentBlock) << printer::NL; } writeStubsForStructureFields(tests); - ss << NL; + ss << printer::NL; writeStubsForParameters(tests); - ss << NL; + ss << printer::NL; tests.regressionMethodsNumber = printSuiteAndReturnMethodsCount(Tests::DEFAULT_SUITE_NAME, tests.methods); tests.errorMethodsNumber = printSuiteAndReturnMethodsCount(Tests::ERROR_SUITE_NAME, tests.methods); @@ -145,7 +145,7 @@ std::uint32_t TestsPrinter::printSuiteAndReturnMethodsCount(const std::string &s })) { return 0; } - ss << "#pragma region " << suiteName << NL; + ss << "#pragma region " << suiteName << printer::NL; std::uint32_t count = 0; for (const auto &[methodName, methodDescription] : methods) { if (methodDescription.codeText.at(suiteName).empty()) { @@ -154,7 +154,7 @@ std::uint32_t TestsPrinter::printSuiteAndReturnMethodsCount(const std::string &s count += methodDescription.suiteTestCases.at(suiteName).size(); ss << methodDescription.codeText.at(suiteName); } - ss << "#pragma endregion" << NL; + ss << "#pragma endregion" << printer::NL; return count; } @@ -248,10 +248,10 @@ void TestsPrinter::genVerboseTestCase(const Tests::MethodDescription &methodDesc } if (testCase.errorInfo.errorType == ErrorType::ASSERTION_FAILURE) { ss << LINE_INDENT() << "/*" - << LINE_INDENT() << testCase.errorInfo.failureBody << NL - << LINE_INDENT() << "FILE: " << testCase.errorInfo.fileWithFailure.string() << NL - << LINE_INDENT() << "LINE: " << testCase.errorInfo.lineWithFailure << NL - << LINE_INDENT() << "*/" << NL; + << LINE_INDENT() << testCase.errorInfo.failureBody << printer::NL + << LINE_INDENT() << "FILE: " << testCase.errorInfo.fileWithFailure.string() << printer::NL + << LINE_INDENT() << "LINE: " << testCase.errorInfo.lineWithFailure << printer::NL + << LINE_INDENT() << "*/" << printer::NL; } TestsPrinter::verboseFunctionCall(methodDescription, testCase, errorMode); @@ -260,10 +260,10 @@ void TestsPrinter::genVerboseTestCase(const Tests::MethodDescription &methodDesc if (testCase.isError()) { printFailAssertion(errorMode); } else { - ss << NL; + ss << printer::NL; TestsPrinter::verboseAsserts(methodDescription, testCase, predicateInfo); } - ss << RB() << NL; + ss << RB() << printer::NL; } void TestsPrinter::initializeFiles(const Tests::MethodDescription &methodDescription, @@ -287,7 +287,7 @@ void TestsPrinter::initializeFiles(const Tests::MethodDescription &methodDescrip testCase.getFileByName(fileName).data }); } if (numInitFiles != 0) { - ss << NL; + ss << printer::NL; } } @@ -317,7 +317,7 @@ void TestsPrinter::openFiles(const Tests::MethodDescription &methodDescription, fileName++; } if (fileName != 'A') { - ss << NL; + ss << printer::NL; } } @@ -331,7 +331,7 @@ void TestsPrinter::printLazyVariables(const Tests::MethodDescription &methodDesc for (const auto ¶mValue : testCase.paramValues) { printLazyVariables(paramValue.lazyParams, paramValue.lazyValues); } - ss << NL; + ss << printer::NL; } } @@ -354,7 +354,7 @@ void TestsPrinter::printLazyReferences(const Tests::MethodDescription &methodDes for (const auto &lazy : testCase.lazyReferences) { strAssignVar(lazy.varName, lazy.typeName); } - ss << NL; + ss << printer::NL; } } @@ -384,11 +384,11 @@ void TestsPrinter::genParametrizedTestCase(const Tests::MethodDescription &metho printLazyVariables(methodDescription, testCase, false); printLazyReferences(methodDescription, testCase, false); parametrizedAsserts(methodDescription, testCase, predicateInfo, errorMode); - ss << RB() << NL; + ss << RB() << printer::NL; } void TestsPrinter::genHeaders(Tests &tests, const fs::path& generatedHeaderPath) { - strInclude(generatedHeaderPath.filename()) << NL; + strInclude(generatedHeaderPath.filename()) << printer::NL; strInclude("gtest/gtest.h"); @@ -454,7 +454,7 @@ void TestsPrinter::verboseParameters(const Tests::MethodDescription &methodDescr verboseParameter(methodDescription, param, value, false); } } - ss << NL; + ss << printer::NL; } std::vector> types = {testCase.stubValuesTypes, testCase.stubParamTypes}; @@ -476,7 +476,7 @@ void TestsPrinter::verboseParameters(const Tests::MethodDescription &methodDescr verboseParameter(methodDescription, param, value, false); } } - ss << NL; + ss << printer::NL; } } @@ -485,7 +485,7 @@ void TestsPrinter::verboseParameters(const Tests::MethodDescription &methodDescr } printClassObject(methodDescription, testCase); printFunctionParameters(methodDescription, testCase, true); - ss << NL; + ss << printer::NL; } void TestsPrinter::printFunctionParameters(const Tests::MethodDescription &methodDescription, @@ -557,7 +557,7 @@ void TestsPrinter::verboseOutputVariable(const Tests::MethodDescription &methodD visitor::VerboseParameterVisitor(typesHandler, this, true, types::PointerUsage::RETURN) .visit(expectedType, PrinterUtils::EXPECTED, testCase.returnValue.view.get(), std::nullopt); } - ss << NL; + ss << printer::NL; } void TestsPrinter::verboseFunctionCall(const Tests::MethodDescription &methodDescription, @@ -599,19 +599,19 @@ void TestsPrinter::verboseAsserts(const Tests::MethodDescription &methodDescript } if (!methodDescription.globalParams.empty()) { - ss << NL; + ss << printer::NL; strComment("Check global variables"); globalParamsAsserts(methodDescription, testCase); } if (methodDescription.isClassMethod()) { - ss << NL; + ss << printer::NL; strComment("Check class fields mutation"); classAsserts(methodDescription, testCase); } if (!testCase.paramPostValues.empty()) { - ss << NL; + ss << printer::NL; strComment("Check function parameters"); changeableParamsAsserts(methodDescription, testCase); } @@ -726,7 +726,7 @@ void TestsPrinter::markTestedFunctionCallIfNeed(const std::string &name, // cannot generate stack for error return; } - ss << sarif::PREFIX_FOR_JSON_PATH << name << "," << testCase.testIndex << NL; + ss << sarif::PREFIX_FOR_JSON_PATH << name << "," << testCase.testIndex << printer::NL; } std::vector @@ -825,7 +825,7 @@ void printer::TestsPrinter::parametrizedInitializeSymbolicStubs(const Tests::Met void TestsPrinter::printFailAssertion(ErrorMode errorMode) { switch (errorMode) { case ErrorMode::FAILING: - ss << NL; + ss << printer::NL; ss << LINE_INDENT() << "FAIL() << \"Unreachable point or the function was supposed to fail, but \"\n" << LINE_INDENT() << LINE_INDENT() @@ -845,7 +845,7 @@ std::string printer::MultiLinePrinter::print(TestsPrinter *printer, auto subViews = view->getSubViews(); std::stringstream structuredValuesWithPrefixes; - structuredValuesWithPrefixes << (view->isAnonymous() ? "/* { */" : "{") << NL; + structuredValuesWithPrefixes << (view->isAnonymous() ? "/* { */" : "{") << printer::NL; ++printer->tabsDepth; const size_t fieldIndexToInitUnion = view->getFieldIndexToInitUnion(); @@ -856,7 +856,7 @@ std::string printer::MultiLinePrinter::print(TestsPrinter *printer, if (i != 0) { if (isStruct) structuredValuesWithPrefixes << ","; - structuredValuesWithPrefixes << NL; + structuredValuesWithPrefixes << printer::NL; } bool printInComment = !(isStruct || fieldIndexToInitUnion == i); @@ -874,7 +874,7 @@ std::string printer::MultiLinePrinter::print(TestsPrinter *printer, } --printer->tabsDepth; - structuredValuesWithPrefixes << NL + structuredValuesWithPrefixes << printer::NL << printer->LINE_INDENT() << (view->isAnonymous() ? "/* } */" : "}"); diff --git a/server/src/types/TypeVisitor.cpp b/server/src/types/TypeVisitor.cpp index 7d97ff843..933deba2a 100644 --- a/server/src/types/TypeVisitor.cpp +++ b/server/src/types/TypeVisitor.cpp @@ -28,7 +28,8 @@ bool TypeVisitor::TraverseType(clang::QualType type) { kinds.push_back(std::make_shared(size, false)); } else { uint64_t id = ::types::Type::getIdFromCanonicalType(curType); - bool unnamed = StringUtils::contains(curTypeString, "anonymous at"); + bool unnamed = StringUtils::contains(curTypeString, "anonymous at") || + StringUtils::contains(curTypeString, "unnamed at"); bool constQualified = canonicalType.getNonReferenceType().isConstQualified(); SimpleType::ReferenceType referenceType = SimpleType::ReferenceType::NotReference; if (canonicalType->isLValueReferenceType()) { diff --git a/server/src/utils/path/FileSystemPath.h b/server/src/utils/path/FileSystemPath.h index 2182eb828..81777cf22 100644 --- a/server/src/utils/path/FileSystemPath.h +++ b/server/src/utils/path/FileSystemPath.h @@ -4,6 +4,8 @@ #include #include +#include + namespace fs { using file_time_type = std::filesystem::file_time_type; @@ -21,6 +23,8 @@ namespace fs { path(const char *s) : path_(normalizedTrimmed(s)) {} + path(llvm::StringRef s) : path_(normalizedTrimmed(s.str())) {} + path root_path() const { return path(path_.root_path()); } diff --git a/server/src/visitors/ParametrizedAssertsVisitor.cpp b/server/src/visitors/ParametrizedAssertsVisitor.cpp index 2d939e439..cbec3d9df 100644 --- a/server/src/visitors/ParametrizedAssertsVisitor.cpp +++ b/server/src/visitors/ParametrizedAssertsVisitor.cpp @@ -92,7 +92,7 @@ namespace visitor { printer->strDeclareVar(type.typeName(), PrinterUtils::fillVarName(access, PrinterUtils::EXPECTED), value); } else { - printer->ss << value << NL; + printer->ss << value << printer::NL; } } @@ -113,7 +113,7 @@ namespace visitor { processExpect(type, gtestMacro, {view->getEntryValue(printer), getDecorateActualVarName(access)}); signature = changeSignatureToNullCheck(signature, type, view, access); - printer->strFunctionCall(signature.name, signature.args, SCNL, std::nullopt, true, + printer->strFunctionCall(signature.name, signature.args, printer::SCNL, std::nullopt, true, 0, std::nullopt, inUnion); } } else { @@ -125,7 +125,7 @@ namespace visitor { {getDecorateActualVarName(access), PrinterUtils::fillVarName(access, PrinterUtils::EXPECTED)}); signature = changeSignatureToNullCheck(signature, type, view, access); - printer->strFunctionCall(signature.name, signature.args, SCNL, std::nullopt, true, 0, + printer->strFunctionCall(signature.name, signature.args, printer::SCNL, std::nullopt, true, 0, std::nullopt, inUnion); } } diff --git a/server/src/visitors/VerboseAssertsReturnValueVisitor.cpp b/server/src/visitors/VerboseAssertsReturnValueVisitor.cpp index fe15a99a8..19a48c32e 100644 --- a/server/src/visitors/VerboseAssertsReturnValueVisitor.cpp +++ b/server/src/visitors/VerboseAssertsReturnValueVisitor.cpp @@ -32,7 +32,7 @@ namespace visitor { auto signature = processExpect(type, gtestMacro, {PrinterUtils::fillVarName(access, PrinterUtils::EXPECTED), getDecorateActualVarName(access)}); signature = changeSignatureToNullCheck(signature, type, view, access); - printer->strFunctionCall(signature.name, signature.args, SCNL, std::nullopt, true, 0, std::nullopt, inUnion); + printer->strFunctionCall(signature.name, signature.args, printer::SCNL, std::nullopt, true, 0, std::nullopt, inUnion); } void VerboseAssertsReturnValueVisitor::visitPointer(const types::Type &type, diff --git a/server/src/visitors/VerboseAssertsVisitor.cpp b/server/src/visitors/VerboseAssertsVisitor.cpp index da06d14ce..81c6c06c1 100644 --- a/server/src/visitors/VerboseAssertsVisitor.cpp +++ b/server/src/visitors/VerboseAssertsVisitor.cpp @@ -14,7 +14,7 @@ namespace visitor { const std::string &access, int depth) { size_t size = types::TypesHandler::getElementsNumberInPointerOneDim(usage); - printer->strForBound(IND, size) << printer->LB(); + printer->strForBound(printer::IND, size) << printer->LB(); AbstractValueViewVisitor::visitPointer(type, name, view, access, depth); printer->ss << printer->RB(); } diff --git a/server/src/visitors/VerboseParameterVisitor.cpp b/server/src/visitors/VerboseParameterVisitor.cpp index 7ed7f5f96..c42729e7c 100644 --- a/server/src/visitors/VerboseParameterVisitor.cpp +++ b/server/src/visitors/VerboseParameterVisitor.cpp @@ -92,7 +92,7 @@ namespace visitor { printer->strAssignVar(name, value); } } else { - printer->ss << value << NL; + printer->ss << value << printer::NL; } } diff --git a/server/test/framework/Server_Tests.cpp b/server/test/framework/Server_Tests.cpp index 789d94ca0..7f2652d29 100644 --- a/server/test/framework/Server_Tests.cpp +++ b/server/test/framework/Server_Tests.cpp @@ -908,9 +908,9 @@ namespace { TEST_F(Server_Test, Correct_CodeText_For_Regression) { auto [testGen, status] = performFeatureFileTestsRequest(floating_point_plain_c); const std::string code = testGen.tests.begin()->second.code; - const std::string beginRegressionRegion = "#pragma region " + Tests::DEFAULT_SUITE_NAME + NL; - const std::string endRegion = std::string("#pragma endregion") + NL; - const std::string beginErrorRegion = "#pragma region " + Tests::ERROR_SUITE_NAME + NL; + const std::string beginRegressionRegion = "#pragma region " + Tests::DEFAULT_SUITE_NAME + printer::NL; + const std::string endRegion = std::string("#pragma endregion") + printer::NL; + const std::string beginErrorRegion = "#pragma region " + Tests::ERROR_SUITE_NAME + printer::NL; ASSERT_TRUE(code.find(beginRegressionRegion) != std::string::npos) << "No regression begin region"; ASSERT_TRUE(code.find(endRegion) != std::string::npos) << "No regression end region"; } @@ -1560,7 +1560,7 @@ namespace { testUtils::checkStatuses(resultMap, tests); - StatusCountMap expectedStatusCountMap{{testsgen::TEST_PASSED, 3}}; + StatusCountMap expectedStatusCountMap{{testsgen::TEST_PASSED, 2}}; testUtils::checkStatusesCount(resultMap, tests, expectedStatusCountMap); } diff --git a/server/test/framework/Syntax_Tests.cpp b/server/test/framework/Syntax_Tests.cpp index 98023abbd..bb70bdd99 100644 --- a/server/test/framework/Syntax_Tests.cpp +++ b/server/test/framework/Syntax_Tests.cpp @@ -1576,9 +1576,9 @@ namespace { TEST_F(Syntax_Test, Correct_CodeText_For_Regression_And_Error) { auto [testGen, status] = createTestForFunction(structs_with_pointers_c, 78); const std::string code = testGen.tests.begin()->second.code; - const std::string beginRegressionRegion = "#pragma region " + Tests::DEFAULT_SUITE_NAME + NL; - const std::string endRegion = std::string("#pragma endregion") + NL; - const std::string beginErrorRegion = "#pragma region " + Tests::ERROR_SUITE_NAME + NL; + const std::string beginRegressionRegion = "#pragma region " + Tests::DEFAULT_SUITE_NAME + printer::NL; + const std::string endRegion = std::string("#pragma endregion") + printer::NL; + const std::string beginErrorRegion = "#pragma region " + Tests::ERROR_SUITE_NAME + printer::NL; ASSERT_TRUE(code.find(beginRegressionRegion) != std::string::npos) << "No regression begin region"; ASSERT_TRUE(code.find(endRegion) != std::string::npos) << "No regression end region"; ASSERT_TRUE(code.find(beginErrorRegion) != std::string::npos) << "No error begin region"; diff --git a/server/test/suites/server/keywords.c b/server/test/suites/server/keywords.c index 2f66c0fd1..9b8421957 100644 --- a/server/test/suites/server/keywords.c +++ b/server/test/suites/server/keywords.c @@ -1,6 +1,5 @@ -#include "keywords.h" - #include +#include "keywords.h" extern int get_size_of_data(struct data d) { return sizeof(d); diff --git a/submodules/build-klee.sh b/submodules/build-klee.sh index 84cc8acc9..04b328c39 100644 --- a/submodules/build-klee.sh +++ b/submodules/build-klee.sh @@ -15,7 +15,6 @@ $UTBOT_CMAKE_BINARY -G Ninja \ -DENABLE_POSIX_RUNTIME=TRUE \ -DENABLE_FLOATING_POINT=TRUE \ -DENABLE_FP_RUNTIME=TRUE \ - -DLLVM_CONFIG_BINARY=$UTBOT_INSTALL_DIR/bin/llvm-config \ -DLLVMCC=/utbot_distr/install/bin/clang \ -DLLVMCXX=/utbot_distr/install/bin/clang++ \ -DENABLE_UNIT_TESTS=TRUE \