From 24156e12f067b0183fdea799e09655a175e43ff7 Mon Sep 17 00:00:00 2001 From: Sergey Morozov <50552659+S1eGa@users.noreply.github.com> Date: Thu, 11 Jul 2024 20:59:29 +0300 Subject: [PATCH] Compile warnings fixes (#178) * [refactor] Multiple fixes for compilation warnings. * [refactor] Added function. * [fix] Error handling in Z3. * [fix] Placed back bitwise AND in klee_prefer_cex. * [refactor] Included unistd in runtime, suppressed target overrides and reduntant include paths for runtime. Turned ON -Werror. * [refactor] Fixed CW for MetaSMT. * [chore] LLVM headers are made SYSTEM in cmake. * [chore] Update after rebase * [chore] Rebase on pointers-fixes. * [chore] Removed pragmas disabling warnings from system headers, removed reduntant includes. * [chore] Fixes. * [fix] Should JIT be included in External Dispatcher? MSan fails otherwise. * chore] Turned on -Wunused. --------- Co-authored-by: Aleksandr Misonizhnik --- .github/workflows/build.yaml | 1 + CMakeLists.txt | 8 +- Dockerfile | 1 + build.sh | 4 +- cmake/compiler_warnings.cmake | 4 +- include/klee/ADT/Bits.h | 8 -- include/klee/ADT/DisjointSetUnion.h | 9 -- include/klee/ADT/FixedSizeStorageAdapter.h | 7 + include/klee/ADT/ImmutableTree.h | 6 +- include/klee/ADT/Incremental.h | 2 +- include/klee/ADT/StorageAdapter.h | 6 + include/klee/ADT/WeightedQueue.h | 5 +- include/klee/Expr/ArrayExprHash.h | 3 - include/klee/Expr/ArrayExprOptimizer.h | 2 - include/klee/Expr/ArrayExprRewriter.h | 1 - include/klee/Expr/ArrayExprVisitor.h | 4 - include/klee/Expr/Assignment.h | 1 - include/klee/Expr/Constraints.h | 1 - include/klee/Expr/Expr.h | 53 ++++---- include/klee/Expr/ExprSMTLIBPrinter.h | 2 - include/klee/Expr/ExprUtil.h | 1 - .../klee/Expr/IndependentConstraintSetUnion.h | 2 - include/klee/Expr/IndependentSet.h | 5 - include/klee/Expr/Path.h | 1 - include/klee/Expr/SymbolicSource.h | 11 +- include/klee/Expr/Symcrete.h | 6 - include/klee/Module/KCallable.h | 5 - include/klee/Module/KInstruction.h | 7 - include/klee/Module/KModule.h | 7 - include/klee/Module/KType.h | 1 - include/klee/Module/KValue.h | 4 +- include/klee/Module/LocationInfo.h | 1 - include/klee/Module/SarifReport.h | 15 ++- include/klee/Module/Target.h | 18 +-- include/klee/Module/TargetForest.h | 8 +- include/klee/Module/TargetHash.h | 1 - include/klee/Solver/SolverCmdLine.h | 7 - include/klee/Solver/SolverImpl.h | 4 +- include/klee/Solver/SolverUtil.h | 10 +- include/klee/Support/Casting.h | 6 - include/klee/Support/CompilerWarning.h | 8 ++ include/klee/Support/CompressionStream.h | 4 - include/klee/Support/Debug.h | 7 +- include/klee/Support/FileHandling.h | 5 +- include/klee/Support/ModuleUtil.h | 4 - include/klee/Support/OptionCategories.h | 4 - include/klee/Support/PrintContext.h | 5 - include/klee/Support/PrintVersion.h | 6 - include/klee/Support/RoundingModeUtil.h | 4 - include/klee/Support/Timer.h | 4 - include/klee/System/Time.h | 4 - include/klee/Utilities/APFloatEval.h | 5 - lib/ADT/CMakeLists.txt | 3 +- lib/ADT/SparseStorage.cpp | 4 - lib/Basic/KTest.cpp | 8 +- lib/Core/AddressSpace.cpp | 13 +- lib/Core/AddressSpace.h | 2 +- lib/Core/BidirectionalSearcher.cpp | 2 - lib/Core/CMakeLists.txt | 4 +- lib/Core/CXXTypeSystem/CXXTypeManager.cpp | 25 ++-- lib/Core/CXXTypeSystem/CXXTypeManager.h | 8 -- lib/Core/CallPathManager.cpp | 4 - lib/Core/CodeEvent.h | 4 - lib/Core/ConstructStorage.h | 3 + lib/Core/Context.cpp | 6 - lib/Core/DistanceCalculator.cpp | 27 ++-- lib/Core/DistanceCalculator.h | 5 +- lib/Core/ExecutionState.cpp | 7 - lib/Core/ExecutionState.h | 7 - lib/Core/Executor.cpp | 91 ++++--------- lib/Core/Executor.h | 22 +-- lib/Core/ExecutorUtil.cpp | 13 +- lib/Core/ExternalDispatcher.cpp | 18 ++- lib/Core/ExternalDispatcher.h | 6 +- lib/Core/GetElementPtrTypeIterator.h | 13 +- lib/Core/ImpliedValue.cpp | 3 - lib/Core/Memory.cpp | 18 +-- lib/Core/Memory.h | 9 -- lib/Core/MemoryManager.cpp | 14 -- lib/Core/MemoryManager.h | 1 - lib/Core/MockBuilder.cpp | 3 +- lib/Core/ObjectManager.cpp | 12 +- lib/Core/ObjectManager.h | 2 +- lib/Core/PForest.cpp | 8 +- lib/Core/PForest.h | 3 +- lib/Core/PTree.cpp | 2 +- lib/Core/PTree.h | 7 +- lib/Core/Searcher.cpp | 17 +-- lib/Core/Searcher.h | 7 - lib/Core/SearcherUtil.h | 2 - lib/Core/SpecialFunctionHandler.cpp | 127 +++++++----------- lib/Core/StatsTracker.cpp | 12 -- lib/Core/StatsTracker.h | 4 - lib/Core/TargetCalculator.cpp | 8 +- lib/Core/TargetCalculator.h | 16 +-- lib/Core/TargetManager.cpp | 2 +- lib/Core/TargetManager.h | 1 - lib/Core/TargetedExecutionManager.h | 1 - lib/Core/TimingSolver.cpp | 1 - lib/Core/TypeManager.cpp | 7 +- lib/Core/UserSearcher.cpp | 6 - lib/Core/UserSearcher.h | 6 - lib/Expr/APFloatEval.cpp | 6 - lib/Expr/ArrayExprOptimizer.cpp | 5 - lib/Expr/ArrayExprRewriter.cpp | 10 +- lib/Expr/ArrayExprVisitor.cpp | 4 - lib/Expr/Assignment.cpp | 1 - lib/Expr/AssignmentGenerator.cpp | 8 -- lib/Expr/CMakeLists.txt | 3 +- lib/Expr/Constraints.cpp | 15 +-- lib/Expr/Expr.cpp | 37 ++--- lib/Expr/ExprPPrinter.cpp | 8 +- lib/Expr/ExprSMTLIBPrinter.cpp | 4 - lib/Expr/ExprVisitor.cpp | 4 - lib/Expr/IndependentConstraintSetUnion.cpp | 2 +- lib/Expr/IndependentSet.cpp | 2 - lib/Expr/Lexer.cpp | 5 - lib/Expr/Parser.cpp | 22 ++- lib/Expr/Path.cpp | 8 +- lib/Expr/SourceBuilder.cpp | 8 +- lib/Expr/SymbolicSource.cpp | 3 - lib/Module/Annotation.cpp | 9 +- lib/Module/CMakeLists.txt | 4 +- lib/Module/CallRemover.cpp | 1 - lib/Module/CallSplitter.cpp | 5 - lib/Module/Checks.cpp | 8 -- lib/Module/CodeGraphInfo.cpp | 4 - lib/Module/FunctionAlias.cpp | 4 - .../InstructionOperandTypeCheckPass.cpp | 5 - lib/Module/IntrinsicCleaner.cpp | 9 +- lib/Module/KInstruction.cpp | 5 - lib/Module/KLEEIRMetaData.h | 6 +- lib/Module/KModule.cpp | 13 +- lib/Module/KType.cpp | 11 +- lib/Module/KValue.cpp | 7 - lib/Module/LocalVarDeclarationFinderPass.cpp | 5 - lib/Module/LocationInfo.cpp | 9 +- lib/Module/LowerSwitch.cpp | 5 - lib/Module/ModuleUtil.cpp | 102 -------------- lib/Module/OptNone.cpp | 6 - lib/Module/Optimize.cpp | 6 - lib/Module/Passes.h | 9 +- lib/Module/RaiseAsm.cpp | 8 +- lib/Module/ReturnLocationFinderPass.cpp | 7 - lib/Module/ReturnSplitter.cpp | 5 - lib/Module/SarifReport.cpp | 6 +- lib/Module/Target.cpp | 4 +- lib/Module/TargetForest.cpp | 6 +- lib/Solver/AlphaEquivalenceSolver.cpp | 8 -- lib/Solver/BitwuzlaBuilder.cpp | 10 +- lib/Solver/BitwuzlaBuilder.h | 5 - lib/Solver/BitwuzlaHashConfig.h | 6 - lib/Solver/BitwuzlaSolver.cpp | 24 ++-- lib/Solver/CMakeLists.txt | 4 +- lib/Solver/CexCachingSolver.cpp | 4 - lib/Solver/ConcretizingSolver.cpp | 13 +- lib/Solver/ConstructSolverChain.cpp | 6 - lib/Solver/CoreSolver.cpp | 18 ++- lib/Solver/DummySolver.cpp | 19 ++- lib/Solver/FastCexSolver.cpp | 20 +-- lib/Solver/IndependentSolver.cpp | 23 +--- lib/Solver/MetaSMTBuilder.h | 32 ++--- lib/Solver/MetaSMTSolver.cpp | 10 +- lib/Solver/QueryLoggingSolver.h | 4 - lib/Solver/STPBuilder.cpp | 8 -- lib/Solver/STPSolver.cpp | 10 +- lib/Solver/Solver.cpp | 1 + lib/Solver/SolverCmdLine.cpp | 8 +- lib/Solver/SolverUtil.cpp | 11 +- lib/Solver/Z3BitvectorBuilder.cpp | 11 +- lib/Solver/Z3BitvectorBuilder.h | 13 +- lib/Solver/Z3Builder.cpp | 7 +- lib/Solver/Z3CoreBuilder.cpp | 6 - lib/Solver/Z3HashConfig.h | 4 - lib/Solver/Z3Solver.cpp | 87 +++++++----- lib/Support/CMakeLists.txt | 4 +- lib/Support/CompressionStream.cpp | 5 - lib/Support/ErrorHandling.cpp | 13 +- lib/Support/FileHandling.cpp | 6 - lib/Support/PrintVersion.cpp | 5 - lib/Support/RoundingModeUtil.cpp | 4 - lib/Support/TreeStream.cpp | 13 +- runtime/CMakeLists.txt | 2 + runtime/POSIX/fd_init.c | 9 +- runtime/POSIX/input_output.c | 3 +- runtime/POSIX/klee_init_env.c | 4 +- runtime/POSIX/stubs.c | 7 + runtime/Runtest/intrinsics.c | 8 +- runtime/klee-fp/fpclassify.c | 8 +- scripts/build/p-klee.inc | 7 +- scripts/build/v-klee.inc | 2 + test/CMakeLists.txt | 4 +- tools/kleaver/CMakeLists.txt | 3 +- tools/kleaver/main.cpp | 6 - tools/klee-replay/file-creator.c | 11 +- tools/klee-replay/klee-replay.c | 27 ++-- tools/klee-replay/klee_init_env.c | 6 +- tools/klee/CMakeLists.txt | 3 +- tools/klee/main.cpp | 24 ++-- unittests/Assignment/AssignmentTest.cpp | 1 - unittests/CMakeLists.txt | 6 +- unittests/DiscretePDF/DiscretePDFTest.cpp | 2 - unittests/Expr/ArrayExprTest.cpp | 6 - unittests/Expr/ExprTest.cpp | 1 - unittests/Ref/CMakeLists.txt | 2 +- unittests/Ref/RefTest.cpp | 1 - unittests/Searcher/SearcherTest.cpp | 16 +-- unittests/Solver/SolverTest.cpp | 8 -- unittests/Solver/Z3SolverTest.cpp | 3 - unittests/TestMain.cpp | 4 - 210 files changed, 577 insertions(+), 1355 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 2a5aa24aee..adf65c7c58 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -17,6 +17,7 @@ env: ENABLE_DOXYGEN: 0 ENABLE_OPTIMIZED: 1 ENABLE_DEBUG: 1 + ENABLE_WARNINGS_AS_ERRORS: 1 GTEST_VERSION: 1.11.0 KLEE_RUNTIME_BUILD: "Debug+Asserts" LLVM_VERSION: 11 diff --git a/CMakeLists.txt b/CMakeLists.txt index 1579516990..086d250f4e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -678,10 +678,10 @@ configure_file(${CMAKE_SOURCE_DIR}/include/klee/Config/CompileTimeInfo.h.cmin ################################################################################ # Set KLEE-specific include files ################################################################################ -include_directories("${CMAKE_BINARY_DIR}/include") -include_directories("${CMAKE_SOURCE_DIR}/include") -include_directories("${JSON_SRC_DIR}/include") -include_directories("${IMMER_SRC_DIR}") +include_directories(SYSTEM "${CMAKE_BINARY_DIR}/include") +include_directories(SYSTEM "${CMAKE_SOURCE_DIR}/include") +include_directories(SYSTEM "${JSON_SRC_DIR}/include") +include_directories(SYSTEM "${IMMER_SRC_DIR}") # set(KLEE_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/include ${CMAKE_BINARY_DIR}/include) ################################################################################ diff --git a/Dockerfile b/Dockerfile index e4d87f0fe9..1376b91664 100644 --- a/Dockerfile +++ b/Dockerfile @@ -23,6 +23,7 @@ ENV ENABLE_DOXYGEN=1 ENV ENABLE_OPTIMIZED=1 ENV ENABLE_DEBUG=1 ENV DISABLE_ASSERTIONS=0 +ENV ENABLE_WARNINGS_AS_ERRORS=0 ENV REQUIRES_RTTI=0 ENV SOLVERS=STP:Z3 ENV GTEST_VERSION=1.11.0 diff --git a/build.sh b/build.sh index fa26148326..01bb2c376e 100755 --- a/build.sh +++ b/build.sh @@ -70,4 +70,6 @@ else fi done -BASE="$BASE" BUILD_SUFFIX="$BUILD_SUFFIX" KLEE_RUNTIME_BUILD=$KLEE_RUNTIME_BUILD COVERAGE=$COVERAGE ENABLE_DOXYGEN=$ENABLE_DOXYGEN USE_TCMALLOC=$USE_TCMALLOC USE_LIBCXX=$USE_LIBCXX LLVM_VERSION=$LLVM_VERSION ENABLE_OPTIMIZED=$ENABLE_OPTIMIZED ENABLE_DEBUG=$ENABLE_DEBUG DISABLE_ASSERTIONS=$DISABLE_ASSERTIONS REQUIRES_RTTI=$REQUIRES_RTTI SOLVERS=$SOLVERS GTEST_VERSION=$GTEST_VERSION UCLIBC_VERSION=$UCLIBC_VERSION STP_VERSION=$STP_VERSION MINISAT_VERSION=$MINISAT_VERSION Z3_VERSION=$Z3_VERSION BITWUZLA_VERSION=$BITWUZLA_VERSION SQLITE_VERSION=$SQLITE_VERSION JSON_VERSION=$JSON_VERSION IMMER_VERSION=$IMMER_VERSION SANITIZER_BUILD=$SANITIZER_BUILD SANITIZER_LLVM_VERSION=$SANITIZER_LLVM_VERSION ./scripts/build/build.sh klee --install-system-deps +ENABLE_WARNINGS_AS_ERRORS=0 + +BASE="$BASE" BUILD_SUFFIX="$BUILD_SUFFIX" KLEE_RUNTIME_BUILD=$KLEE_RUNTIME_BUILD COVERAGE=$COVERAGE ENABLE_DOXYGEN=$ENABLE_DOXYGEN USE_TCMALLOC=$USE_TCMALLOC USE_LIBCXX=$USE_LIBCXX LLVM_VERSION=$LLVM_VERSION ENABLE_OPTIMIZED=$ENABLE_OPTIMIZED ENABLE_DEBUG=$ENABLE_DEBUG DISABLE_ASSERTIONS=$DISABLE_ASSERTIONS REQUIRES_RTTI=$REQUIRES_RTTI SOLVERS=$SOLVERS GTEST_VERSION=$GTEST_VERSION UCLIBC_VERSION=$UCLIBC_VERSION STP_VERSION=$STP_VERSION MINISAT_VERSION=$MINISAT_VERSION Z3_VERSION=$Z3_VERSION BITWUZLA_VERSION=$BITWUZLA_VERSION SQLITE_VERSION=$SQLITE_VERSION JSON_VERSION=$JSON_VERSION IMMER_VERSION=$IMMER_VERSION SANITIZER_BUILD=$SANITIZER_BUILD SANITIZER_LLVM_VERSION=$SANITIZER_LLVM_VERSION ENABLE_WARNINGS_AS_ERRORS=$ENABLE_WARNINGS_AS_ERRORS ./scripts/build/build.sh klee --install-system-deps diff --git a/cmake/compiler_warnings.cmake b/cmake/compiler_warnings.cmake index b250483a1d..87bd5cd3a4 100644 --- a/cmake/compiler_warnings.cmake +++ b/cmake/compiler_warnings.cmake @@ -10,17 +10,15 @@ ############################################################################### # Compiler warnings ############################################################################### -# FIXME: -Wunused-parameter fires a lot so for now suppress it. add_compile_options( "-Wall" "-Wextra" - "-Wno-unused-parameter" ) ############################################################################### # Warnings as errors ############################################################################### -option(WARNINGS_AS_ERRORS "Treat compiler warnings as errors" OFF) +option(WARNINGS_AS_ERRORS "Treat compiler warnings as errors" ON) if (WARNINGS_AS_ERRORS) add_compile_options("-Werror") message(STATUS "Treating compiler warnings as errors") diff --git a/include/klee/ADT/Bits.h b/include/klee/ADT/Bits.h index 20518fee10..c01b30b77b 100644 --- a/include/klee/ADT/Bits.h +++ b/include/klee/ADT/Bits.h @@ -10,14 +10,6 @@ #ifndef KLEE_BITS_H #define KLEE_BITS_H -#include "klee/Config/Version.h" - -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS -#include "llvm/Support/DataTypes.h" -DISABLE_WARNING_POP - #include #include #include diff --git a/include/klee/ADT/DisjointSetUnion.h b/include/klee/ADT/DisjointSetUnion.h index eb7a363576..deeef35fe7 100644 --- a/include/klee/ADT/DisjointSetUnion.h +++ b/include/klee/ADT/DisjointSetUnion.h @@ -2,19 +2,10 @@ #define KLEE_DISJOINEDSETUNION_H #include "klee/ADT/Either.h" -#include "klee/ADT/PersistentMap.h" -#include "klee/ADT/PersistentSet.h" #include "klee/ADT/Ref.h" #include "klee/Expr/Expr.h" #include "klee/Expr/Symcrete.h" -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS -#include "llvm/Support/raw_ostream.h" -DISABLE_WARNING_POP - -#include #include #include #include diff --git a/include/klee/ADT/FixedSizeStorageAdapter.h b/include/klee/ADT/FixedSizeStorageAdapter.h index 82b512fda6..a4a6611d3a 100644 --- a/include/klee/ADT/FixedSizeStorageAdapter.h +++ b/include/klee/ADT/FixedSizeStorageAdapter.h @@ -1,6 +1,8 @@ #ifndef KLEE_FIXEDSIZESTORAGEADAPTER_H #define KLEE_FIXEDSIZESTORAGEADAPTER_H +#include "klee/Support/CompilerWarning.h" + #ifndef IMMER_NO_EXCEPTIONS #define IMMER_NO_EXCEPTIONS #endif /* IMMER_NO_EXCEPTIONS */ @@ -109,6 +111,7 @@ template struct FixedSizeStorageAdapter { } default: assert(0 && "unhandled iterator kind"); + unreachable(); } } ~iterator() { @@ -127,6 +130,7 @@ template struct FixedSizeStorageAdapter { } default: assert(0 && "unhandled iterator kind"); + unreachable(); } } @@ -147,6 +151,7 @@ template struct FixedSizeStorageAdapter { } default: assert(0 && "unhandled iterator kind"); + unreachable(); } return *this; } @@ -163,6 +168,7 @@ template struct FixedSizeStorageAdapter { } default: assert(0 && "unhandled iterator kind"); + unreachable(); } } bool operator!=(const iterator &other) const { @@ -178,6 +184,7 @@ template struct FixedSizeStorageAdapter { } default: assert(0 && "unhandled iterator kind"); + unreachable(); } } }; diff --git a/include/klee/ADT/ImmutableTree.h b/include/klee/ADT/ImmutableTree.h index c02491fed6..5c3df42ddd 100644 --- a/include/klee/ADT/ImmutableTree.h +++ b/include/klee/ADT/ImmutableTree.h @@ -10,9 +10,9 @@ #ifndef KLEE_IMMUTABLETREE_H #define KLEE_IMMUTABLETREE_H +#include #include #include -#include namespace klee { template class ImmutableTree { @@ -259,8 +259,10 @@ ImmutableTree::Node::~Node() { template inline void ImmutableTree::Node::decref() { --references; - if (references == 0) + + if (references == 0 && !isTerminator()) { delete this; + } } template diff --git a/include/klee/ADT/Incremental.h b/include/klee/ADT/Incremental.h index d5a77defa8..85fc991575 100644 --- a/include/klee/ADT/Incremental.h +++ b/include/klee/ADT/Incremental.h @@ -272,7 +272,7 @@ class inc_uset { frame_index += framesSize(); return frame_it(ids, frame_index); } - frame_it end(int frame_index) const { return frame_it(ids); } + frame_it end(int) const { return frame_it(ids); } void insert(const _Value &v) { ids[v].insert(current_frame); } diff --git a/include/klee/ADT/StorageAdapter.h b/include/klee/ADT/StorageAdapter.h index a1315af682..2b38c875b7 100644 --- a/include/klee/ADT/StorageAdapter.h +++ b/include/klee/ADT/StorageAdapter.h @@ -2,6 +2,7 @@ #define KLEE_STORAGEADAPTER_H #include "klee/ADT/PersistentHashMap.h" +#include "klee/Support/CompilerWarning.h" #ifndef IMMER_NO_EXCEPTIONS #define IMMER_NO_EXCEPTIONS @@ -139,6 +140,7 @@ struct StorageAdapter { } default: assert(0 && "unhandled iterator kind"); + unreachable(); } } ~iterator() { @@ -157,6 +159,7 @@ struct StorageAdapter { } default: assert(0 && "unhandled iterator kind"); + unreachable(); } } @@ -177,6 +180,7 @@ struct StorageAdapter { } default: assert(0 && "unhandled iterator kind"); + unreachable(); } return *this; } @@ -193,6 +197,7 @@ struct StorageAdapter { } default: assert(0 && "unhandled iterator kind"); + unreachable(); } } bool operator!=(const iterator &other) const { @@ -208,6 +213,7 @@ struct StorageAdapter { } default: assert(0 && "unhandled iterator kind"); + unreachable(); } } }; diff --git a/include/klee/ADT/WeightedQueue.h b/include/klee/ADT/WeightedQueue.h index ca94537abd..0914db75d0 100644 --- a/include/klee/ADT/WeightedQueue.h +++ b/include/klee/ADT/WeightedQueue.h @@ -10,11 +10,12 @@ #ifndef KLEE_WEIGHTEDQUEUE_H #define KLEE_WEIGHTEDQUEUE_H -#include #include #include #include +#include "klee/Support/CompilerWarning.h" + namespace klee { template > class WeightedQueue { @@ -109,7 +110,7 @@ T WeightedQueue::choose( return result; } } - assert(0 && "unreachable"); + unreachable(); } template diff --git a/include/klee/Expr/ArrayExprHash.h b/include/klee/Expr/ArrayExprHash.h index 5ec1a54130..aa3763dc57 100644 --- a/include/klee/Expr/ArrayExprHash.h +++ b/include/klee/Expr/ArrayExprHash.h @@ -12,10 +12,7 @@ #define KLEE_ARRAYEXPRHASH_H #include "klee/Expr/Expr.h" -#include "klee/Solver/SolverStats.h" -#include "klee/Statistics/TimerStatIncrementer.h" -#include #include namespace klee { diff --git a/include/klee/Expr/ArrayExprOptimizer.h b/include/klee/Expr/ArrayExprOptimizer.h index 015ed1a24a..e088c61312 100644 --- a/include/klee/Expr/ArrayExprOptimizer.h +++ b/include/klee/Expr/ArrayExprOptimizer.h @@ -12,8 +12,6 @@ #include #include -#include -#include #include #include diff --git a/include/klee/Expr/ArrayExprRewriter.h b/include/klee/Expr/ArrayExprRewriter.h index 116279062a..e838c6856e 100644 --- a/include/klee/Expr/ArrayExprRewriter.h +++ b/include/klee/Expr/ArrayExprRewriter.h @@ -10,7 +10,6 @@ #ifndef KLEE_ARRAYEXPRREWRITER_H #define KLEE_ARRAYEXPRREWRITER_H -#include #include #include diff --git a/include/klee/Expr/ArrayExprVisitor.h b/include/klee/Expr/ArrayExprVisitor.h index 124aa66387..aaa582db73 100644 --- a/include/klee/Expr/ArrayExprVisitor.h +++ b/include/klee/Expr/ArrayExprVisitor.h @@ -10,14 +10,10 @@ #ifndef KLEE_ARRAYEXPRVISITOR_H #define KLEE_ARRAYEXPRVISITOR_H -#include "klee/Expr/ExprBuilder.h" #include "klee/Expr/ExprHashMap.h" #include "klee/Expr/ExprVisitor.h" -#include "klee/Solver/SolverCmdLine.h" #include -#include -#include namespace klee { diff --git a/include/klee/Expr/Assignment.h b/include/klee/Expr/Assignment.h index 583a7d4056..529aa23cc7 100644 --- a/include/klee/Expr/Assignment.h +++ b/include/klee/Expr/Assignment.h @@ -14,7 +14,6 @@ #include "klee/ADT/SparseStorage.h" #include "klee/Expr/ExprEvaluator.h" -#include #include namespace klee { diff --git a/include/klee/Expr/Constraints.h b/include/klee/Expr/Constraints.h index a09d06a205..119dcbf105 100644 --- a/include/klee/Expr/Constraints.h +++ b/include/klee/Expr/Constraints.h @@ -21,7 +21,6 @@ #include "klee/Expr/Path.h" #include "klee/Expr/Symcrete.h" -#include #include namespace klee { diff --git a/include/klee/Expr/Expr.h b/include/klee/Expr/Expr.h index 080c0f90a4..55bf4755ec 100644 --- a/include/klee/Expr/Expr.h +++ b/include/klee/Expr/Expr.h @@ -10,24 +10,19 @@ #ifndef KLEE_EXPR_H #define KLEE_EXPR_H -#include "klee/ADT/Bits.h" #include "klee/ADT/Ref.h" #include "klee/Expr/SymbolicSource.h" -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS +#ifndef NDEBUG +#include "klee/ADT/Bits.h" +#endif + #include "llvm/ADT/APFloat.h" #include "llvm/ADT/APInt.h" -#include "llvm/ADT/APSInt.h" #include "llvm/ADT/DenseSet.h" -#include "llvm/ADT/Hashing.h" -#include "llvm/ADT/SmallVector.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/raw_ostream.h" -DISABLE_WARNING_POP -#include #include #include #include @@ -424,7 +419,7 @@ class Expr { struct CreateArg; static ref createFromKind(Kind k, std::vector args); - static bool isValidKidWidth(unsigned kid, Width w) { return true; } + static bool isValidKidWidth(unsigned, Width) { return true; } static bool needsResultType() { return false; } static bool classof(const Expr *) { return true; } @@ -580,7 +575,7 @@ class NotOptimizedExpr : public NonConstantExpr { Kind getKind() const { return NotOptimized; } unsigned getNumKids() const { return 1; } - ref getKid(unsigned i) const { return src; } + ref getKid(unsigned) const { return src; } virtual ref rebuild(ref kids[]) const { return create(kids[0]); } @@ -588,7 +583,7 @@ class NotOptimizedExpr : public NonConstantExpr { NotOptimizedExpr(const ref &_src) : src(_src) {} protected: - virtual int compareContents(const Expr &b) const { + virtual int compareContents(const Expr &) const { // No attributes to compare. return 0; } @@ -851,7 +846,7 @@ class SelectExpr : public NonConstantExpr { static bool classof(const SelectExpr *) { return true; } protected: - virtual int compareContents(const Expr &b) const { + virtual int compareContents(const Expr &) const { // No attributes to compare. return 0; } @@ -955,7 +950,7 @@ class ExtractExpr : public NonConstantExpr { Kind getKind() const { return Extract; } unsigned getNumKids() const { return numKids; } - ref getKid(unsigned i) const { return expr; } + ref getKid(unsigned) const { return expr; } int compareContents(const Expr &b) const { const ExtractExpr &eb = static_cast(b); @@ -1005,7 +1000,7 @@ class NotExpr : public NonConstantExpr { Kind getKind() const { return Not; } unsigned getNumKids() const { return numKids; } - ref getKid(unsigned i) const { return expr; } + ref getKid(unsigned) const { return expr; } virtual ref rebuild(ref kids[]) const { return create(kids[0]); } @@ -1019,7 +1014,7 @@ class NotExpr : public NonConstantExpr { NotExpr(const ref &e) : expr(e) {} protected: - virtual int compareContents(const Expr &b) const { + virtual int compareContents(const Expr &) const { // No attributes to compare. return 0; } @@ -1172,7 +1167,7 @@ FP_CAST_EXPR_CLASS(SIToFP) } \ \ protected: \ - virtual int compareContents(const Expr &b) const { \ + virtual int compareContents(const Expr &) const { \ /* No attributes to compare.*/ \ return 0; \ } \ @@ -1276,7 +1271,7 @@ FLOAT_ARITHMETIC_EXPR_CLASS(FMin) static bool classof(const _class_kind##Expr *) { return true; } \ \ protected: \ - virtual int compareContents(const Expr &b) const { \ + virtual int compareContents(const Expr &) const { \ /* No attributes to compare. */ \ return 0; \ } \ @@ -1317,9 +1312,9 @@ COMPARISON_EXPR_CLASS(FOGe) Kind getKind() const { return Expr::_class_kind; } \ \ unsigned getNumKids() const { return numKids; } \ - ref getKid(unsigned i) const { return expr; } \ + ref getKid(unsigned) const { return expr; } \ \ - int compareContents(const Expr &b) const { \ + int compareContents(const Expr &) const { \ /* No attributes to compare. */ \ return 0; \ } \ @@ -1364,7 +1359,7 @@ FP_PRED_EXPR_CLASS(IsSubnormal) Kind getKind() const { return Expr::_class_kind; } \ \ unsigned getNumKids() const { return numKids; } \ - ref getKid(unsigned i) const { return expr; } \ + ref getKid(unsigned) const { return expr; } \ \ int compareContents(const Expr &b) const { \ const _class_kind##Expr &eb = static_cast(b); \ @@ -1410,9 +1405,9 @@ class FAbsExpr : public NonConstantExpr { Kind getKind() const { return Expr::FAbs; } unsigned getNumKids() const { return numKids; } - ref getKid(unsigned i) const { return expr; } + ref getKid(unsigned) const { return expr; } - int compareContents(const Expr &b) const { + int compareContents(const Expr &) const { // No attributes return 0; } @@ -1443,9 +1438,9 @@ class FNegExpr : public NonConstantExpr { Kind getKind() const { return Expr::FNeg; } unsigned getNumKids() const { return numKids; } - ref getKid(unsigned i) const { return expr; } + ref getKid(unsigned) const { return expr; } - int compareContents(const Expr &b) const { + int compareContents(const Expr &) const { // No attributes return 0; } @@ -1484,7 +1479,7 @@ class ConstantExpr : public Expr { Kind getKind() const { return Constant; } unsigned getNumKids() const { return 0; } - ref getKid(unsigned i) const { return 0; } + ref getKid(unsigned) const { return 0; } /// getAPValue - Return the arbitrary precision value directly. /// @@ -1507,7 +1502,7 @@ class ConstantExpr : public Expr { /// useful bits. /// /// Example: unit8_t byte= (unit8_t) constant->getZExtValue(8); - uint64_t getZExtValue(unsigned bits = 64) const { + uint64_t getZExtValue([[maybe_unused]] unsigned bits = 64) const { assert(getWidth() <= bits && "Value may be out of range!"); return value.getZExtValue(); } @@ -1532,7 +1527,7 @@ class ConstantExpr : public Expr { return value.ult(cb.value) ? -1 : 1; } - virtual ref rebuild(ref kids[]) const { + virtual ref rebuild(ref[]) const { assert(0 && "rebuild() on ConstantExpr"); return const_cast(this); } @@ -1710,7 +1705,7 @@ class PointerExpr : public NonConstantExpr { return 0; } - int compareContents(const Expr &b) const { return 0; } + int compareContents(const Expr &) const { return 0; } virtual ref rebuild(ref kids[]) const { return create(kids[0], kids[1]); } diff --git a/include/klee/Expr/ExprSMTLIBPrinter.h b/include/klee/Expr/ExprSMTLIBPrinter.h index 10e46048cd..3eb875b9f5 100644 --- a/include/klee/Expr/ExprSMTLIBPrinter.h +++ b/include/klee/Expr/ExprSMTLIBPrinter.h @@ -11,14 +11,12 @@ #ifndef KLEE_EXPRSMTLIBPRINTER_H #define KLEE_EXPRSMTLIBPRINTER_H -#include "klee/Expr/Constraints.h" #include "klee/Expr/Expr.h" #include "klee/Solver/Solver.h" #include "klee/Support/PrintContext.h" #include #include -#include namespace llvm { class raw_ostream; diff --git a/include/klee/Expr/ExprUtil.h b/include/klee/Expr/ExprUtil.h index a1f4a0c2d7..b28b1c51c4 100644 --- a/include/klee/Expr/ExprUtil.h +++ b/include/klee/Expr/ExprUtil.h @@ -15,7 +15,6 @@ #include "klee/Expr/ExprVisitor.h" #include -#include #include namespace klee { diff --git a/include/klee/Expr/IndependentConstraintSetUnion.h b/include/klee/Expr/IndependentConstraintSetUnion.h index 6a80782442..ebf694cf2e 100644 --- a/include/klee/Expr/IndependentConstraintSetUnion.h +++ b/include/klee/Expr/IndependentConstraintSetUnion.h @@ -1,8 +1,6 @@ #ifndef KLEE_INDEPENDENTCONSTRAINTSETUNION_H #define KLEE_INDEPENDENTCONSTRAINTSETUNION_H -#include "klee/ADT/Either.h" - #include "klee/Expr/Assignment.h" #include "klee/Expr/IndependentSet.h" diff --git a/include/klee/Expr/IndependentSet.h b/include/klee/Expr/IndependentSet.h index 21d64cdadc..77709fc764 100644 --- a/include/klee/Expr/IndependentSet.h +++ b/include/klee/Expr/IndependentSet.h @@ -10,13 +10,8 @@ #include "klee/Expr/ExprHashMap.h" #include "klee/Expr/Symcrete.h" -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS #include "llvm/Support/raw_ostream.h" -DISABLE_WARNING_POP -#include #include #include #include diff --git a/include/klee/Expr/Path.h b/include/klee/Expr/Path.h index 456d4be906..b2bd0dbb3e 100644 --- a/include/klee/Expr/Path.h +++ b/include/klee/Expr/Path.h @@ -3,7 +3,6 @@ #include "klee/ADT/ImmutableList.h" -#include #include #include diff --git a/include/klee/Expr/SymbolicSource.h b/include/klee/Expr/SymbolicSource.h index 99fe508b5f..d5add16b17 100644 --- a/include/klee/Expr/SymbolicSource.h +++ b/include/klee/Expr/SymbolicSource.h @@ -4,17 +4,12 @@ #include "klee/ADT/Ref.h" #include "klee/ADT/SparseStorage.h" -#include "klee/Support/CompilerWarning.h" -#include -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS #include "llvm/ADT/StringExtras.h" #include "llvm/IR/Argument.h" -#include "llvm/IR/GlobalVariable.h" #include "llvm/IR/Instruction.h" -DISABLE_WARNING_POP +#include #include #include #include @@ -290,7 +285,7 @@ class ArgumentSource : public ValueSource { return S->getKind() == Kind::Argument; } - static bool classof(const ArgumentSource *S) { return true; } + static bool classof(const ArgumentSource *) { return true; } const llvm::Value &value() const override { return allocSite; } @@ -313,7 +308,7 @@ class InstructionSource : public ValueSource { return S->getKind() == Kind::Instruction; } - static bool classof(const InstructionSource *S) { return true; } + static bool classof(const InstructionSource *) { return true; } const llvm::Value &value() const override { return allocSite; } diff --git a/include/klee/Expr/Symcrete.h b/include/klee/Expr/Symcrete.h index 91fc044622..eef5f1e790 100644 --- a/include/klee/Expr/Symcrete.h +++ b/include/klee/Expr/Symcrete.h @@ -4,12 +4,6 @@ #include "klee/ADT/Ref.h" #include "klee/Expr/ExprUtil.h" -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS -#include "llvm/Support/Casting.h" -DISABLE_WARNING_POP - #include #include diff --git a/include/klee/Module/KCallable.h b/include/klee/Module/KCallable.h index 72ae9f5b44..08ccd1a8dc 100644 --- a/include/klee/Module/KCallable.h +++ b/include/klee/Module/KCallable.h @@ -11,15 +11,10 @@ #define KLEE_KCALLABLE_H #include "klee/Module/KValue.h" -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS #include "llvm/ADT/Twine.h" -#include "llvm/IR/Function.h" #include "llvm/IR/InlineAsm.h" #include "llvm/IR/LLVMContext.h" #include "llvm/Support/Casting.h" -DISABLE_WARNING_POP #include #include diff --git a/include/klee/Module/KInstruction.h b/include/klee/Module/KInstruction.h index ce3ca900b9..0ad0e8a7d1 100644 --- a/include/klee/Module/KInstruction.h +++ b/include/klee/Module/KInstruction.h @@ -13,14 +13,7 @@ #include "KModule.h" #include "KValue.h" -#include "klee/Config/Version.h" -#include "klee/Support/CompilerWarning.h" -#include "llvm/IR/Argument.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS -#include "llvm/Support/DataTypes.h" #include "llvm/Support/raw_ostream.h" -DISABLE_WARNING_POP #include #include diff --git a/include/klee/Module/KModule.h b/include/klee/Module/KModule.h index aab05622ea..6549d06a2e 100644 --- a/include/klee/Module/KModule.h +++ b/include/klee/Module/KModule.h @@ -10,26 +10,19 @@ #ifndef KLEE_KMODULE_H #define KLEE_KMODULE_H -#include "klee/Config/Version.h" #include "klee/Core/Interpreter.h" #include "klee/Module/KCallable.h" #include "klee/Module/KValue.h" -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS #include "llvm/ADT/ArrayRef.h" #include "llvm/IR/CFG.h" #include "llvm/Support/Casting.h" -DISABLE_WARNING_POP -#include #include #include #include #include #include -#include #include namespace llvm { diff --git a/include/klee/Module/KType.h b/include/klee/Module/KType.h index 59ab9021e2..1b45b63215 100644 --- a/include/klee/Module/KType.h +++ b/include/klee/Module/KType.h @@ -5,7 +5,6 @@ #include #include #include -#include namespace llvm { class Type; diff --git a/include/klee/Module/KValue.h b/include/klee/Module/KValue.h index 278ebed39d..eaf6044d58 100644 --- a/include/klee/Module/KValue.h +++ b/include/klee/Module/KValue.h @@ -38,12 +38,12 @@ struct KValue { /* Returns name of inner value if so exists. */ [[nodiscard]] virtual llvm::StringRef getName() const; - [[nodiscard]] virtual bool operator<(const KValue &rhs) const = 0; + [[nodiscard]] virtual bool operator<(const KValue &) const = 0; [[nodiscard]] virtual unsigned hash() const = 0; /* Kind of value. Serves for llvm rtti purposes. */ [[nodiscard]] Kind getKind() const { return kind; } - [[nodiscard]] static bool classof(const KValue *rhs) { return true; } + [[nodiscard]] static bool classof(const KValue *) { return true; } virtual ~KValue() = default; }; diff --git a/include/klee/Module/LocationInfo.h b/include/klee/Module/LocationInfo.h index ae1db8f315..043e85cac4 100644 --- a/include/klee/Module/LocationInfo.h +++ b/include/klee/Module/LocationInfo.h @@ -11,7 +11,6 @@ #define KLEE_LOCATIONINFO_H #include -#include #include #include diff --git a/include/klee/Module/SarifReport.h b/include/klee/Module/SarifReport.h index 7f80b7ed82..37275c77a9 100644 --- a/include/klee/Module/SarifReport.h +++ b/include/klee/Module/SarifReport.h @@ -10,16 +10,17 @@ #ifndef KLEE_SARIF_REPORT_H #define KLEE_SARIF_REPORT_H +#include "klee/ADT/Ref.h" + +#include + +#include "nlohmann/json.hpp" + #include -#include #include #include #include -#include "klee/ADT/Ref.h" -#include "nlohmann/json.hpp" -#include "llvm/IR/Function.h" - using json = nlohmann::json; namespace nlohmann { @@ -102,11 +103,11 @@ struct Fingerprints { std::string cooddy_uid; }; -static void to_json(json &j, const Fingerprints &p) { +[[maybe_unused]] static void to_json(json &j, const Fingerprints &p) { j = json{{"cooddy.uid", p.cooddy_uid}}; } -static void from_json(const json &j, Fingerprints &p) { +[[maybe_unused]] static void from_json(const json &j, Fingerprints &p) { j.at("cooddy.uid").get_to(p.cooddy_uid); } diff --git a/include/klee/Module/Target.h b/include/klee/Module/Target.h index eec1e8d302..c4c7185fa0 100644 --- a/include/klee/Module/Target.h +++ b/include/klee/Module/Target.h @@ -12,27 +12,11 @@ #include "klee/Module/TargetHash.h" -#include "klee/ADT/RNG.h" #include "klee/ADT/Ref.h" #include "klee/Module/KModule.h" #include "klee/Module/SarifReport.h" -#include "klee/Support/OptionCategories.h" -#include "klee/System/Time.h" - -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS -#include "llvm/Support/Casting.h" -#include "llvm/Support/CommandLine.h" -#include "llvm/Support/raw_ostream.h" -DISABLE_WARNING_POP - -#include -#include -#include -#include + #include -#include namespace klee { diff --git a/include/klee/Module/TargetForest.h b/include/klee/Module/TargetForest.h index 6ae8dd3bb5..c53ee1fdc6 100644 --- a/include/klee/Module/TargetForest.h +++ b/include/klee/Module/TargetForest.h @@ -272,11 +272,9 @@ class TargetForest { bool deepFind(ref target) const; bool deepFindIn(ref child, ref target) const; size_t size() const { return forest.size(); } - Layer *replaceChildWith( - ref child, - const std::unordered_set, - UnorderedTargetsSetHash, - UnorderedTargetsSetCmp> &other) const; + Layer *replaceChildWith(const std::unordered_set< + ref, UnorderedTargetsSetHash, + UnorderedTargetsSetCmp> &other) const; Layer *replaceChildWith(ref child, Layer *other) const; Layer *removeChild(ref child) const; Layer *addChild(ref child) const; diff --git a/include/klee/Module/TargetHash.h b/include/klee/Module/TargetHash.h index 1962ba906c..339b58917b 100644 --- a/include/klee/Module/TargetHash.h +++ b/include/klee/Module/TargetHash.h @@ -12,7 +12,6 @@ #include "klee/ADT/Ref.h" -#include #include #include diff --git a/include/klee/Solver/SolverCmdLine.h b/include/klee/Solver/SolverCmdLine.h index e4e5fdcf03..874eced979 100644 --- a/include/klee/Solver/SolverCmdLine.h +++ b/include/klee/Solver/SolverCmdLine.h @@ -15,14 +15,7 @@ #ifndef KLEE_SOLVERCMDLINE_H #define KLEE_SOLVERCMDLINE_H -#include "klee/Config/config.h" -#include "klee/Support/CompilerWarning.h" - -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS -#include "llvm/ADT/ArrayRef.h" #include "llvm/Support/CommandLine.h" -DISABLE_WARNING_POP namespace klee { diff --git a/include/klee/Solver/SolverImpl.h b/include/klee/Solver/SolverImpl.h index 1893b4b799..bbdd262832 100644 --- a/include/klee/Solver/SolverImpl.h +++ b/include/klee/Solver/SolverImpl.h @@ -115,12 +115,12 @@ class SolverImpl { /// status code static const char *getOperationStatusString(SolverRunStatus statusCode); - virtual char *getConstraintLog(const Query &query) { + virtual char *getConstraintLog(const Query &) { // dummy return nullptr; } - virtual void setCoreSolverTimeout(time::Span timeout){}; + virtual void setCoreSolverTimeout(time::Span) {} virtual void notifyStateTermination(std::uint32_t id) = 0; }; diff --git a/include/klee/Solver/SolverUtil.h b/include/klee/Solver/SolverUtil.h index f3f4965a89..cc59ea37d1 100644 --- a/include/klee/Solver/SolverUtil.h +++ b/include/klee/Solver/SolverUtil.h @@ -165,16 +165,16 @@ class SolverResponse { virtual ResponseKind getResponseKind() const = 0; virtual bool tryGetInitialValuesFor( - const std::vector &objects, - std::vector> &values) const { + const std::vector &, + std::vector> &) const { return false; } - virtual bool tryGetInitialValues(Assignment::bindings_ty &values) const { + virtual bool tryGetInitialValues(Assignment::bindings_ty &) const { return false; } - virtual bool tryGetValidityCore(ValidityCore &validityCore) { return false; } + virtual bool tryGetValidityCore(ValidityCore &) { return false; } static bool classof(const SolverResponse *) { return true; } @@ -333,7 +333,7 @@ class UnknownResponse : public SolverResponse { return b.getResponseKind() == ResponseKind::Unknown; } - bool lessThen(const SolverResponse &b) const { return false; } + bool lessThen(const SolverResponse &) const { return false; } void dump() { llvm::errs() << "Unknown response"; } }; diff --git a/include/klee/Support/Casting.h b/include/klee/Support/Casting.h index d2cd1cb84e..4073c3174f 100644 --- a/include/klee/Support/Casting.h +++ b/include/klee/Support/Casting.h @@ -10,13 +10,7 @@ #ifndef KLEE_CASTING_H #define KLEE_CASTING_H -#include "klee/Config/Version.h" - -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS #include "llvm/Support/Casting.h" -DISABLE_WARNING_POP namespace klee { diff --git a/include/klee/Support/CompilerWarning.h b/include/klee/Support/CompilerWarning.h index f3c6ccacfa..49da0a5d23 100644 --- a/include/klee/Support/CompilerWarning.h +++ b/include/klee/Support/CompilerWarning.h @@ -37,5 +37,13 @@ #define DISABLE_WARNING_DEPRECATED_DECLARATIONS #endif +/// @brief marks instructions as unreachable +/// From C++23 in std: https://en.cppreference.com/w/cpp/utility/unreachable +__attribute__((noreturn)) inline void unreachable() { +#if defined(__GNUC__) || defined(__clang__) + __builtin_unreachable(); +#endif +} + #endif // KLEE_INCLUDE_KLEE_SUPPORT_COMPILERWARNING_H // clang-format off diff --git a/include/klee/Support/CompressionStream.h b/include/klee/Support/CompressionStream.h index fe3d606d21..e8b3b310f4 100644 --- a/include/klee/Support/CompressionStream.h +++ b/include/klee/Support/CompressionStream.h @@ -12,11 +12,7 @@ #include "zlib.h" -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS #include "llvm/Support/raw_ostream.h" -DISABLE_WARNING_POP namespace klee { const size_t BUFSIZE = 128 * 1024; diff --git a/include/klee/Support/Debug.h b/include/klee/Support/Debug.h index 594dc3f8a0..ec90fd8c96 100644 --- a/include/klee/Support/Debug.h +++ b/include/klee/Support/Debug.h @@ -12,17 +12,12 @@ #include "klee/Config/config.h" -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS -#include "llvm/Support/Debug.h" -DISABLE_WARNING_POP - // We define wrappers around the LLVM DEBUG macros that are conditionalized on // whether the LLVM we are building against has the symbols needed by these // checks. #ifdef ENABLE_KLEE_DEBUG +#include "llvm/Support/Debug.h" #define KLEE_DEBUG_WITH_TYPE(TYPE, X) DEBUG_WITH_TYPE(TYPE, X) #else #define KLEE_DEBUG_WITH_TYPE(TYPE, X) \ diff --git a/include/klee/Support/FileHandling.h b/include/klee/Support/FileHandling.h index a0dd0e9575..554dc3557d 100644 --- a/include/klee/Support/FileHandling.h +++ b/include/klee/Support/FileHandling.h @@ -10,11 +10,8 @@ #ifndef KLEE_FILEHANDLING_H #define KLEE_FILEHANDLING_H -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS +#include "klee/Config/config.h" #include "llvm/Support/raw_ostream.h" -DISABLE_WARNING_POP #include #include diff --git a/include/klee/Support/ModuleUtil.h b/include/klee/Support/ModuleUtil.h index a066a106ce..f1bc104ed3 100644 --- a/include/klee/Support/ModuleUtil.h +++ b/include/klee/Support/ModuleUtil.h @@ -11,12 +11,8 @@ #define KLEE_MODULEUTIL_H #include "klee/Core/Interpreter.h" -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS #include "llvm/IR/InstrTypes.h" #include "llvm/IR/Module.h" -DISABLE_WARNING_POP #include #include diff --git a/include/klee/Support/OptionCategories.h b/include/klee/Support/OptionCategories.h index ed8c23c880..773800edfe 100644 --- a/include/klee/Support/OptionCategories.h +++ b/include/klee/Support/OptionCategories.h @@ -14,11 +14,7 @@ #ifndef KLEE_OPTIONCATEGORIES_H #define KLEE_OPTIONCATEGORIES_H -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS #include "llvm/Support/CommandLine.h" -DISABLE_WARNING_POP namespace klee { extern llvm::cl::OptionCategory TestCompCat; diff --git a/include/klee/Support/PrintContext.h b/include/klee/Support/PrintContext.h index 5196b9a35f..74024f5a4d 100644 --- a/include/klee/Support/PrintContext.h +++ b/include/klee/Support/PrintContext.h @@ -12,13 +12,8 @@ #include "klee/Expr/Expr.h" -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS #include "llvm/Support/raw_ostream.h" -DISABLE_WARNING_POP -#include #include #include diff --git a/include/klee/Support/PrintVersion.h b/include/klee/Support/PrintVersion.h index fe77d60952..d1b18e5f21 100644 --- a/include/klee/Support/PrintVersion.h +++ b/include/klee/Support/PrintVersion.h @@ -10,13 +10,7 @@ #ifndef KLEE_PRINTVERSION_H #define KLEE_PRINTVERSION_H -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS #include "llvm/Support/raw_ostream.h" -DISABLE_WARNING_POP - -#include "klee/Config/Version.h" namespace klee { void printVersion(llvm::raw_ostream &OS); diff --git a/include/klee/Support/RoundingModeUtil.h b/include/klee/Support/RoundingModeUtil.h index 562dabff19..68ae84cb10 100644 --- a/include/klee/Support/RoundingModeUtil.h +++ b/include/klee/Support/RoundingModeUtil.h @@ -8,11 +8,7 @@ //===----------------------------------------------------------------------===// #ifndef KLEE_ROUNDING_MODE_UTIL_H -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS #include "llvm/ADT/APFloat.h" -DISABLE_WARNING_POP namespace klee { diff --git a/include/klee/Support/Timer.h b/include/klee/Support/Timer.h index ea621ee2d3..4021f1560b 100644 --- a/include/klee/Support/Timer.h +++ b/include/klee/Support/Timer.h @@ -12,11 +12,7 @@ #include "klee/System/Time.h" -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS #include "llvm/ADT/SmallVector.h" -DISABLE_WARNING_POP #include #include diff --git a/include/klee/System/Time.h b/include/klee/System/Time.h index 504a61a508..71c172c2fd 100644 --- a/include/klee/System/Time.h +++ b/include/klee/System/Time.h @@ -10,11 +10,7 @@ #ifndef KLEE_TIME_H #define KLEE_TIME_H -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS #include "llvm/Support/raw_ostream.h" -DISABLE_WARNING_POP #include #include diff --git a/include/klee/Utilities/APFloatEval.h b/include/klee/Utilities/APFloatEval.h index 4f038aa40d..e24f7cf8a3 100644 --- a/include/klee/Utilities/APFloatEval.h +++ b/include/klee/Utilities/APFloatEval.h @@ -10,12 +10,7 @@ #ifndef KLEE_APFLOAT_EVAL_H #define KLEE_APFLOAT_EVAL_H -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS #include "llvm/ADT/APFloat.h" -#include "llvm/Support/ErrorHandling.h" -DISABLE_WARNING_POP namespace klee { diff --git a/lib/ADT/CMakeLists.txt b/lib/ADT/CMakeLists.txt index 4afa541dd6..f013a88af4 100644 --- a/lib/ADT/CMakeLists.txt +++ b/lib/ADT/CMakeLists.txt @@ -11,6 +11,7 @@ add_library(kleeADT ) llvm_config(kleeADT "${USE_LLVM_SHARED}" support) -target_include_directories(kleeADT PRIVATE ${KLEE_INCLUDE_DIRS} ${LLVM_INCLUDE_DIRS}) +target_include_directories(kleeADT SYSTEM PRIVATE ${LLVM_INCLUDE_DIRS}) +target_include_directories(kleeADT PRIVATE ${KLEE_INCLUDE_DIRS}) target_compile_options(kleeADT PRIVATE ${KLEE_COMPONENT_CXX_FLAGS}) target_compile_definitions(kleeADT PRIVATE ${KLEE_COMPONENT_CXX_DEFINES}) diff --git a/lib/ADT/SparseStorage.cpp b/lib/ADT/SparseStorage.cpp index f6da087d4c..3c442c3f85 100644 --- a/lib/ADT/SparseStorage.cpp +++ b/lib/ADT/SparseStorage.cpp @@ -1,12 +1,8 @@ #include "klee/ADT/SparseStorage.h" #include "klee/Expr/Expr.h" -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH #include "llvm/ADT/StringExtras.h" #include "llvm/Support/raw_ostream.h" -DISABLE_WARNING_DEPRECATED_DECLARATIONS -DISABLE_WARNING_POP namespace klee { template <> diff --git a/lib/Basic/KTest.cpp b/lib/Basic/KTest.cpp index 71aaf96c93..c9556cf8df 100644 --- a/lib/Basic/KTest.cpp +++ b/lib/Basic/KTest.cpp @@ -9,10 +9,10 @@ #include "klee/ADT/KTest.h" -#include -#include -#include -#include +#include +#include +#include +#include #define KTEST_VERSION 4 #define KTEST_MAGIC_SIZE 5 diff --git a/lib/Core/AddressSpace.cpp b/lib/Core/AddressSpace.cpp index d95b8f9e0a..85f7940834 100644 --- a/lib/Core/AddressSpace.cpp +++ b/lib/Core/AddressSpace.cpp @@ -112,8 +112,8 @@ ObjectState *AddressSpace::getWriteable(const MemoryObject *mo, /// -bool AddressSpace::resolveOne(ref address, - KType *objectType, ObjectPair &result) const { +bool AddressSpace::resolveOne(ref address, KType *, + ObjectPair &result) const { uint64_t baseConst = address->getConstantBase()->getZExtValue(); uint64_t addressConst = address->getConstantValue()->getZExtValue(); MemoryObject hack(baseConst); @@ -143,9 +143,8 @@ bool AddressSpace::resolveOne(ref address, bool AddressSpace::resolveOneIfUnique(ExecutionState &state, TimingSolver *solver, - ref address, - KType *objectType, ObjectPair &result, - bool &success) const { + ref address, KType *, + ObjectPair &result, bool &success) const { ref base = address->getBase(); ref uniqueAddress = base; if (!isa(uniqueAddress) && @@ -325,8 +324,8 @@ int AddressSpace::checkPointerInObject(ExecutionState &state, bool AddressSpace::resolve(ExecutionState &state, TimingSolver *solver, ref p, KType *objectType, - ResolutionList &rl, ResolutionList &rlSkipped, - unsigned maxResolutions, time::Span timeout) const { + ResolutionList &rl, unsigned maxResolutions, + time::Span timeout) const { ResolvePredicate predicate(state, p, objectType, complete); if (ref CP = dyn_cast(p)) { ObjectPair res; diff --git a/lib/Core/AddressSpace.h b/lib/Core/AddressSpace.h index 6374950814..bb844561c4 100644 --- a/lib/Core/AddressSpace.h +++ b/lib/Core/AddressSpace.h @@ -121,7 +121,7 @@ class AddressSpace { /// \return true iff the resolution is incomplete (`maxResolutions` /// is non-zero and it was reached, or a query timed out). bool resolve(ExecutionState &state, TimingSolver *solver, ref p, - KType *objectType, ResolutionList &rl, ResolutionList &rlSkipped, + KType *objectType, ResolutionList &rl, unsigned maxResolutions = 0, time::Span timeout = time::Span()) const; diff --git a/lib/Core/BidirectionalSearcher.cpp b/lib/Core/BidirectionalSearcher.cpp index 9b1bdbd4a6..90045c520a 100644 --- a/lib/Core/BidirectionalSearcher.cpp +++ b/lib/Core/BidirectionalSearcher.cpp @@ -3,8 +3,6 @@ #include "Searcher.h" #include "SearcherUtil.h" -namespace {} // namespace - namespace klee { ref ForwardOnlySearcher::selectAction() { diff --git a/lib/Core/CMakeLists.txt b/lib/Core/CMakeLists.txt index c7606d7c7b..9f654afc0f 100644 --- a/lib/Core/CMakeLists.txt +++ b/lib/Core/CMakeLists.txt @@ -51,6 +51,8 @@ target_link_libraries(kleeCore PRIVATE llvm_config(kleeCore "${USE_LLVM_SHARED}" core executionengine mcjit native support) target_link_libraries(kleeCore PRIVATE ${SQLite3_LIBRARIES}) -target_include_directories(kleeCore PRIVATE ${KLEE_INCLUDE_DIRS} ${LLVM_INCLUDE_DIRS} ${SQLite3_INCLUDE_DIRS}) + +target_include_directories(kleeCore SYSTEM PRIVATE ${LLVM_INCLUDE_DIRS} ${SQLite3_INCLUDE_DIRS}) +target_include_directories(kleeCore PRIVATE ${KLEE_INCLUDE_DIRS}) target_compile_options(kleeCore PRIVATE ${KLEE_COMPONENT_CXX_FLAGS}) target_compile_definitions(kleeCore PRIVATE ${KLEE_COMPONENT_CXX_DEFINES}) diff --git a/lib/Core/CXXTypeSystem/CXXTypeManager.cpp b/lib/Core/CXXTypeSystem/CXXTypeManager.cpp index 8b2cfd4a0c..af2ad81c4d 100644 --- a/lib/Core/CXXTypeSystem/CXXTypeManager.cpp +++ b/lib/Core/CXXTypeSystem/CXXTypeManager.cpp @@ -2,29 +2,24 @@ #include "../Memory.h" #include "../TypeManager.h" +#include "klee/Expr/Constraints.h" #include "klee/Expr/Expr.h" -#include "klee/Expr/ExprHashMap.h" +#include "klee/Core/Context.h" #include "klee/Module/KModule.h" #include "klee/Module/KType.h" -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS #include "llvm/IR/DebugInfoMetadata.h" #include "llvm/IR/DerivedTypes.h" #include "llvm/IR/Metadata.h" #include "llvm/IR/Module.h" #include "llvm/IR/Type.h" #include "llvm/Support/Casting.h" -DISABLE_WARNING_POP #include #include #include -#include "llvm/Support/raw_ostream.h" - using namespace llvm; using namespace klee; @@ -222,18 +217,14 @@ cxxtypes::KCXXType::KCXXType(llvm::Type *type, TypeManager *parent) typeKind = DEFAULT; } -bool cxxtypes::KCXXType::isAccessableFrom(KCXXType *accessingType) const { - return true; -} +bool cxxtypes::KCXXType::isAccessableFrom(KCXXType *) const { return true; } bool cxxtypes::KCXXType::isAccessableFrom(KType *accessingType) const { - assert(accessingType && "Accessing type is nullptr!"); - if (isa(accessingType)) { - KCXXType *accessingCXXType = cast(accessingType); - return isAccessingFromChar(accessingCXXType) || - isAccessableFrom(accessingCXXType); - } - assert(false && "Attempted to compare raw llvm type with C++ type!"); + KCXXType *accessingCXXType = dyn_cast_or_null(accessingType); + assert(accessingCXXType && + "Attempted to compare raw llvm type with C++ type!"); + return isAccessingFromChar(accessingCXXType) || + isAccessableFrom(accessingCXXType); } ref cxxtypes::KCXXType::getContentRestrictions(ref object) const { diff --git a/lib/Core/CXXTypeSystem/CXXTypeManager.h b/lib/Core/CXXTypeSystem/CXXTypeManager.h index 3446091138..66a7625490 100644 --- a/lib/Core/CXXTypeSystem/CXXTypeManager.h +++ b/lib/Core/CXXTypeSystem/CXXTypeManager.h @@ -3,17 +3,9 @@ #include "../TypeManager.h" -#include "klee/Expr/ExprHashMap.h" #include "klee/Module/KType.h" -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS -#include "llvm/Support/raw_ostream.h" -DISABLE_WARNING_POP - #include -#include #include #include #include diff --git a/lib/Core/CallPathManager.cpp b/lib/Core/CallPathManager.cpp index 8c2dc2b804..d5edbe2685 100644 --- a/lib/Core/CallPathManager.cpp +++ b/lib/Core/CallPathManager.cpp @@ -11,12 +11,8 @@ #include "klee/Statistics/Statistics.h" -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS #include "llvm/IR/Function.h" #include "llvm/Support/raw_ostream.h" -DISABLE_WARNING_POP #include #include diff --git a/lib/Core/CodeEvent.h b/lib/Core/CodeEvent.h index f266208629..4450a67311 100644 --- a/lib/Core/CodeEvent.h +++ b/lib/Core/CodeEvent.h @@ -16,12 +16,8 @@ #include "klee/Module/KValue.h" #include "klee/Module/SarifReport.h" -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS #include "llvm/IR/Instructions.h" #include "llvm/Support/Casting.h" -DISABLE_WARNING_POP #include #include diff --git a/lib/Core/ConstructStorage.h b/lib/Core/ConstructStorage.h index 758d02dd6c..6d2076c8b0 100644 --- a/lib/Core/ConstructStorage.h +++ b/lib/Core/ConstructStorage.h @@ -13,6 +13,7 @@ #include "klee/ADT/FixedSizeStorageAdapter.h" #include "klee/ADT/SparseStorage.h" #include "klee/Expr/Expr.h" +#include "klee/Support/CompilerWarning.h" #include #include @@ -65,6 +66,7 @@ constructStorage(ref size, const ValueType &defaultValue, } default: assert(0 && "unhandled memory type"); + unreachable(); } } @@ -90,6 +92,7 @@ constructStorage(size_t size, size_t treshold = MaxFixedSizeStructureSize) { } default: assert(0 && "unhandled memory type"); + unreachable(); } } } // namespace klee diff --git a/lib/Core/Context.cpp b/lib/Core/Context.cpp index 0ba40313d2..c478f8b934 100644 --- a/lib/Core/Context.cpp +++ b/lib/Core/Context.cpp @@ -11,12 +11,6 @@ #include "klee/Expr/Expr.h" -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS -#include "llvm/IR/Type.h" -DISABLE_WARNING_POP - #include using namespace klee; diff --git a/lib/Core/DistanceCalculator.cpp b/lib/Core/DistanceCalculator.cpp index 86aefdcb88..59025c76c4 100644 --- a/lib/Core/DistanceCalculator.cpp +++ b/lib/Core/DistanceCalculator.cpp @@ -11,16 +11,6 @@ #include "ExecutionState.h" #include "klee/Module/CodeGraphInfo.h" #include "klee/Module/KInstruction.h" -#include "klee/Module/Target.h" - -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS -#include "llvm/IR/CFG.h" -#include "llvm/IR/IntrinsicInst.h" -DISABLE_WARNING_POP - -#include using namespace llvm; using namespace klee; @@ -50,7 +40,7 @@ unsigned DistanceCalculator::SpeculativeState::computeHash() { DistanceResult DistanceCalculator::getDistance(const ExecutionState &state, KBlock *target) { - return getDistance(state.prevPC, state.pc, state.stack.callStack(), target); + return getDistance(state.pc, state.stack.callStack(), target); } DistanceResult DistanceCalculator::getDistance(KBlock *kb, TargetKind kind, @@ -87,7 +77,7 @@ DistanceResult DistanceCalculator::computeDistance(KBlock *kb, TargetKind kind, break; case PostTarget: - res = tryGetPostTargetWeight(kb, weight, target); + res = tryGetPostTargetWeight(kb, weight); isInsideFunction = false; break; @@ -97,9 +87,10 @@ DistanceResult DistanceCalculator::computeDistance(KBlock *kb, TargetKind kind, return DistanceResult(res, weight, isInsideFunction); } -DistanceResult DistanceCalculator::getDistance( - const KInstruction *prevPC, const KInstruction *pc, - const ExecutionStack::call_stack_ty &frames, KBlock *target) { +DistanceResult +DistanceCalculator::getDistance(const KInstruction *pc, + const ExecutionStack::call_stack_ty &frames, + KBlock *target) { KBlock *kb = pc->parent; const auto &distanceToTargetFunction = codeGraphInfo.getBackwardDistance(target->parent); @@ -203,9 +194,9 @@ WeightResult DistanceCalculator::tryGetPreTargetWeight(KBlock *kb, return res == Done ? Continue : res; } -WeightResult DistanceCalculator::tryGetPostTargetWeight(KBlock *kb, - weight_type &weight, - KBlock *target) const { +WeightResult +DistanceCalculator::tryGetPostTargetWeight(KBlock *kb, + weight_type &weight) const { KFunction *currentKF = kb->parent; std::vector &localTargets = currentKF->returnKBlocks; diff --git a/lib/Core/DistanceCalculator.h b/lib/Core/DistanceCalculator.h index c4b1e10657..697506a85f 100644 --- a/lib/Core/DistanceCalculator.h +++ b/lib/Core/DistanceCalculator.h @@ -51,7 +51,7 @@ class DistanceCalculator { DistanceResult getDistance(const ExecutionState &es, KBlock *target); - DistanceResult getDistance(const KInstruction *prevPC, const KInstruction *pc, + DistanceResult getDistance(const KInstruction *pc, const ExecutionStack::call_stack_ty &frames, KBlock *target); @@ -118,8 +118,7 @@ class DistanceCalculator { KBlock *target) const; WeightResult tryGetTargetWeight(KBlock *kb, weight_type &weight, KBlock *target) const; - WeightResult tryGetPostTargetWeight(KBlock *kb, weight_type &weight, - KBlock *target) const; + WeightResult tryGetPostTargetWeight(KBlock *kb, weight_type &weight) const; }; } // namespace klee diff --git a/lib/Core/ExecutionState.cpp b/lib/Core/ExecutionState.cpp index 8995736214..2e22f240ff 100644 --- a/lib/Core/ExecutionState.cpp +++ b/lib/Core/ExecutionState.cpp @@ -12,7 +12,6 @@ #include "ConstructStorage.h" #include "Memory.h" -#include "klee/Expr/ArrayExprVisitor.h" #include "klee/Expr/Expr.h" #include "klee/Module/Cell.h" #include "klee/Module/KInstruction.h" @@ -20,17 +19,12 @@ #include "klee/Support/Casting.h" #include "klee/Support/OptionCategories.h" -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS #include "llvm/ADT/APFloat.h" #include "llvm/IR/Function.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/raw_ostream.h" -DISABLE_WARNING_POP #include -#include #include #include #include @@ -423,7 +417,6 @@ BasicBlock *ExecutionState::getPCBlock() const { void ExecutionState::increaseLevel() { llvm::BasicBlock *srcbb = getPrevPCBlock(); - llvm::BasicBlock *dstbb = getPCBlock(); KFunction *kf = prevPC->parent->parent; KModule *kmodule = kf->parent; diff --git a/lib/Core/ExecutionState.h b/lib/Core/ExecutionState.h index 613c376762..29b49b62b7 100644 --- a/lib/Core/ExecutionState.h +++ b/lib/Core/ExecutionState.h @@ -31,20 +31,14 @@ #include "klee/Module/TargetForest.h" #include "klee/Module/TargetHash.h" #include "klee/Solver/Solver.h" -#include "klee/System/Time.h" #include "klee/Utilities/Math.h" #include "CodeLocation.h" #include "EventRecorder.h" -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS #include "llvm/ADT/APFloat.h" #include "llvm/IR/Function.h" -DISABLE_WARNING_POP -#include #include #include #include @@ -52,7 +46,6 @@ DISABLE_WARNING_POP #include #include #include -#include #include #include diff --git a/lib/Core/Executor.cpp b/lib/Core/Executor.cpp index b37ac868c8..9c37230634 100644 --- a/lib/Core/Executor.cpp +++ b/lib/Core/Executor.cpp @@ -32,6 +32,7 @@ #include "TimingSolver.h" #include "TypeManager.h" #include "UserSearcher.h" +#include "klee/ADT/Bits.h" #include "klee/ADT/SparseStorage.h" #include "klee/Core/Context.h" @@ -50,8 +51,6 @@ #include "klee/Expr/ExprPPrinter.h" #include "klee/Expr/ExprSMTLIBPrinter.h" #include "klee/Expr/ExprUtil.h" -#include "klee/Expr/IndependentConstraintSetUnion.h" -#include "klee/Expr/IndependentSet.h" #include "klee/Expr/SymbolicSource.h" #include "klee/Expr/Symcrete.h" #include "klee/Module/Cell.h" @@ -78,9 +77,6 @@ #include "CodeLocation.h" #include "EventRecorder.h" -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS #include "llvm/ADT/APFloat.h" #include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/StringExtras.h" @@ -98,31 +94,15 @@ DISABLE_WARNING_DEPRECATED_DECLARATIONS #include "llvm/Support/Casting.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/ErrorHandling.h" -#include "llvm/Support/FileSystem.h" #include "llvm/Support/Path.h" #include "llvm/Support/Process.h" -#if LLVM_VERSION_CODE >= LLVM_VERSION(10, 0) -#include "llvm/Support/TypeSize.h" -#else -typedef unsigned TypeSize; -#endif #include "llvm/Support/raw_ostream.h" -DISABLE_WARNING_POP #include #include -#include -#include -#include #include -#include -#include #include #include -#include -#include -#include -#include #include #include #include @@ -731,8 +711,8 @@ Executor::~Executor() { /***/ -ref X87FP80ToFPTrunc(ref arg, Expr::Width type, - llvm::APFloat::roundingMode rm) { +ref X87FP80ToFPTrunc(ref arg, [[maybe_unused]] Expr::Width type, + [[maybe_unused]] llvm::APFloat::roundingMode rm) { ref result = arg; #ifdef ENABLE_FP Expr::Width resultType = type; @@ -1001,7 +981,7 @@ void Executor::allocateGlobalObjects(ExecutionState &state) { errno_addr = reinterpret_cast( cast(errnoObj->getBaseExpr())->getZExtValue()); } else { - errno_addr = getErrnoLocation(state); + errno_addr = getErrnoLocation(); errnoObj = addExternalObject(state, (void *)errno_addr, typeSystemManager->getWrappedType(pointerErrnoAddr), @@ -1390,8 +1370,8 @@ bool Executor::canReachSomeTargetFromBlock(ExecutionState &es, KBlock *block) { auto target = p.first; if (mustVisitForkBranches(target, es.prevPC)) return true; - auto dist = distanceCalculator->getDistance( - es.prevPC, nextInstr, es.stack.callStack(), target->getBlock()); + auto dist = distanceCalculator->getDistance(nextInstr, es.stack.callStack(), + target->getBlock()); if (dist.result != WeightResult::Miss) return true; } @@ -2098,9 +2078,6 @@ void Executor::unwindToNextLandingpad(ExecutionState &state) { if (popFrames) { state.popFrame(); - if (statsTracker != nullptr) { - statsTracker->framePopped(state); - } } if (InvokeInst *invoke = dyn_cast(inst)) { @@ -2810,9 +2787,6 @@ void Executor::executeInstruction(ExecutionState &state, KInstruction *ki) { state.popFrame(); - if (statsTracker) - statsTracker->framePopped(state); - if (InvokeInst *ii = dyn_cast(caller)) { transferToBasicBlock(ii->getNormalDest(), caller->getParent(), state); } else { @@ -3584,7 +3558,6 @@ void Executor::executeInstruction(ExecutionState &state, KInstruction *ki) { KGEPInstruction *kgepi = static_cast(ki); GetElementPtrInst *gepInst = static_cast(kgepi->inst()); - Expr::Width pointerWidthInBits = Context::get().getPointerWidth(); ref base = eval(ki, 0, state).value; ref pointer = makePointer(base); @@ -5411,7 +5384,7 @@ void Executor::callExternalFunction(ExecutionState &state, KInstruction *target, e->getWidth() == Context::get().getPointerWidth() && resultType->isPointerTy()) { ref symExternCallsCanReturnNullExpr = - makeMockValue(state, "symExternCallsCanReturnNull", Expr::Bool); + makeMockValue("symExternCallsCanReturnNull", Expr::Bool); e = SelectExpr::create( symExternCallsCanReturnNullExpr, PointerExpr::create(Expr::createPointer(0), Expr::createPointer(0)), @@ -5450,8 +5423,7 @@ ref Executor::replaceReadWithSymbolic(ExecutionState &state, return res; } -ref Executor::makeMockValue(ExecutionState &state, - const std::string &name, Expr::Width width) { +ref Executor::makeMockValue(const std::string &name, Expr::Width width) { const Array *array = makeArray(Expr::createPointer(Expr::getMinBytesForWidth(width)), SourceBuilder::irreproducible(name)); @@ -5545,7 +5517,7 @@ void Executor::executeAlloc(ExecutionState &state, ref size, bool isLocal, if (checkOutOfMemory && !isLocal) { ref symCheckOutOfMemoryExpr = - makeMockValue(state, "symCheckOutOfMemory", Expr::Bool); + makeMockValue("symCheckOutOfMemory", Expr::Bool); address = SelectExpr::create(symCheckOutOfMemoryExpr, Expr::createPointer(0), address); } @@ -5664,7 +5636,7 @@ bool Executor::resolveExact(ExecutionState &estate, ref address, bool incomplete = false; /* We do not need this variable here, just a placeholder for resolve */ - bool success = resolveMemoryObjects( + [[maybe_unused]] bool success = resolveMemoryObjects( state, pointer, type, state.prevPC, 0, rl, mayBeOutOfBound, hasLazyInitialized, incomplete, LazyInitialization == LazyInitializationPolicy::Only); @@ -5846,7 +5818,7 @@ MemoryObject *Executor::allocate(ExecutionState &state, ref size, size_t allocationAlignment, KType *type, ref conditionExpr, ref lazyInitializationSource, - unsigned timestamp, bool isSymbolic) { + unsigned timestamp) { size = ZExtExpr::create(size, Context::get().getPointerWidth()); /* Try to find existing solution. */ @@ -6022,12 +5994,11 @@ bool Executor::resolveMemoryObjects( if (!onlyLazyInitialize || !mayLazyInitialize) { ResolutionList rl; - ResolutionList rlSkipped; solver->setTimeout(coreSolverTimeout); - incomplete = state.addressSpace.resolve(state, solver.get(), basePointer, - targetType, rl, rlSkipped, 0, - coreSolverTimeout); + incomplete = + state.addressSpace.resolve(state, solver.get(), basePointer, + targetType, rl, 0, coreSolverTimeout); solver->setTimeout(time::Span()); for (ResolutionList::iterator i = rl.begin(), ie = rl.end(); i != ie; @@ -6073,8 +6044,8 @@ bool Executor::resolveMemoryObjects( } bool Executor::checkResolvedMemoryObjects( - ExecutionState &state, ref address, KInstruction *target, - unsigned bytes, const ObjectResolutionList &mayBeResolvedMemoryObjects, + ExecutionState &state, ref address, unsigned bytes, + const ObjectResolutionList &mayBeResolvedMemoryObjects, bool hasLazyInitialized, ObjectResolutionList &resolvedMemoryObjects, std::vector> &resolveConditions, std::vector> &unboundConditions, ref &checkOutOfBounds, @@ -6218,12 +6189,9 @@ bool Executor::checkResolvedMemoryObjects( bool Executor::makeGuard(ExecutionState &state, const std::vector> &resolveConditions, - const std::vector> &unboundConditions, - ref checkOutOfBounds, bool hasLazyInitialized, ref &guard, bool &mayBeInBounds) { guard = Expr::createFalse(); - assert(resolveConditions.size() == unboundConditions.size()); if (resolveConditions.size() > 0) { guard = resolveConditions.back(); for (unsigned int i = 0; i < resolveConditions.size() - 1; ++i) { @@ -6247,7 +6215,7 @@ bool Executor::makeGuard(ExecutionState &state, } void Executor::collectReads(ExecutionState &state, ref address, - KType *targetType, Expr::Width type, unsigned bytes, + Expr::Width type, const ObjectResolutionList &resolvedMemoryObjects, std::vector> &results) { for (unsigned int i = 0; i < resolvedMemoryObjects.size(); ++i) { @@ -6309,9 +6277,8 @@ void Executor::executeMemoryOperation( KType *baseTargetType = targetType; if (estate.isGEPExpr(base)) { - KType *baseTargetType = typeSystemManager->getWrappedType( - llvm::PointerType::get(estate.gepExprBases[base], - kmodule->targetData->getAllocaAddrSpace())); + baseTargetType = typeSystemManager->getWrappedType(llvm::PointerType::get( + estate.gepExprBases[base], kmodule->targetData->getAllocaAddrSpace())); } if (SimplifySymIndices) { @@ -6480,7 +6447,7 @@ void Executor::executeMemoryOperation( ObjectResolutionList resolvedMemoryObjects; if (!checkResolvedMemoryObjects( - *state, address, target, bytes, mayBeResolvedMemoryObjects, + *state, address, bytes, mayBeResolvedMemoryObjects, hasLazyInitialized, resolvedMemoryObjects, resolveConditions, unboundConditions, checkOutOfBounds, mayBeOutOfBound)) { terminateStateOnSolverError(*state, @@ -6493,9 +6460,8 @@ void Executor::executeMemoryOperation( ref guard; bool mayBeInBounds; - if (!makeGuard(*state, resolveConditions, unboundConditions, - checkOutOfBounds, hasLazyInitialized, guard, - mayBeInBounds)) { + assert(resolveConditions.size() == unboundConditions.size()); + if (!makeGuard(*state, resolveConditions, guard, mayBeInBounds)) { terminateStateOnSolverError(*state, "Query timed out (resolve)"); return; } @@ -6517,8 +6483,7 @@ void Executor::executeMemoryOperation( if (state) { std::vector> results; - collectReads(*state, address, targetType, type, bytes, - resolvedMemoryObjects, results); + collectReads(*state, address, type, resolvedMemoryObjects, results); if (isWrite) { for (unsigned int i = 0; i < resolvedMemoryObjects.size(); ++i) { @@ -6569,9 +6534,7 @@ void Executor::executeMemoryOperation( } } - if (!unbound && resolveConditions.size() == 0) { - klee_error(""); - } + assert(unbound || !resolveConditions.empty()); } else { std::vector statesForMemoryOperation; if (mayBeOutOfBound) { @@ -6748,7 +6711,7 @@ ref Executor::lazyInitializeObject( allocate(state, sizeExpr, isLocal, /*isGlobal=*/false, CodeLocation::create(target, "", 0, {}), /*allocationAlignment=*/8, targetType, conditionExpr, - addressExpr, timestamp, isSymbolic); + addressExpr, timestamp); return mo; } @@ -7166,7 +7129,7 @@ void Executor::prepareSymbolicValue(ExecutionState &state, StackFrame &frame, void Executor::prepareMockValue(ExecutionState &state, StackFrame &frame, const std::string &name, Expr::Width width, KInstruction *target) { - ref result = makeMockValue(state, name, width); + ref result = makeMockValue(name, width); bindLocal(target, frame, result); if (isa(target->inst())) { lazyInitializeLocalObject(state, frame, result, target); @@ -7822,7 +7785,7 @@ void Executor::prepareForEarlyExit() { } /// Returns the errno location in memory -int *Executor::getErrnoLocation(const ExecutionState &state) const { +int *Executor::getErrnoLocation() const { #if !defined(__APPLE__) && !defined(__FreeBSD__) /* From /usr/include/errno.h: it [errno] is a per-thread variable. */ return __errno_location(); diff --git a/lib/Core/Executor.h b/lib/Core/Executor.h index b007f6ff3b..e990524a45 100644 --- a/lib/Core/Executor.h +++ b/lib/Core/Executor.h @@ -37,17 +37,12 @@ #include "klee/Support/Timer.h" #include "klee/System/Time.h" -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS #include "llvm/ADT/APFloat.h" #include "llvm/ADT/Twine.h" -#include "llvm/IR/Argument.h" + #include "llvm/IR/Intrinsics.h" #include "llvm/Support/raw_ostream.h" -DISABLE_WARNING_POP -#include #include #include #include @@ -346,7 +341,7 @@ class Executor : public Interpreter { size_t allocationAlignment, KType *type, ref conditionExpr = Expr::createTrue(), ref lazyInitializationSource = ref(), - unsigned timestamp = 0, bool isSymbolic = false); + unsigned timestamp = 0); /// Allocate and bind a new object in a particular state. NOTE: This /// function may fork. @@ -404,8 +399,8 @@ class Executor : public Interpreter { bool &incomplete, bool onlyLazyInitialize = false); bool checkResolvedMemoryObjects( - ExecutionState &state, ref address, KInstruction *target, - unsigned bytes, const ObjectResolutionList &mayBeResolvedMemoryObjects, + ExecutionState &state, ref address, unsigned bytes, + const ObjectResolutionList &mayBeResolvedMemoryObjects, bool hasLazyInitialized, ObjectResolutionList &resolvedMemoryObjects, std::vector> &resolveConditions, std::vector> &unboundConditions, ref &checkOutOfBounds, @@ -413,12 +408,10 @@ class Executor : public Interpreter { bool makeGuard(ExecutionState &state, const std::vector> &resolveConditions, - const std::vector> &unboundConditions, - ref checkOutOfBounds, bool hasLazyInitialized, ref &guard, bool &mayBeInBounds); void collectReads(ExecutionState &state, ref address, - KType *targetType, Expr::Width type, unsigned bytes, + Expr::Width type, const ObjectResolutionList &resolvedMemoryObjects, std::vector> &results); @@ -479,8 +472,7 @@ class Executor : public Interpreter { // Used for testing. ref replaceReadWithSymbolic(ExecutionState &state, ref e); - ref makeMockValue(ExecutionState &state, const std::string &name, - Expr::Width width); + ref makeMockValue(const std::string &name, Expr::Width width); const Cell &eval(const KInstruction *ki, unsigned index, ExecutionState &state, StackFrame &sf, @@ -864,7 +856,7 @@ class Executor : public Interpreter { size_t getAllocationAlignment(const llvm::Value *allocSite) const; /// Returns the errno location in memory of the state - int *getErrnoLocation(const ExecutionState &state) const; + int *getErrnoLocation() const; }; } // namespace klee diff --git a/lib/Core/ExecutorUtil.cpp b/lib/Core/ExecutorUtil.cpp index 546d6e1a94..6626c5d7b3 100644 --- a/lib/Core/ExecutorUtil.cpp +++ b/lib/Core/ExecutorUtil.cpp @@ -11,16 +11,12 @@ #include "klee/Core/Context.h" #include "klee/ADT/Either.h" -#include "klee/Config/Version.h" #include "klee/Core/Interpreter.h" #include "klee/Expr/Expr.h" #include "klee/Module/KModule.h" #include "klee/Solver/Solver.h" #include "klee/Support/ErrorHandling.h" -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS #include "llvm/ADT/APFloat.h" #include "llvm/ADT/APInt.h" #include "llvm/IR/Constants.h" @@ -28,10 +24,7 @@ DISABLE_WARNING_DEPRECATED_DECLARATIONS #include "llvm/IR/Function.h" #include "llvm/IR/GetElementPtrTypeIterator.h" #include "llvm/IR/Instructions.h" -#include "llvm/IR/Module.h" -#include "llvm/IR/Operator.h" #include "llvm/Support/raw_ostream.h" -DISABLE_WARNING_POP #include @@ -39,8 +32,8 @@ using namespace llvm; namespace klee { extern llvm::cl::opt X86FPAsX87FP80; -ref X87FP80ToFPTrunc(ref arg, Expr::Width type, - llvm::APFloat::roundingMode rm) { +ref X87FP80ToFPTrunc(ref arg, [[maybe_unused]] Expr::Width type, + [[maybe_unused]] llvm::APFloat::roundingMode rm) { ref result = arg; #ifdef ENABLE_FP Expr::Width resultType = type; @@ -281,7 +274,7 @@ ref Executor::evalConstantExpr(const llvm::ConstantExpr *ce, llvm::Type *type = ce->getType(); ref op1(0), op2(0), op3(0); - bool isPointer1(false), isPointer2(false), isPointer3(false); + [[maybe_unused]] bool isPointer1(false), isPointer2(false), isPointer3(false); int numOperands = ce->getNumOperands(); if (numOperands > 0) { diff --git a/lib/Core/ExternalDispatcher.cpp b/lib/Core/ExternalDispatcher.cpp index 642dd7a7ae..9676f21cdc 100644 --- a/lib/Core/ExternalDispatcher.cpp +++ b/lib/Core/ExternalDispatcher.cpp @@ -10,13 +10,10 @@ #include "ExternalDispatcher.h" #include "CoreStats.h" -#include "klee/Config/Version.h" #include "klee/Module/KCallable.h" #include "klee/Module/KModule.h" -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS +#include "llvm/ExecutionEngine/ExecutionEngine.h" #include "llvm/ExecutionEngine/GenericValue.h" #include "llvm/ExecutionEngine/MCJIT.h" #include "llvm/IR/Constants.h" @@ -29,12 +26,12 @@ DISABLE_WARNING_DEPRECATED_DECLARATIONS #include "llvm/Support/DynamicLibrary.h" #include "llvm/Support/TargetSelect.h" #include "llvm/Support/raw_ostream.h" -DISABLE_WARNING_POP #include -#include #include +#include "setjmp.h" + using namespace llvm; using namespace klee; @@ -44,7 +41,7 @@ static sigjmp_buf escapeCallJmpBuf; extern "C" { -static void sigsegv_handler(int signal, siginfo_t *info, void *context) { +static void sigsegv_handler(int, siginfo_t *, void *) { siglongjmp(escapeCallJmpBuf, 1); } } @@ -349,12 +346,13 @@ Function *ExternalDispatcherImpl::createDispatcher(KCallable *target, target->getName(), FTy, func->function()->getAttributes()); result = Builder.CreateCall(dispatchTarget, llvm::ArrayRef(args, args + i)); - } else if (auto *asmValue = dyn_cast(target)) { + } else { + auto *asmValue = dyn_cast(target); + assert(asmValue && "Unhandled KCallable type"); result = Builder.CreateCall(asmValue->inlineAsm(), llvm::ArrayRef(args, args + i)); - } else { - assert(0 && "Unhandled KCallable derived class"); } + if (result->getType() != Type::getVoidTy(ctx)) { auto resp = Builder.CreateBitCast( argI64s, PointerType::getUnqual(result->getType())); diff --git a/lib/Core/ExternalDispatcher.h b/lib/Core/ExternalDispatcher.h index e9ed7682d8..b4e8f2d7b1 100644 --- a/lib/Core/ExternalDispatcher.h +++ b/lib/Core/ExternalDispatcher.h @@ -10,11 +10,7 @@ #ifndef KLEE_EXTERNALDISPATCHER_H #define KLEE_EXTERNALDISPATCHER_H -#include "klee/Config/Version.h" - -#include -#include -#include +#include #include namespace llvm { diff --git a/lib/Core/GetElementPtrTypeIterator.h b/lib/Core/GetElementPtrTypeIterator.h index f892194737..3d7ae2b2e0 100644 --- a/lib/Core/GetElementPtrTypeIterator.h +++ b/lib/Core/GetElementPtrTypeIterator.h @@ -18,14 +18,10 @@ #ifndef KLEE_GETELEMENTPTRTYPEITERATOR_H #define KLEE_GETELEMENTPTRTYPEITERATOR_H -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS #include "llvm/IR/Constants.h" #include "llvm/IR/DerivedTypes.h" #include "llvm/IR/Instructions.h" #include "llvm/IR/User.h" -DISABLE_WARNING_POP #include "klee/Config/Version.h" @@ -87,8 +83,9 @@ class generic_gep_type_iterator { generic_gep_type_iterator &operator++() { // Preincrement #if LLVM_VERSION_CODE >= LLVM_VERSION(11, 0) - if (isa(CurTy) || isa(CurTy) || - isa(CurTy)) { + if (llvm::isa(CurTy) || + llvm::isa(CurTy) || + llvm::isa(CurTy)) { CurTy = llvm::GetElementPtrInst::getTypeAtIndex(CurTy, getOperand()); #else if (llvm::CompositeType *CT = dyn_cast(CurTy)) { @@ -158,12 +155,12 @@ inline vce_type_iterator vce_type_end(const llvm::ConstantExpr *CE) { template inline generic_gep_type_iterator gep_type_begin(llvm::Type *Op0, ItTy I, - ItTy E) { + ItTy) { return generic_gep_type_iterator::begin(Op0, I); } template -inline generic_gep_type_iterator gep_type_end(llvm::Type *Op0, ItTy I, +inline generic_gep_type_iterator gep_type_end(llvm::Type *, ItTy, ItTy E) { return generic_gep_type_iterator::end(E); } diff --git a/lib/Core/ImpliedValue.cpp b/lib/Core/ImpliedValue.cpp index 81d3e3faf8..f7f56405f4 100644 --- a/lib/Core/ImpliedValue.cpp +++ b/lib/Core/ImpliedValue.cpp @@ -9,9 +9,6 @@ #include "ImpliedValue.h" -#include "klee/Core/Context.h" - -#include "klee/Expr/Constraints.h" #include "klee/Expr/Expr.h" #include "klee/Expr/ExprUtil.h" #include "klee/Solver/Solver.h" diff --git a/lib/Core/Memory.cpp b/lib/Core/Memory.cpp index b27ad36eee..157babee2e 100644 --- a/lib/Core/Memory.cpp +++ b/lib/Core/Memory.cpp @@ -12,35 +12,27 @@ #include "ConstructStorage.h" #include "ExecutionState.h" #include "MemoryManager.h" +#include "klee/ADT/Bits.h" #include "klee/ADT/Ref.h" #include "klee/ADT/SparseStorage.h" #include "klee/Core/Context.h" #include "CodeLocation.h" -#include "klee/ADT/BitArray.h" #include "klee/Expr/Assignment.h" #include "klee/Expr/Expr.h" #include "klee/Module/KType.h" #include "klee/Solver/Solver.h" #include "klee/Support/ErrorHandling.h" -#include "klee/Support/OptionCategories.h" -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS #include "llvm/IR/Function.h" #include "llvm/IR/Instruction.h" #include "llvm/IR/Value.h" -#include "llvm/Support/Casting.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/raw_ostream.h" -DISABLE_WARNING_POP #include #include #include -#include -#include namespace klee { llvm::cl::opt MemoryBackend( @@ -167,7 +159,7 @@ ref ObjectState::read8(ref offset) const { std::string allocInfo = object->getAllocInfo(); klee_warning_once(nullptr, "Symbolic memory access will send the following " - "array of %lu bytes to " + "array of %" PRId64 " bytes to " "the constraint solver -- large symbolic arrays may " "cause significant " "performance issues: %s", @@ -196,7 +188,7 @@ ref ObjectState::readValue8(ref offset) const { std::string allocInfo = object->getAllocInfo(); klee_warning_once(nullptr, "Symbolic memory access will send the following " - "array of %lu bytes to " + "array of %" PRId64 " bytes to " "the constraint solver -- large symbolic arrays may " "cause significant " "performance issues: %s", @@ -219,7 +211,7 @@ ref ObjectState::readBase8(ref offset) const { std::string allocInfo = object->getAllocInfo(); klee_warning_once(nullptr, "Symbolic memory access will send the following " - "array of %lu bytes to " + "array of %" PRId64 " bytes to " "the constraint solver -- large symbolic arrays may " "cause significant " "performance issues: %s", @@ -261,7 +253,7 @@ void ObjectState::write8(ref offset, ref value) { std::string allocInfo = object->getAllocInfo(); klee_warning_once(nullptr, "Symbolic memory access will send the following array " - "of %lu bytes to " + "array of %" PRId64 " bytes to " "the constraint solver -- large symbolic arrays may " "cause significant " "performance issues: %s", diff --git a/lib/Core/Memory.h b/lib/Core/Memory.h index 80127c399a..14c0cb16a6 100644 --- a/lib/Core/Memory.h +++ b/lib/Core/Memory.h @@ -12,27 +12,18 @@ #include "CodeLocation.h" #include "MemoryManager.h" -#include "TimingSolver.h" #include "klee/ADT/Ref.h" #include "klee/ADT/SparseStorage.h" -#include "klee/Core/Context.h" #include "klee/Expr/Assignment.h" #include "klee/Expr/Expr.h" #include "klee/Expr/SourceBuilder.h" -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS -#include "llvm/ADT/StringExtras.h" -DISABLE_WARNING_POP - #include #include #include #include #include -#include namespace llvm { class Value; diff --git a/lib/Core/MemoryManager.cpp b/lib/Core/MemoryManager.cpp index 61f416e1b3..1abfe9d686 100644 --- a/lib/Core/MemoryManager.cpp +++ b/lib/Core/MemoryManager.cpp @@ -17,24 +17,12 @@ #include "klee/Expr/SourceBuilder.h" #include "klee/Support/ErrorHandling.h" -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS -#include "llvm/IR/GlobalVariable.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/MathExtras.h" -#if LLVM_VERSION_CODE >= LLVM_VERSION(10, 0) -#include "llvm/Support/Alignment.h" -#else -#include "llvm/Support/MathExtras.h" -#endif -DISABLE_WARNING_POP #include #include -#include #include -#include using namespace klee; @@ -237,8 +225,6 @@ MemoryObject *MemoryManager::allocateFixed(uint64_t address, uint64_t size, return res; } -void MemoryManager::deallocate(const MemoryObject *mo) { assert(0); } - void MemoryManager::markFreed(MemoryObject *mo) { if (objects.find(mo) != objects.end()) { if (!mo->isFixed && !DeterministicAllocation) { diff --git a/lib/Core/MemoryManager.h b/lib/Core/MemoryManager.h index 8c9a6424b0..f714c7f186 100644 --- a/lib/Core/MemoryManager.h +++ b/lib/Core/MemoryManager.h @@ -53,7 +53,6 @@ class MemoryManager { const Array *content = nullptr); MemoryObject *allocateFixed(uint64_t address, uint64_t size, ref allocSite, KType *type); - void deallocate(const MemoryObject *mo); void markFreed(MemoryObject *mo); /* * Returns the size used by deterministic allocation in bytes diff --git a/lib/Core/MockBuilder.cpp b/lib/Core/MockBuilder.cpp index de06f5e463..5c82feee13 100644 --- a/lib/Core/MockBuilder.cpp +++ b/lib/Core/MockBuilder.cpp @@ -656,7 +656,8 @@ void MockBuilder::buildAnnotationForExternalFunctionReturn( } void MockBuilder::buildAnnotationForExternalFunctionProperties( - llvm::Function *func, const std::set &properties) { + [[maybe_unused]] llvm::Function *func, + const std::set &properties) { for (const auto &property : properties) { switch (property) { case Statement::Property::Deterministic: diff --git a/lib/Core/ObjectManager.cpp b/lib/Core/ObjectManager.cpp index d79d1d28a8..40a66eee23 100644 --- a/lib/Core/ObjectManager.cpp +++ b/lib/Core/ObjectManager.cpp @@ -5,11 +5,6 @@ #include "TargetManager.h" #include "klee/Module/KModule.h" -#include "klee/Module/Target.h" -#include "klee/Support/Debug.h" - -#include "llvm/Support/CommandLine.h" -#include using namespace llvm; using namespace klee; @@ -38,15 +33,14 @@ ExecutionState *ObjectManager::branchState(ExecutionState *state, assert(statesUpdated); ExecutionState *newState = state->branch(); addedStates.push_back(newState); - processForest->attach(state->ptreeNode, newState, state, reason); + processForest->attach(state->ptreeNode, newState, state); stats::incBranchStat(reason, 1); return newState; } void ObjectManager::removeState(ExecutionState *state) { - std::vector::iterator itr = - std::find(removedStates.begin(), removedStates.end(), state); - assert(itr == removedStates.end()); + assert(std::find(removedStates.begin(), removedStates.end(), state) == + removedStates.end()); if (!statesUpdated) { statesUpdated = true; diff --git a/lib/Core/ObjectManager.h b/lib/Core/ObjectManager.h index 3f7034f3c9..4d3acd78f6 100644 --- a/lib/Core/ObjectManager.h +++ b/lib/Core/ObjectManager.h @@ -7,7 +7,6 @@ #include "klee/Core/BranchTypes.h" #include "klee/Module/KModule.h" -#include #include namespace klee { @@ -85,6 +84,7 @@ class ObjectManager { class Subscriber { public: virtual void update(ref e) = 0; + virtual ~Subscriber() = default; }; } // namespace klee diff --git a/lib/Core/PForest.cpp b/lib/Core/PForest.cpp index 8a97410510..9ccc046c41 100644 --- a/lib/Core/PForest.cpp +++ b/lib/Core/PForest.cpp @@ -13,10 +13,6 @@ #include "klee/Expr/Expr.h" #include "klee/Expr/ExprPPrinter.h" -#include "klee/Support/OptionCategories.h" - -#include -#include using namespace klee; using namespace llvm; @@ -27,9 +23,9 @@ void PForest::addRoot(ExecutionState *initialState) { } void PForest::attach(PTreeNode *node, ExecutionState *leftState, - ExecutionState *rightState, BranchType reason) { + ExecutionState *rightState) { assert(trees.find(node->getTreeID()) != trees.end()); - trees[node->getTreeID()]->attach(node, leftState, rightState, reason); + trees[node->getTreeID()]->attach(node, leftState, rightState); } void PForest::remove(PTreeNode *node) { diff --git a/lib/Core/PForest.h b/lib/Core/PForest.h index dd4236e948..7a63bdf9a1 100644 --- a/lib/Core/PForest.h +++ b/lib/Core/PForest.h @@ -12,6 +12,7 @@ #define KLEE_PFOREST_H #include "PTree.h" +#include "klee/Support/ErrorHandling.h" #include @@ -32,7 +33,7 @@ class PForest { ~PForest(); void addRoot(ExecutionState *initialState); void attach(PTreeNode *node, ExecutionState *leftState, - ExecutionState *rightState, BranchType reason); + ExecutionState *rightState); void remove(PTreeNode *node); const std::map &getPTrees() { return trees; } void dump(llvm::raw_ostream &os); diff --git a/lib/Core/PTree.cpp b/lib/Core/PTree.cpp index 64d83bd2dd..86b205d6b4 100644 --- a/lib/Core/PTree.cpp +++ b/lib/Core/PTree.cpp @@ -38,7 +38,7 @@ PTree::PTree(ExecutionState *initialState, uint32_t treeID) { } void PTree::attach(PTreeNode *node, ExecutionState *leftState, - ExecutionState *rightState, BranchType reason) { + ExecutionState *rightState) { assert(node && !node->left.getPointer() && !node->right.getPointer()); assert(node == rightState->ptreeNode && "Attach assumes the right state is the current state"); diff --git a/lib/Core/PTree.h b/lib/Core/PTree.h index b0f3e0f320..b4db0d8933 100644 --- a/lib/Core/PTree.h +++ b/lib/Core/PTree.h @@ -12,13 +12,8 @@ #include "klee/Core/BranchTypes.h" #include "klee/Expr/Expr.h" -#include "klee/Support/ErrorHandling.h" -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS #include "llvm/ADT/PointerIntPair.h" -DISABLE_WARNING_POP namespace klee { class ExecutionState; @@ -60,7 +55,7 @@ class PTree { ~PTree() = default; void attach(PTreeNode *node, ExecutionState *leftState, - ExecutionState *rightState, BranchType reason); + ExecutionState *rightState); void remove(PTreeNode *node); void dump(llvm::raw_ostream &os); std::uint32_t getID() const { return id; }; diff --git a/lib/Core/Searcher.cpp b/lib/Core/Searcher.cpp index 1bfdb2620d..695f3f3977 100644 --- a/lib/Core/Searcher.cpp +++ b/lib/Core/Searcher.cpp @@ -27,15 +27,6 @@ #include "klee/System/Time.h" #include "klee/Utilities/Math.h" -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS -#include "llvm/IR/Constants.h" -#include "llvm/IR/Instructions.h" -#include "llvm/IR/Module.h" -#include "llvm/Support/CommandLine.h" -DISABLE_WARNING_POP - #include #include #include @@ -47,7 +38,7 @@ using namespace llvm; ExecutionState &DFSSearcher::selectState() { return *states.back(); } -void DFSSearcher::update(ExecutionState *current, +void DFSSearcher::update(ExecutionState *, const std::vector &addedStates, const std::vector &removedStates) { // insert states @@ -116,7 +107,7 @@ ExecutionState &RandomSearcher::selectState() { } void RandomSearcher::update( - ExecutionState *current, const std::vector &addedStates, + ExecutionState *, const std::vector &addedStates, const std::vector &removedStates) { // insert states states.insert(states.end(), addedStates.begin(), addedStates.end()); @@ -518,7 +509,7 @@ ExecutionState &RandomPathSearcher::selectState() { } void RandomPathSearcher::update( - ExecutionState *current, const std::vector &addedStates, + ExecutionState *, const std::vector &addedStates, const std::vector &removedStates) { // insert states for (auto &es : addedStates) { @@ -649,7 +640,7 @@ class TimeMetric final : public IterativeDeepeningSearcher::Metric { public: void selectState() final { startTime = time::getWallTime(); } - bool exceeds(const ExecutionState &state) const final { + bool exceeds(const ExecutionState &) const final { return time::getWallTime() - startTime > time; } void increaseLimit() final { diff --git a/lib/Core/Searcher.h b/lib/Core/Searcher.h index ee1bc18690..e5bc79705c 100644 --- a/lib/Core/Searcher.h +++ b/lib/Core/Searcher.h @@ -20,15 +20,8 @@ #include "klee/Module/KModule.h" #include "klee/System/Time.h" -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS -#include "llvm/Support/CommandLine.h" #include "llvm/Support/raw_ostream.h" -DISABLE_WARNING_POP -#include -#include #include #include #include diff --git a/lib/Core/SearcherUtil.h b/lib/Core/SearcherUtil.h index a5b27f6378..297bdcd033 100644 --- a/lib/Core/SearcherUtil.h +++ b/lib/Core/SearcherUtil.h @@ -3,8 +3,6 @@ #define KLEE_SEARCHERUTIL_H #include "ExecutionState.h" -#include "klee/Expr/Path.h" -#include "klee/Module/KInstruction.h" namespace klee { diff --git a/lib/Core/SpecialFunctionHandler.cpp b/lib/Core/SpecialFunctionHandler.cpp index 58fe990f2f..cd64598b69 100644 --- a/lib/Core/SpecialFunctionHandler.cpp +++ b/lib/Core/SpecialFunctionHandler.cpp @@ -20,28 +20,21 @@ #include "TypeManager.h" #include "klee/Config/config.h" +#include "klee/Core/Context.h" #include "klee/Expr/Expr.h" #include "klee/Module/KInstruction.h" #include "klee/Module/KModule.h" -#include "klee/Solver/SolverCmdLine.h" #include "klee/Support/Casting.h" -#include "klee/Support/Debug.h" #include "klee/Support/ErrorHandling.h" #include "klee/Support/OptionCategories.h" #include "klee/klee.h" -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS #include "llvm/ADT/APFloat.h" #include "llvm/ADT/Twine.h" #include "llvm/IR/DataLayout.h" #include "llvm/IR/Instructions.h" #include "llvm/IR/Module.h" -#include "llvm/Support/Format.h" -DISABLE_WARNING_POP -#include #include using namespace llvm; @@ -349,31 +342,30 @@ SpecialFunctionHandler::readStringAtAddress(ExecutionState &state, /****/ -void SpecialFunctionHandler::handleAbort(ExecutionState &state, - KInstruction *target, - std::vector> &arguments) { +void SpecialFunctionHandler::handleAbort( + ExecutionState &state, KInstruction *, + [[maybe_unused]] std::vector> &arguments) { assert(arguments.size() == 0 && "invalid number of arguments to abort"); executor.terminateStateOnProgramError( state, new ErrorEvent(executor.locationOf(state), StateTerminationType::Abort, "abort failure")); } -void SpecialFunctionHandler::handleExit(ExecutionState &state, - KInstruction *target, - std::vector> &arguments) { +void SpecialFunctionHandler::handleExit( + ExecutionState &state, KInstruction *, + [[maybe_unused]] std::vector> &arguments) { assert(arguments.size() == 1 && "invalid number of arguments to exit"); executor.terminateStateOnExit(state); } void SpecialFunctionHandler::handleSilentExit( - ExecutionState &state, KInstruction *target, - std::vector> &arguments) { + ExecutionState &state, KInstruction *, + [[maybe_unused]] std::vector> &arguments) { assert(arguments.size() == 1 && "invalid number of arguments to exit"); executor.terminateStateEarlyUser(state, ""); } -void SpecialFunctionHandler::handleAssert(ExecutionState &state, - KInstruction *target, +void SpecialFunctionHandler::handleAssert(ExecutionState &state, KInstruction *, std::vector> &arguments) { assert(arguments.size() == 3 && "invalid number of arguments to _assert"); executor.terminateStateOnProgramError( @@ -385,8 +377,7 @@ void SpecialFunctionHandler::handleAssert(ExecutionState &state, } void SpecialFunctionHandler::handleAssertFail( - ExecutionState &state, KInstruction *target, - std::vector> &arguments) { + ExecutionState &state, KInstruction *, std::vector> &arguments) { assert(arguments.size() == 4 && "invalid number of arguments to __assert_fail"); executor.terminateStateOnProgramError( @@ -398,8 +389,7 @@ void SpecialFunctionHandler::handleAssertFail( } void SpecialFunctionHandler::handleReportError( - ExecutionState &state, KInstruction *target, - std::vector> &arguments) { + ExecutionState &state, KInstruction *, std::vector> &arguments) { assert(arguments.size() == 4 && "invalid number of arguments to klee_report_error"); @@ -423,8 +413,7 @@ void SpecialFunctionHandler::handleNew(ExecutionState &state, false, nullptr, 0, CheckOutOfMemory); } -void SpecialFunctionHandler::handleDelete(ExecutionState &state, - KInstruction *target, +void SpecialFunctionHandler::handleDelete(ExecutionState &state, KInstruction *, std::vector> &arguments) { // FIXME: Should check proper pairing with allocation type (malloc/free, // new/delete, new[]/delete[]). @@ -457,8 +446,7 @@ void SpecialFunctionHandler::handleNewNothrowArray( } void SpecialFunctionHandler::handleDeleteArray( - ExecutionState &state, KInstruction *target, - std::vector> &arguments) { + ExecutionState &state, KInstruction *, std::vector> &arguments) { // XXX should type check args assert(arguments.size() == 1 && "invalid number of arguments to delete[]"); executor.executeFree(state, executor.makePointer(arguments[0])); @@ -511,8 +499,7 @@ void SpecialFunctionHandler::handleMemalign(ExecutionState &state, #ifdef SUPPORT_KLEE_EH_CXX void SpecialFunctionHandler::handleEhUnwindRaiseExceptionImpl( - ExecutionState &state, KInstruction *target, - std::vector> &arguments) { + ExecutionState &state, KInstruction *, std::vector> &arguments) { assert(arguments.size() == 1 && "invalid number of arguments to _klee_eh_Unwind_RaiseException_impl"); @@ -549,14 +536,12 @@ void SpecialFunctionHandler::handleEhTypeid(ExecutionState &state, } #endif // SUPPORT_KLEE_EH_CXX -void SpecialFunctionHandler::handleSleep(ExecutionState &state, - KInstruction *target, - std::vector> &arguments) { +void SpecialFunctionHandler::handleSleep(ExecutionState &, KInstruction *, + std::vector> &) { nanosleep((const struct timespec[]){{1, 0}}, NULL); } -void SpecialFunctionHandler::handleAssume(ExecutionState &state, - KInstruction *target, +void SpecialFunctionHandler::handleAssume(ExecutionState &state, KInstruction *, std::vector> &arguments) { assert(arguments.size() == 1 && "invalid number of arguments to klee_assume"); @@ -593,8 +578,7 @@ void SpecialFunctionHandler::handleIsSymbolic( } void SpecialFunctionHandler::handlePreferCex( - ExecutionState &state, KInstruction *target, - std::vector> &arguments) { + ExecutionState &state, KInstruction *, std::vector> &arguments) { assert(arguments.size() == 2 && "invalid number of arguments to klee_prefex_cex"); @@ -613,8 +597,7 @@ void SpecialFunctionHandler::handlePosixPreferCex( } void SpecialFunctionHandler::handlePrintExpr( - ExecutionState &state, KInstruction *target, - std::vector> &arguments) { + ExecutionState &state, KInstruction *, std::vector> &arguments) { assert(arguments.size() == 2 && "invalid number of arguments to klee_print_expr"); @@ -624,8 +607,7 @@ void SpecialFunctionHandler::handlePrintExpr( } void SpecialFunctionHandler::handleSetForking( - ExecutionState &state, KInstruction *target, - std::vector> &arguments) { + ExecutionState &state, KInstruction *, std::vector> &arguments) { assert(arguments.size() == 1 && "invalid number of arguments to klee_set_forking"); ref value = executor.toUnique(state, arguments[0]); @@ -638,14 +620,14 @@ void SpecialFunctionHandler::handleSetForking( } } -void SpecialFunctionHandler::handleStackTrace( - ExecutionState &state, KInstruction *target, - std::vector> &arguments) { +void SpecialFunctionHandler::handleStackTrace(ExecutionState &state, + KInstruction *, + std::vector> &) { state.dumpStack(outs()); } void SpecialFunctionHandler::handleWarning(ExecutionState &state, - KInstruction *target, + KInstruction *, std::vector> &arguments) { assert(arguments.size() == 1 && "invalid number of arguments to klee_warning"); @@ -658,8 +640,7 @@ void SpecialFunctionHandler::handleWarning(ExecutionState &state, } void SpecialFunctionHandler::handleWarningOnce( - ExecutionState &state, KInstruction *target, - std::vector> &arguments) { + ExecutionState &state, KInstruction *, std::vector> &arguments) { assert(arguments.size() == 1 && "invalid number of arguments to klee_warning_once"); @@ -672,8 +653,8 @@ void SpecialFunctionHandler::handleWarningOnce( } void SpecialFunctionHandler::handleDumpConstraints( - ExecutionState &state, KInstruction *target, - std::vector> &arguments) { + ExecutionState &state, KInstruction *, + [[maybe_unused]] std::vector> &arguments) { assert(arguments.size() == 0 && "invalid number of arguments to klee_warning_once"); @@ -681,8 +662,7 @@ void SpecialFunctionHandler::handleDumpConstraints( } void SpecialFunctionHandler::handlePrintRange( - ExecutionState &state, KInstruction *target, - std::vector> &arguments) { + ExecutionState &state, KInstruction *, std::vector> &arguments) { assert(arguments.size() == 2 && "invalid number of arguments to klee_print_range"); @@ -729,14 +709,14 @@ void SpecialFunctionHandler::handleGetObjSize( } } -void SpecialFunctionHandler::handleGetErrno(ExecutionState &state, - KInstruction *target, - std::vector> &arguments) { +void SpecialFunctionHandler::handleGetErrno( + ExecutionState &state, KInstruction *target, + [[maybe_unused]] std::vector> &arguments) { // XXX should type check args assert(arguments.size() == 0 && "invalid number of arguments to klee_get_errno"); #ifndef WINDOWS - int *errno_addr = executor.getErrnoLocation(state); + int *errno_addr = executor.getErrnoLocation(); #else int *errno_addr = nullptr; #endif @@ -762,7 +742,7 @@ void SpecialFunctionHandler::handleGetErrno(ExecutionState &state, void SpecialFunctionHandler::handleErrnoLocation( ExecutionState &state, KInstruction *target, - std::vector> &arguments) { + [[maybe_unused]] std::vector> &arguments) { // Returns the address of the errno variable assert(arguments.size() == 0 && "invalid number of arguments to __errno_location/__error"); @@ -841,8 +821,7 @@ void SpecialFunctionHandler::handleRealloc(ExecutionState &state, } } -void SpecialFunctionHandler::handleFree(ExecutionState &state, - KInstruction *target, +void SpecialFunctionHandler::handleFree(ExecutionState &state, KInstruction *, std::vector> &arguments) { // XXX should type check args assert(arguments.size() == 1 && "invalid number of arguments to free"); @@ -850,8 +829,7 @@ void SpecialFunctionHandler::handleFree(ExecutionState &state, } void SpecialFunctionHandler::handleCheckMemoryAccess( - ExecutionState &state, KInstruction *target, - std::vector> &arguments) { + ExecutionState &state, KInstruction *, std::vector> &arguments) { assert(arguments.size() == 2 && "invalid number of arguments to klee_check_memory_access"); @@ -926,8 +904,7 @@ void SpecialFunctionHandler::handleDefineFixedObject( } void SpecialFunctionHandler::handleMakeSymbolic( - ExecutionState &state, KInstruction *target, - std::vector> &arguments) { + ExecutionState &state, KInstruction *, std::vector> &arguments) { std::string name; if (arguments.size() != 3) { @@ -980,10 +957,6 @@ void SpecialFunctionHandler::handleMakeSymbolic( assert(success && "FIXME: Unhandled solver failure"); if (res) { - uint64_t sid = 0; // TODO: unused variable - if (state.arrayNames.count(name)) { - sid = state.arrayNames[name]; - } executor.executeMakeSymbolic( *s, mo, old->getDynamicType(), SourceBuilder::makeSymbolic(name, @@ -1076,8 +1049,7 @@ void SpecialFunctionHandler::handleMakeMock(ExecutionState &state, } void SpecialFunctionHandler::handleMarkGlobal( - ExecutionState &state, KInstruction *target, - std::vector> &arguments) { + ExecutionState &state, KInstruction *, std::vector> &arguments) { assert(arguments.size() == 1 && "invalid number of arguments to klee_mark_global"); @@ -1128,7 +1100,7 @@ void SpecialFunctionHandler::handleIsSubnormal( void SpecialFunctionHandler::handleGetRoundingMode( ExecutionState &state, KInstruction *target, - std::vector> &arguments) { + [[maybe_unused]] std::vector> &arguments) { assert(arguments.size() == 0 && "invalid number of arguments to GetRoundingMode"); unsigned returnValue = 0; @@ -1159,8 +1131,7 @@ void SpecialFunctionHandler::handleGetRoundingMode( } void SpecialFunctionHandler::handleSetConcreteRoundingMode( - ExecutionState &state, KInstruction *target, - std::vector> &arguments) { + ExecutionState &state, KInstruction *, std::vector> &arguments) { assert(arguments.size() == 1 && "invalid number of arguments to SetRoundingMode"); llvm::APFloat::roundingMode newRoundingMode = @@ -1222,27 +1193,27 @@ void SpecialFunctionHandler::handleFAbs(ExecutionState &state, #ifdef HAVE_CTYPE_EXTERNALS -void SpecialFunctionHandler::handleCTypeBLoc( - ExecutionState &state, KInstruction *target, - std::vector> &arguments) { +void SpecialFunctionHandler::handleCTypeBLoc(ExecutionState &state, + KInstruction *target, + std::vector> &) { ref pointerValue = Expr::createPointer( reinterpret_cast(executor.c_type_b_loc_addr)); ref result = ConstantPointerExpr::create(pointerValue, pointerValue); executor.bindLocal(target, state, result); } -void SpecialFunctionHandler::handleCTypeToLowerLoc( - ExecutionState &state, KInstruction *target, - std::vector> &arguments) { +void SpecialFunctionHandler::handleCTypeToLowerLoc(ExecutionState &state, + KInstruction *target, + std::vector> &) { ref pointerValue = Expr::createPointer( reinterpret_cast(executor.c_type_tolower_addr)); ref result = ConstantPointerExpr::create(pointerValue, pointerValue); executor.bindLocal(target, state, result); } -void SpecialFunctionHandler::handleCTypeToUpperLoc( - ExecutionState &state, KInstruction *target, - std::vector> &arguments) { +void SpecialFunctionHandler::handleCTypeToUpperLoc(ExecutionState &state, + KInstruction *target, + std::vector> &) { ref pointerValue = Expr::createPointer( reinterpret_cast(executor.c_type_toupper_addr)); ref result = ConstantPointerExpr::create(pointerValue, pointerValue); diff --git a/lib/Core/StatsTracker.cpp b/lib/Core/StatsTracker.cpp index b6320e9c81..cc3119109e 100644 --- a/lib/Core/StatsTracker.cpp +++ b/lib/Core/StatsTracker.cpp @@ -11,7 +11,6 @@ #include "ExecutionState.h" -#include "klee/Config/Version.h" #include "klee/Core/TerminationTypes.h" #include "klee/Module/KInstruction.h" #include "klee/Module/KModule.h" @@ -28,25 +27,19 @@ #include "MemoryManager.h" #include "UserSearcher.h" -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS #include "llvm/ADT/SmallBitVector.h" #include "llvm/IR/BasicBlock.h" #include "llvm/IR/CFG.h" #include "llvm/IR/Function.h" #include "llvm/IR/InlineAsm.h" #include "llvm/IR/Instructions.h" -#include "llvm/IR/IntrinsicInst.h" #include "llvm/IR/Module.h" #include "llvm/IR/Type.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/Path.h" #include "llvm/Support/Process.h" -DISABLE_WARNING_POP -#include #include using namespace klee; @@ -463,11 +456,6 @@ void StatsTracker::framePushed(ExecutionState &es, } } -/* Should be called _after_ the es->popFrame() */ -void StatsTracker::framePopped(ExecutionState &es) { - // XXX remove me? -} - void StatsTracker::markBranchVisited(ExecutionState *visitedTrue, ExecutionState *visitedFalse) { if (OutputIStats) { diff --git a/lib/Core/StatsTracker.h b/lib/Core/StatsTracker.h index 52a85d560c..7ed10a830d 100644 --- a/lib/Core/StatsTracker.h +++ b/lib/Core/StatsTracker.h @@ -14,7 +14,6 @@ #include "klee/System/Time.h" #include -#include #include namespace llvm { @@ -80,9 +79,6 @@ class StatsTracker { // called after a new StackFrame has been pushed (for callpath tracing) void framePushed(ExecutionState &es, InfoStackFrame *parentFrame); - // called after a StackFrame has been popped - void framePopped(ExecutionState &es); - // called when some side of a branch has been visited. it is // imperative that this be called when the statistics index is at // the index for the branch itself. diff --git a/lib/Core/TargetCalculator.cpp b/lib/Core/TargetCalculator.cpp index 61fdcef5fa..f71540e3bc 100644 --- a/lib/Core/TargetCalculator.cpp +++ b/lib/Core/TargetCalculator.cpp @@ -15,6 +15,8 @@ #include "klee/Module/KInstruction.h" #include "klee/Module/Target.h" #include "klee/Module/TargetHash.h" +#include "klee/Support/CompilerWarning.h" +#include "klee/Support/OptionCategories.h" #include #include @@ -33,8 +35,6 @@ llvm::cl::opt TrackCoverage( cl::init(TrackCoverageBy::None), cl::cat(ExecCat)); void TargetCalculator::update(const ExecutionState &state) { - Function *initialFunction = state.getInitPCBlock()->getParent(); - if (state.prevPC == state.prevPC->parent->getLastInstruction() && !fullyCoveredFunctions.count(state.pc->parent->parent)) { auto &fBranches = getCoverageTargets(state.pc->parent->parent); @@ -160,11 +160,11 @@ TargetCalculator::getCoverageTargets(KFunction *kf) { case TrackCoverageBy::Branches: return codeGraphInfo.getFunctionConditionalBranches(kf); case TrackCoverageBy::None: + [[fallthrough]]; case TrackCoverageBy::All: return codeGraphInfo.getFunctionBranches(kf); - default: - assert(0 && "not implemented"); + unreachable(); } } diff --git a/lib/Core/TargetCalculator.h b/lib/Core/TargetCalculator.h index 16a9a5350e..6d54ef666b 100644 --- a/lib/Core/TargetCalculator.h +++ b/lib/Core/TargetCalculator.h @@ -12,23 +12,9 @@ #include "ObjectManager.h" -#include "klee/ADT/RNG.h" #include "klee/Module/KModule.h" -#include "klee/Module/Target.h" #include "klee/Module/TargetHash.h" -#include "klee/Support/OptionCategories.h" -#include "klee/System/Time.h" - -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS -#include "llvm/Support/Casting.h" -#include "llvm/Support/CommandLine.h" -#include "llvm/Support/raw_ostream.h" -DISABLE_WARNING_POP - -#include -#include + #include #include #include diff --git a/lib/Core/TargetManager.cpp b/lib/Core/TargetManager.cpp index 50a6c5e486..b91226d7a8 100644 --- a/lib/Core/TargetManager.cpp +++ b/lib/Core/TargetManager.cpp @@ -51,7 +51,7 @@ void TargetManager::updateMiss(ExecutionState &state, ref target) { } } -void TargetManager::updateContinue(ExecutionState &state, ref target) {} +void TargetManager::updateContinue(ExecutionState &, ref) {} void TargetManager::updateDone(ExecutionState &state, ref target) { auto &stateTargetForest = targetForest(state); diff --git a/lib/Core/TargetManager.h b/lib/Core/TargetManager.h index c045c013d2..c0561787ba 100644 --- a/lib/Core/TargetManager.h +++ b/lib/Core/TargetManager.h @@ -17,7 +17,6 @@ #include "klee/Core/Interpreter.h" #include "klee/Module/TargetHash.h" -#include #include #ifndef KLEE_TARGETMANAGER_H diff --git a/lib/Core/TargetedExecutionManager.h b/lib/Core/TargetedExecutionManager.h index 9d787d724e..694dc70005 100644 --- a/lib/Core/TargetedExecutionManager.h +++ b/lib/Core/TargetedExecutionManager.h @@ -17,7 +17,6 @@ #include "ObjectManager.h" #include "klee/Core/TargetedExecutionReporter.h" #include "klee/Module/KModule.h" -#include "klee/Module/Target.h" #include "klee/Module/TargetForest.h" #include diff --git a/lib/Core/TimingSolver.cpp b/lib/Core/TimingSolver.cpp index 9f05dc9f83..9eab1295a2 100644 --- a/lib/Core/TimingSolver.cpp +++ b/lib/Core/TimingSolver.cpp @@ -11,7 +11,6 @@ #include "ExecutionState.h" -#include "klee/Config/Version.h" #include "klee/Expr/Constraints.h" #include "klee/Solver/Solver.h" #include "klee/Solver/SolverStats.h" diff --git a/lib/Core/TypeManager.cpp b/lib/Core/TypeManager.cpp index c053d449fa..490ffc3e32 100644 --- a/lib/Core/TypeManager.cpp +++ b/lib/Core/TypeManager.cpp @@ -2,20 +2,15 @@ #include "klee/ADT/Ref.h" #include "klee/Expr/Expr.h" -#include "klee/Expr/ExprHashMap.h" #include "klee/Module/KInstruction.h" #include "klee/Module/KModule.h" #include "klee/Module/KType.h" -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS #include "llvm/IR/DerivedTypes.h" #include "llvm/IR/Instruction.h" #include "llvm/IR/Module.h" #include "llvm/IR/Type.h" #include "llvm/Support/Casting.h" -DISABLE_WARNING_POP #include #include @@ -49,7 +44,7 @@ KType *TypeManager::getWrappedType(llvm::Type *type) { KType *TypeManager::getUnknownType() { return getWrappedType(nullptr); } -KType *TypeManager::handleAlloc(ref size) { return getUnknownType(); } +KType *TypeManager::handleAlloc(ref) { return getUnknownType(); } KType *TypeManager::handleRealloc(KType *type, ref) { return type; } diff --git a/lib/Core/UserSearcher.cpp b/lib/Core/UserSearcher.cpp index cdd9cb09a5..66fb2a6b17 100644 --- a/lib/Core/UserSearcher.cpp +++ b/lib/Core/UserSearcher.cpp @@ -13,14 +13,8 @@ #include "Searcher.h" #include "klee/Core/Interpreter.h" -#include "klee/Support/ErrorHandling.h" -#include "klee/Support/OptionCategories.h" -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS #include "llvm/Support/CommandLine.h" -DISABLE_WARNING_POP using namespace llvm; using namespace klee; diff --git a/lib/Core/UserSearcher.h b/lib/Core/UserSearcher.h index 387c60c4a0..d980a0a668 100644 --- a/lib/Core/UserSearcher.h +++ b/lib/Core/UserSearcher.h @@ -10,12 +10,6 @@ #ifndef KLEE_USERSEARCHER_H #define KLEE_USERSEARCHER_H -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS -#include "llvm/Support/CommandLine.h" -DISABLE_WARNING_POP - namespace klee { class Executor; class Searcher; diff --git a/lib/Expr/APFloatEval.cpp b/lib/Expr/APFloatEval.cpp index b3b7329432..68522036a4 100644 --- a/lib/Expr/APFloatEval.cpp +++ b/lib/Expr/APFloatEval.cpp @@ -7,18 +7,12 @@ // //===----------------------------------------------------------------------===// #include "klee/Utilities/APFloatEval.h" -#include "klee/Config/Version.h" -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS #include "llvm/ADT/APFloat.h" #include "llvm/Support/raw_ostream.h" -DISABLE_WARNING_POP #include #include -#include namespace { void change_to_rounding_mode(llvm::APFloat::roundingMode rm) { diff --git a/lib/Expr/ArrayExprOptimizer.cpp b/lib/Expr/ArrayExprOptimizer.cpp index 405c4b9011..d539a4f1bc 100644 --- a/lib/Expr/ArrayExprOptimizer.cpp +++ b/lib/Expr/ArrayExprOptimizer.cpp @@ -10,7 +10,6 @@ #include "klee/Expr/ArrayExprOptimizer.h" #include "klee/ADT/BitArray.h" -#include "klee/Config/Version.h" #include "klee/Expr/ArrayExprRewriter.h" #include "klee/Expr/ArrayExprVisitor.h" #include "klee/Expr/Assignment.h" @@ -20,12 +19,8 @@ #include "klee/Support/ErrorHandling.h" #include "klee/Support/OptionCategories.h" -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS #include "llvm/ADT/APInt.h" #include "llvm/Support/CommandLine.h" -DISABLE_WARNING_POP #include #include diff --git a/lib/Expr/ArrayExprRewriter.cpp b/lib/Expr/ArrayExprRewriter.cpp index 68eabf8260..cf5edb87e1 100644 --- a/lib/Expr/ArrayExprRewriter.cpp +++ b/lib/Expr/ArrayExprRewriter.cpp @@ -13,15 +13,10 @@ #include "klee/Expr/ArrayExprVisitor.h" #include "klee/Support/Casting.h" -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS #include "llvm/ADT/APInt.h" -DISABLE_WARNING_POP #include #include -#include #include using namespace klee; @@ -90,7 +85,10 @@ ref ExprRewriter::rewrite(const ref &e, const array2idx_ty &arrays, set++; } if (set > 0 && set < size / width) - invert = ((float)set / (float)(size / width)) > 0.5 ? true : false; + invert = (static_cast(set) / (static_cast(size) / + static_cast(width))) > 0.5 + ? true + : false; int start = -1; for (unsigned i = 0; i < size / width; ++i) { if ((!invert && ba.get(i)) || (invert && !ba.get(i))) { diff --git a/lib/Expr/ArrayExprVisitor.cpp b/lib/Expr/ArrayExprVisitor.cpp index 9696d0db94..d0af6e765d 100644 --- a/lib/Expr/ArrayExprVisitor.cpp +++ b/lib/Expr/ArrayExprVisitor.cpp @@ -9,10 +9,6 @@ #include "klee/Expr/ArrayExprVisitor.h" -#include "klee/Support/ErrorHandling.h" - -#include - using namespace klee; //------------------------------ HELPER FUNCTIONS ---------------------------// diff --git a/lib/Expr/Assignment.cpp b/lib/Expr/Assignment.cpp index a17d2ed9fd..28938ff441 100644 --- a/lib/Expr/Assignment.cpp +++ b/lib/Expr/Assignment.cpp @@ -10,7 +10,6 @@ #include "klee/Expr/Assignment.h" #include "klee/ADT/Ref.h" -#include "klee/Expr/Constraints.h" #include "klee/Expr/Symcrete.h" namespace klee { diff --git a/lib/Expr/AssignmentGenerator.cpp b/lib/Expr/AssignmentGenerator.cpp index 0b7a18a9cb..58a4103bd9 100644 --- a/lib/Expr/AssignmentGenerator.cpp +++ b/lib/Expr/AssignmentGenerator.cpp @@ -12,20 +12,12 @@ #include "klee/Expr/Assignment.h" #include "klee/Support/Casting.h" #include "klee/Support/ErrorHandling.h" -#include "klee/klee.h" -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS #include "llvm/ADT/APInt.h" #include "llvm/Support/raw_ostream.h" -DISABLE_WARNING_POP #include #include -#include -#include -#include #include #include diff --git a/lib/Expr/CMakeLists.txt b/lib/Expr/CMakeLists.txt index 6167bbf721..ebaa452e41 100644 --- a/lib/Expr/CMakeLists.txt +++ b/lib/Expr/CMakeLists.txt @@ -38,6 +38,7 @@ target_link_libraries(kleaverExpr PRIVATE ) llvm_config(kleaverExpr "${USE_LLVM_SHARED}" support) -target_include_directories(kleaverExpr PRIVATE ${KLEE_INCLUDE_DIRS} ${LLVM_INCLUDE_DIRS}) +target_include_directories(kleaverExpr SYSTEM PRIVATE ${LLVM_INCLUDE_DIRS}) +target_include_directories(kleaverExpr PRIVATE ${KLEE_INCLUDE_DIRS}) target_compile_options(kleaverExpr PRIVATE ${KLEE_COMPONENT_CXX_FLAGS}) target_compile_definitions(kleaverExpr PRIVATE ${KLEE_COMPONENT_CXX_DEFINES}) diff --git a/lib/Expr/Constraints.cpp b/lib/Expr/Constraints.cpp index acf0aa4da3..15e9658aac 100644 --- a/lib/Expr/Constraints.cpp +++ b/lib/Expr/Constraints.cpp @@ -9,7 +9,6 @@ #include "klee/Expr/Constraints.h" -#include "klee/Expr/ArrayExprVisitor.h" #include "klee/Expr/Assignment.h" #include "klee/Expr/Expr.h" #include "klee/Expr/ExprHashMap.h" @@ -22,16 +21,11 @@ #include "klee/Expr/SymbolicSource.h" #include "klee/Expr/Symcrete.h" #include "klee/Module/KModule.h" +#include "klee/Support/CompilerWarning.h" #include "klee/Support/OptionCategories.h" -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS #include "llvm/IR/Function.h" #include "llvm/Support/CommandLine.h" -DISABLE_WARNING_POP - -#include using namespace klee; @@ -152,6 +146,7 @@ class ExprReplaceVisitor2 : public ExprVisitor { } default: assert(0 && "unreachable"); + unreachable(); } } else { return source; @@ -186,7 +181,7 @@ class ExprReplaceVisitor2 : public ExprVisitor { return UpdateList(root, updates[0]); } - Action visitRead(const ReadExpr &re) override { return Action::doChildren(); } + Action visitRead(const ReadExpr &) override { return Action::doChildren(); } public: ExprHashSet replacementDependency; @@ -403,7 +398,7 @@ void PathConstraints::advancePath(KInstruction *ki) { _path.advance(ki); } ExprHashSet PathConstraints::addConstraint(ref e, Path::PathIndex currIndex) { auto expr = Simplificator::simplifyExpr(constraints, e); - if (auto ce = dyn_cast(expr.simplified)) { + if (auto ce [[maybe_unused]] = dyn_cast(expr.simplified)) { assert(ce->isTrue() && "Attempt to add invalid constraint"); return {}; } @@ -411,7 +406,7 @@ ExprHashSet PathConstraints::addConstraint(ref e, std::vector> exprs; Expr::splitAnds(expr.simplified, exprs); for (auto expr : exprs) { - if (auto ce = dyn_cast(expr)) { + if (auto ce [[maybe_unused]] = dyn_cast(expr)) { assert(ce->isTrue() && "Expression simplified to false"); } else { _original.insert(expr); diff --git a/lib/Expr/Expr.cpp b/lib/Expr/Expr.cpp index e346587843..cdceea707c 100644 --- a/lib/Expr/Expr.cpp +++ b/lib/Expr/Expr.cpp @@ -16,25 +16,20 @@ #include "klee/Expr/SourceBuilder.h" #include "klee/Expr/SymbolicSource.h" #include "klee/Support/ErrorHandling.h" -#include "klee/Support/OptionCategories.h" #include "klee/Support/RoundingModeUtil.h" #include "klee/Utilities/APFloatEval.h" -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS #include "llvm/ADT/APFloat.h" +#include "llvm/ADT/APSInt.h" #include "llvm/ADT/ArrayRef.h" -#include "llvm/ADT/Hashing.h" #if LLVM_VERSION_CODE >= LLVM_VERSION(13, 0) #include "llvm/ADT/StringExtras.h" #endif #include "llvm/Support/CommandLine.h" #include "llvm/Support/raw_ostream.h" -DISABLE_WARNING_POP +#include #include -#include #include using namespace klee; @@ -676,6 +671,7 @@ void ConstantExpr::toMemory(void *address) { case Expr::Int256: case Expr::Int512: memcpy(address, value.getRawData(), width / 8); + break; // FIXME: what about machines without x87 support? case Expr::Fl80: *((long double *)address) = *(const long double *)value.getRawData(); @@ -698,7 +694,6 @@ void ConstantExpr::toString(std::string &Res, unsigned radix) const { } case 16: { // Emit C99 Hex float - unsigned count = 0; // Example format is -0x1.000p+4 // The total number of characters needed is approximately // @@ -772,7 +767,7 @@ bool shouldTryNativex87Eval(const ConstantExpr *lhs, const ConstantExpr *rhs) { // Workaround this by evaulating natively if possible. ref TryNativeX87FP80EvalCmp(const ConstantExpr *lhs, const ConstantExpr *rhs, - Expr::Kind op) { + [[maybe_unused]] Expr::Kind op) { if (!shouldTryNativex87Eval(lhs, rhs)) return nullptr; @@ -809,10 +804,10 @@ ref TryNativeX87FP80EvalCmp(const ConstantExpr *lhs, #endif } -ref TryNativeX87FP80EvalArith(const ConstantExpr *lhs, - const ConstantExpr *rhs, - Expr::Kind op, - llvm::APFloat::roundingMode rm) { +ref +TryNativeX87FP80EvalArith(const ConstantExpr *lhs, const ConstantExpr *rhs, + [[maybe_unused]] Expr::Kind op, + [[maybe_unused]] llvm::APFloat::roundingMode rm) { if (!shouldTryNativex87Eval(lhs, rhs)) return NULL; #ifdef __x86_64__ @@ -879,9 +874,11 @@ ref TryNativeX87FP80EvalArith(const ConstantExpr *lhs, #endif } -ref TryNativeX87FP80EvalCast(const ConstantExpr *ce, - Expr::Width outWidth, Expr::Kind op, - llvm::APFloat::roundingMode rm) { +ref +TryNativeX87FP80EvalCast(const ConstantExpr *ce, + [[maybe_unused]] Expr::Width outWidth, + [[maybe_unused]] Expr::Kind op, + [[maybe_unused]] llvm::APFloat::roundingMode rm) { if (!shouldTryNativex87Eval(ce, ce)) return NULL; #ifdef __x86_64__ @@ -1179,7 +1176,7 @@ ref ConstantExpr::GetNaN(Expr::Width w) { // These values have been chosen to be consistent with Z3 when // rewriter.hi_fp_unspecified=false llvm::APInt apint; - const llvm::fltSemantics *sem; + [[maybe_unused]] const llvm::fltSemantics *sem; switch (w) { case Int16: { apint = llvm::APInt(/*numBits=*/16, (uint64_t)0x7c01, /*isSigned=*/false); @@ -1212,6 +1209,10 @@ ref ConstantExpr::GetNaN(Expr::Width w) { sem = &(LLVMFltSemantics(IEEEquad)); break; } + default: { + assert(false && "unexpected value for GetNaN"); + unreachable(); + } } #ifndef NDEBUG // Make an APFloat from the bits and check its a NaN @@ -1582,7 +1583,7 @@ ref ReadExpr::create(const UpdateList &ul, ref index, bool safe) { // So that we return weird stuff like reads from consts that should have // simplified to constant exprs if we read beyond size boundary. - if (ConstantSource *source = dyn_cast(ul.root->source)) { + if (isa(ul.root->source)) { if (auto arraySizeExpr = dyn_cast(ul.root->size)) { if (auto indexExpr = dyn_cast(index)) { auto arraySize = arraySizeExpr->getZExtValue(); diff --git a/lib/Expr/ExprPPrinter.cpp b/lib/Expr/ExprPPrinter.cpp index 035eaa3a56..42ebb95985 100644 --- a/lib/Expr/ExprPPrinter.cpp +++ b/lib/Expr/ExprPPrinter.cpp @@ -16,12 +16,8 @@ #include "klee/Module/KModule.h" #include "klee/Support/PrintContext.h" -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS #include "llvm/Support/CommandLine.h" #include "llvm/Support/raw_ostream.h" -DISABLE_WARNING_POP #include #include @@ -275,7 +271,7 @@ class PPrinter : public ExprPPrinter { printUpdateList(re->updates, PC); } - void printExtract(const ExtractExpr *ee, PrintContext &PC, unsigned indent) { + void printExtract(const ExtractExpr *ee, PrintContext &PC) { PC << ee->offset << ' '; print(ee->expr, PC); } @@ -466,7 +462,7 @@ class PPrinter : public ExprPPrinter { if (const ReadExpr *re = dyn_cast(e)) { printRead(re, PC, indent); } else if (const ExtractExpr *ee = dyn_cast(e)) { - printExtract(ee, PC, indent); + printExtract(ee, PC); } else if (e->getKind() == Expr::Concat || e->getKind() == Expr::SExt) printExpr(e.get(), PC, indent, true); else diff --git a/lib/Expr/ExprSMTLIBPrinter.cpp b/lib/Expr/ExprSMTLIBPrinter.cpp index 54ab84c139..7cdae6f66a 100644 --- a/lib/Expr/ExprSMTLIBPrinter.cpp +++ b/lib/Expr/ExprSMTLIBPrinter.cpp @@ -11,12 +11,8 @@ #include "klee/Support/Casting.h" #include "klee/Support/ErrorHandling.h" -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS #include "llvm/Support/CommandLine.h" #include "llvm/Support/ErrorHandling.h" -DISABLE_WARNING_POP #include #include diff --git a/lib/Expr/ExprVisitor.cpp b/lib/Expr/ExprVisitor.cpp index 6a564db1f1..bcd9548606 100644 --- a/lib/Expr/ExprVisitor.cpp +++ b/lib/Expr/ExprVisitor.cpp @@ -11,11 +11,7 @@ #include "klee/Expr/Expr.h" -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS #include "llvm/Support/CommandLine.h" -DISABLE_WARNING_POP namespace { llvm::cl::opt UseVisitorHash( diff --git a/lib/Expr/IndependentConstraintSetUnion.cpp b/lib/Expr/IndependentConstraintSetUnion.cpp index b396a567fd..ea0a2edb34 100644 --- a/lib/Expr/IndependentConstraintSetUnion.cpp +++ b/lib/Expr/IndependentConstraintSetUnion.cpp @@ -184,7 +184,7 @@ void IndependentConstraintSetUnion::flushConstraints() { while (!constraintQueue.empty()) { auto constraint = constraintQueue[constraintQueue.size() - 1]; if (auto expr = dyn_cast(constraint)) { - if (auto ce = dyn_cast(expr->value())) { + if (auto ce [[maybe_unused]] = dyn_cast(expr->value())) { assert(ce->isTrue() && "Attempt to add invalid constraint"); constraintQueue.pop_back(); continue; diff --git a/lib/Expr/IndependentSet.cpp b/lib/Expr/IndependentSet.cpp index 74a8aad3ef..28c2e79cd1 100644 --- a/lib/Expr/IndependentSet.cpp +++ b/lib/Expr/IndependentSet.cpp @@ -2,7 +2,6 @@ #include "klee/ADT/Ref.h" #include "klee/Expr/Assignment.h" -#include "klee/Expr/Constraints.h" #include "klee/Expr/ExprHashMap.h" #include "klee/Expr/ExprUtil.h" #include "klee/Expr/IndependentConstraintSetUnion.h" @@ -10,7 +9,6 @@ #include "klee/Expr/Symcrete.h" #include "klee/Module/KModule.h" -#include #include #include #include diff --git a/lib/Expr/Lexer.cpp b/lib/Expr/Lexer.cpp index acbb29b9dc..244501a5f3 100644 --- a/lib/Expr/Lexer.cpp +++ b/lib/Expr/Lexer.cpp @@ -9,14 +9,9 @@ #include "klee/Expr/Parser/Lexer.h" -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/raw_ostream.h" -DISABLE_WARNING_POP -#include #include using namespace llvm; diff --git a/lib/Expr/Parser.cpp b/lib/Expr/Parser.cpp index 524a1265bc..2d3f588bb8 100644 --- a/lib/Expr/Parser.cpp +++ b/lib/Expr/Parser.cpp @@ -19,14 +19,11 @@ #include "klee/Expr/SymbolicSource.h" #include "klee/Module/KInstruction.h" #include "klee/Module/KModule.h" +#include "klee/Support/ErrorHandling.h" -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS #include "llvm/ADT/APInt.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/raw_ostream.h" -DISABLE_WARNING_POP #include #include @@ -159,7 +156,7 @@ class ParserImpl : public Parser { Tok.kind != Token::LSquare && Tok.kind != Token::RSquare); _ConsumeExpectedToken(k); } - void _ConsumeExpectedToken(Token::Kind k) { + void _ConsumeExpectedToken([[maybe_unused]] Token::Kind k) { assert(Tok.kind == k && "Unexpected token!"); GetNextNonCommentToken(); } @@ -296,13 +293,13 @@ class ParserImpl : public Parser { IntegerResult ParseIntegerConstant(Expr::Width Type); ExprResult ParseExpr(TypeResult ExpectedType); - ExprResult ParseParenExpr(TypeResult ExpectedType); + ExprResult ParseParenExpr(); ExprResult ParseUnaryParenExpr(const Token &Name, unsigned Kind, bool IsFixed, Expr::Width ResTy); ExprResult ParseBinaryParenExpr(const Token &Name, unsigned Kind, bool IsFixed, Expr::Width ResTy); ExprResult ParseSelectParenExpr(const Token &Name, Expr::Width ResTy); - ExprResult ParseConcatParenExpr(const Token &Name, Expr::Width ResTy); + ExprResult ParseConcatParenExpr(Expr::Width ResTy); ExprResult ParseExtractParenExpr(const Token &Name, Expr::Width ResTy); ExprResult ParseAnyReadParenExpr(const Token &Name, unsigned Kind, Expr::Width ResTy); @@ -562,7 +559,7 @@ SourceResult ParserImpl::ParseConstantSource() { } SourceResult ParserImpl::ParseSymbolicSizeConstantAddressSource() { - assert(0 && "unimplemented"); + klee_error("unimplemented"); // auto valueExpr = ParseNumber(64).get(); // auto versionExpr = ParseNumber(64).get(); // auto value = dyn_cast(valueExpr); @@ -880,7 +877,7 @@ ExprResult ParserImpl::ParseExpr(TypeResult ExpectedType) { } Token Start = Tok; - ExprResult Res = ParseParenExpr(ExpectedType); + ExprResult Res = ParseParenExpr(); if (!Res.isValid()) { // If we know the type, define the identifier just so we don't get // use-of-undef errors. @@ -1029,7 +1026,7 @@ static bool LookupExprInfo(const Token &Tok, unsigned &Kind, bool &IsFixed, /// paren-expr = '(' type number ')' /// paren-expr = '(' identifier [type] expr+ ') /// paren-expr = '(' ('Read' | 'ReadMSB' | 'ReadLSB') type expr update-list ')' -ExprResult ParserImpl::ParseParenExpr(TypeResult FIXME_UNUSED) { +ExprResult ParserImpl::ParseParenExpr() { if (Tok.kind != Token::LParen) { Error("unexpected token."); ConsumeAnyToken(); @@ -1098,7 +1095,7 @@ ExprResult ParserImpl::ParseParenExpr(TypeResult FIXME_UNUSED) { if (NumArgs == -1) { switch (ExprKind) { case eMacroKind_Concat: - return ParseConcatParenExpr(Name, ResTy); + return ParseConcatParenExpr(ResTy); case Expr::Extract: return ParseExtractParenExpr(Name, ResTy); @@ -1315,8 +1312,7 @@ ExprResult ParserImpl::ParseSelectParenExpr(const Token &Name, } // FIXME: Rewrite to only accept binary form. Make type optional. -ExprResult ParserImpl::ParseConcatParenExpr(const Token &Name, - Expr::Width ResTy) { +ExprResult ParserImpl::ParseConcatParenExpr(Expr::Width ResTy) { std::vector Kids; unsigned Width = 0; diff --git a/lib/Expr/Path.cpp b/lib/Expr/Path.cpp index af5b2f8705..92bb73118c 100644 --- a/lib/Expr/Path.cpp +++ b/lib/Expr/Path.cpp @@ -3,12 +3,8 @@ #include "klee/Module/KInstruction.h" #include "klee/Module/KModule.h" -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS #include "llvm/ADT/StringExtras.h" -#include "llvm/Support/Casting.h" -DISABLE_WARNING_POP +#include using namespace klee; using namespace llvm; @@ -154,7 +150,7 @@ Path::TransitionKind Path::getTransitionKind(KBlock *a, KBlock *b) { return TransitionKind::StepInto; } } - if (auto rb = dyn_cast(a)) { + if (isa(a)) { return TransitionKind::StepOut; } assert(a->parent == b->parent); diff --git a/lib/Expr/SourceBuilder.cpp b/lib/Expr/SourceBuilder.cpp index 383ed3287e..88ace04b37 100644 --- a/lib/Expr/SourceBuilder.cpp +++ b/lib/Expr/SourceBuilder.cpp @@ -85,11 +85,9 @@ ref SourceBuilder::value(const llvm::Value &_allocSite, if (const llvm::Argument *allocSite = dyn_cast(&_allocSite)) { return argument(*allocSite, _index, km); } - if (const llvm::Instruction *allocSite = - dyn_cast(&_allocSite)) { - return instruction(*allocSite, _index, km); - } - assert(0 && "unreachable"); + const llvm::Instruction *allocSite = dyn_cast(&_allocSite); + assert(allocSite && "Invalid allocSite value"); + return instruction(*allocSite, _index, km); } ref SourceBuilder::irreproducible(const std::string &name) { diff --git a/lib/Expr/SymbolicSource.cpp b/lib/Expr/SymbolicSource.cpp index 83e28a9d24..1e1bc628b4 100644 --- a/lib/Expr/SymbolicSource.cpp +++ b/lib/Expr/SymbolicSource.cpp @@ -6,11 +6,8 @@ #include "klee/Module/KModule.h" #include "klee/Module/KValue.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS #include "llvm/IR/BasicBlock.h" #include "llvm/IR/Function.h" -DISABLE_WARNING_POP #include diff --git a/lib/Module/Annotation.cpp b/lib/Module/Annotation.cpp index c4e5173410..1e5e6c19f5 100644 --- a/lib/Module/Annotation.cpp +++ b/lib/Module/Annotation.cpp @@ -7,17 +7,16 @@ //===----------------------------------------------------------------------===// #include "klee/Module/Annotation.h" +#include "klee/Support/CompilerWarning.h" #include "klee/Support/ErrorHandling.h" -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS #include -DISABLE_WARNING_POP #include "nlohmann/json.hpp" #include +#include +#include namespace klee { @@ -167,6 +166,8 @@ Ptr stringToKindPtr(const std::string &str) { return std::make_shared(str); case Statement::Kind::Free: return std::make_shared(str); + default: + unreachable(); } } diff --git a/lib/Module/CMakeLists.txt b/lib/Module/CMakeLists.txt index 65cccdcc68..3f7651fb44 100644 --- a/lib/Module/CMakeLists.txt +++ b/lib/Module/CMakeLists.txt @@ -59,6 +59,8 @@ llvm_config(kleeModule "${USE_LLVM_SHARED}" target_link_libraries(kleeModule PRIVATE kleeSupport ) -target_include_directories(kleeModule PRIVATE ${KLEE_INCLUDE_DIRS} ${LLVM_INCLUDE_DIRS}) + +target_include_directories(kleeModule SYSTEM PRIVATE ${LLVM_INCLUDE_DIRS}) +target_include_directories(kleeModule PRIVATE ${KLEE_INCLUDE_DIRS}) target_compile_options(kleeModule PRIVATE ${KLEE_COMPONENT_CXX_FLAGS}) target_compile_definitions(kleeModule PRIVATE ${KLEE_COMPONENT_CXX_DEFINES}) diff --git a/lib/Module/CallRemover.cpp b/lib/Module/CallRemover.cpp index 7c94f6d26e..4cbd1f2d92 100644 --- a/lib/Module/CallRemover.cpp +++ b/lib/Module/CallRemover.cpp @@ -8,7 +8,6 @@ //===----------------------------------------------------------------------===// #include "Passes.h" -#include namespace klee { diff --git a/lib/Module/CallSplitter.cpp b/lib/Module/CallSplitter.cpp index a90e17516d..0a33411e5d 100644 --- a/lib/Module/CallSplitter.cpp +++ b/lib/Module/CallSplitter.cpp @@ -9,14 +9,9 @@ #include "Passes.h" -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS #include "llvm/IR/Function.h" #include "llvm/IR/Instruction.h" -#include "llvm/IR/Module.h" #include "llvm/Transforms/Utils/BasicBlockUtils.h" -DISABLE_WARNING_POP using namespace llvm; diff --git a/lib/Module/Checks.cpp b/lib/Module/Checks.cpp index fc639754ef..1262556254 100644 --- a/lib/Module/Checks.cpp +++ b/lib/Module/Checks.cpp @@ -9,13 +9,8 @@ #include "Passes.h" -#include "klee/Config/Version.h" - #include "KLEEIRMetaData.h" -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS #include "llvm/IR/Constants.h" #include "llvm/IR/DataLayout.h" #include "llvm/IR/DerivedTypes.h" @@ -24,14 +19,11 @@ DISABLE_WARNING_DEPRECATED_DECLARATIONS #include "llvm/IR/InstrTypes.h" #include "llvm/IR/Instruction.h" #include "llvm/IR/Instructions.h" -#include "llvm/IR/IntrinsicInst.h" #include "llvm/IR/LLVMContext.h" #include "llvm/IR/Module.h" #include "llvm/IR/Type.h" #include "llvm/Pass.h" -#include "llvm/Transforms/Scalar.h" #include "llvm/Transforms/Utils/BasicBlockUtils.h" -DISABLE_WARNING_POP using namespace llvm; using namespace klee; diff --git a/lib/Module/CodeGraphInfo.cpp b/lib/Module/CodeGraphInfo.cpp index b2c4393983..d32e36f6b1 100644 --- a/lib/Module/CodeGraphInfo.cpp +++ b/lib/Module/CodeGraphInfo.cpp @@ -12,11 +12,7 @@ #include "klee/Module/KModule.h" -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS #include "llvm/IR/CFG.h" -DISABLE_WARNING_POP #include #include diff --git a/lib/Module/FunctionAlias.cpp b/lib/Module/FunctionAlias.cpp index 04afffff5d..aa80b35d6e 100644 --- a/lib/Module/FunctionAlias.cpp +++ b/lib/Module/FunctionAlias.cpp @@ -13,13 +13,9 @@ #include "klee/Support/ErrorHandling.h" #include "klee/Support/OptionCategories.h" -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS #include "llvm/IR/GlobalAlias.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/Regex.h" -DISABLE_WARNING_POP using namespace llvm; diff --git a/lib/Module/InstructionOperandTypeCheckPass.cpp b/lib/Module/InstructionOperandTypeCheckPass.cpp index 3c836afc32..b28a2a34d0 100644 --- a/lib/Module/InstructionOperandTypeCheckPass.cpp +++ b/lib/Module/InstructionOperandTypeCheckPass.cpp @@ -7,14 +7,9 @@ // //===----------------------------------------------------------------------===// #include "Passes.h" -#include "klee/Config/Version.h" #include "klee/Support/ErrorHandling.h" -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS #include "llvm/Support/raw_ostream.h" -DISABLE_WARNING_POP using namespace llvm; diff --git a/lib/Module/IntrinsicCleaner.cpp b/lib/Module/IntrinsicCleaner.cpp index 43a4b23dab..5bb9f021f5 100644 --- a/lib/Module/IntrinsicCleaner.cpp +++ b/lib/Module/IntrinsicCleaner.cpp @@ -12,28 +12,21 @@ #include "klee/Config/Version.h" #include "klee/Support/ErrorHandling.h" -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS #include "llvm/Analysis/ConstantFolding.h" #include "llvm/Analysis/MemoryBuiltins.h" #include "llvm/IR/Constants.h" #include "llvm/IR/DerivedTypes.h" #include "llvm/IR/Function.h" #include "llvm/IR/IRBuilder.h" -#include "llvm/IR/InstrTypes.h" #include "llvm/IR/Instruction.h" #include "llvm/IR/Instructions.h" #include "llvm/IR/IntrinsicInst.h" -#if LLVM_VERSION_CODE >= LLVM_VERSION(10, 0) -#include "llvm/IR/IntrinsicsX86.h" -#endif #include "llvm/IR/Module.h" #include "llvm/IR/Type.h" #include "llvm/Pass.h" #include "llvm/Transforms/Scalar.h" #include "llvm/Transforms/Utils/BasicBlockUtils.h" -DISABLE_WARNING_POP + using namespace llvm; namespace klee { diff --git a/lib/Module/KInstruction.cpp b/lib/Module/KInstruction.cpp index 2c480feef2..f8dc7d0876 100644 --- a/lib/Module/KInstruction.cpp +++ b/lib/Module/KInstruction.cpp @@ -11,14 +11,9 @@ #include "klee/Module/KModule.h" #include "klee/Module/LocationInfo.h" -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS #include "llvm/ADT/StringExtras.h" -#include "llvm/IR/DebugInfoMetadata.h" #include #include -DISABLE_WARNING_POP #include diff --git a/lib/Module/KLEEIRMetaData.h b/lib/Module/KLEEIRMetaData.h index edf6a45bee..6d85bb1de0 100644 --- a/lib/Module/KLEEIRMetaData.h +++ b/lib/Module/KLEEIRMetaData.h @@ -10,11 +10,9 @@ #ifndef KLEE_KLEEIRMETADATA_H #define KLEE_KLEEIRMETADATA_H -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS #include "llvm/IR/MDBuilder.h" -DISABLE_WARNING_POP +#include +#include namespace klee { diff --git a/lib/Module/KModule.cpp b/lib/Module/KModule.cpp index fcbd57baa2..b1e18690bf 100644 --- a/lib/Module/KModule.cpp +++ b/lib/Module/KModule.cpp @@ -11,9 +11,7 @@ #include "Passes.h" -#include "klee/Config/Version.h" #include "klee/Core/Interpreter.h" -#include "klee/Module/Cell.h" #include "klee/Module/KInstruction.h" #include "klee/Module/KModule.h" #include "klee/Module/LocationInfo.h" @@ -22,9 +20,6 @@ #include "klee/Support/ModuleUtil.h" #include "klee/Support/OptionCategories.h" -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS #include "llvm/Bitcode/BitcodeWriter.h" #include "llvm/IR/AssemblyAnnotationWriter.h" #include "llvm/IR/CFG.h" @@ -40,17 +35,13 @@ DISABLE_WARNING_DEPRECATED_DECLARATIONS #include "llvm/Linker/Linker.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/FormattedStream.h" -#include "llvm/Support/Path.h" -#include "llvm/Support/raw_os_ostream.h" #include "llvm/Support/raw_ostream.h" #include "llvm/Transforms/Scalar.h" #include "llvm/Transforms/Scalar/Scalarizer.h" #include "llvm/Transforms/Utils.h" #include "llvm/Transforms/Utils/Cloning.h" -DISABLE_WARNING_POP #include -#include #include using namespace llvm; @@ -686,8 +677,8 @@ KBlock::KBlock( const std::unordered_map &instructionToRegisterMap, KInstruction **instructionsKF, unsigned &globalIndexInc, KBlockType blockType) - : KValue(block, KValue::Kind::BLOCK), blockKind(blockType), - parent(_kfunction) { + : KValue(block, KValue::Kind::BLOCK), parent(_kfunction), + blockKind(blockType) { instructions = instructionsKF; for (auto &it : *block) { diff --git a/lib/Module/KType.cpp b/lib/Module/KType.cpp index dea8be27ca..8642ae3248 100644 --- a/lib/Module/KType.cpp +++ b/lib/Module/KType.cpp @@ -4,15 +4,8 @@ #include "klee/Expr/Expr.h" #include "klee/Module/KModule.h" -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS -#include "llvm/IR/DataLayout.h" -#include "llvm/IR/DerivedTypes.h" #include "llvm/IR/Type.h" -#include "llvm/Support/Casting.h" #include "llvm/Support/raw_ostream.h" -DISABLE_WARNING_POP using namespace klee; using namespace llvm; @@ -24,13 +17,13 @@ KType::KType(llvm::Type *type, TypeManager *parent) innerTypes[this].insert(0); } -bool KType::isAccessableFrom(KType *accessingType) const { return true; } +bool KType::isAccessableFrom(KType *) const { return true; } llvm::Type *KType::getRawType() const { return type; } TypeSystemKind KType::getTypeSystemKind() const { return typeSystemKind; } -void KType::handleMemoryAccess(KType *, ref, ref, bool isWrite) {} +void KType::handleMemoryAccess(KType *, ref, ref, bool) {} size_t KType::getSize() const { return typeStoreSize; } diff --git a/lib/Module/KValue.cpp b/lib/Module/KValue.cpp index d506e612e2..e5a851e1e2 100644 --- a/lib/Module/KValue.cpp +++ b/lib/Module/KValue.cpp @@ -1,14 +1,7 @@ #include "klee/Module/KValue.h" -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS #include "llvm/ADT/StringRef.h" #include "llvm/IR/Value.h" -DISABLE_WARNING_POP - -#include -#include using namespace klee; diff --git a/lib/Module/LocalVarDeclarationFinderPass.cpp b/lib/Module/LocalVarDeclarationFinderPass.cpp index ec8ec45e53..08d86a3c7d 100644 --- a/lib/Module/LocalVarDeclarationFinderPass.cpp +++ b/lib/Module/LocalVarDeclarationFinderPass.cpp @@ -8,17 +8,12 @@ //===----------------------------------------------------------------------===// #include "Passes.h" -#include "klee/Support/CompilerWarning.h" - -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS #include "llvm/IR/BasicBlock.h" #include "llvm/IR/Function.h" #include "llvm/IR/Instruction.h" #include "llvm/IR/IntrinsicInst.h" #include "llvm/IR/Value.h" #include "llvm/Support/Casting.h" -DISABLE_WARNING_POP using namespace klee; diff --git a/lib/Module/LocationInfo.cpp b/lib/Module/LocationInfo.cpp index 3f7a3ee845..dec8d317d5 100644 --- a/lib/Module/LocationInfo.cpp +++ b/lib/Module/LocationInfo.cpp @@ -10,21 +10,14 @@ #include "klee/Module/LocationInfo.h" #include "klee/Module/SarifReport.h" -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS #include "llvm/ADT/SmallVector.h" #include "llvm/Analysis/ValueTracking.h" #include "llvm/IR/AssemblyAnnotationWriter.h" #include "llvm/IR/DebugInfoMetadata.h" #include "llvm/IR/Function.h" -#include "llvm/IR/Instructions.h" #include "llvm/IR/LLVMContext.h" -#include "llvm/IR/Module.h" -#include "llvm/Support/FormattedStream.h" -DISABLE_WARNING_POP +#include -#include #include namespace klee { diff --git a/lib/Module/LowerSwitch.cpp b/lib/Module/LowerSwitch.cpp index 2f614f1d8c..a71f8bf4e2 100644 --- a/lib/Module/LowerSwitch.cpp +++ b/lib/Module/LowerSwitch.cpp @@ -15,14 +15,9 @@ //===----------------------------------------------------------------------===// #include "Passes.h" -#include "klee/Config/Version.h" -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS #include "llvm/IR/IRBuilder.h" #include "llvm/IR/LLVMContext.h" -DISABLE_WARNING_POP #include diff --git a/lib/Module/ModuleUtil.cpp b/lib/Module/ModuleUtil.cpp index 4a6c6bf77e..fa29bdd7e4 100644 --- a/lib/Module/ModuleUtil.cpp +++ b/lib/Module/ModuleUtil.cpp @@ -9,13 +9,9 @@ #include "klee/Support/ModuleUtil.h" -#include "klee/Config/Version.h" #include "klee/Support/Debug.h" #include "klee/Support/ErrorHandling.h" -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS #include "llvm/Analysis/CallGraph.h" #include "llvm/Analysis/ValueTracking.h" #include "llvm/BinaryFormat/Magic.h" @@ -24,8 +20,6 @@ DISABLE_WARNING_DEPRECATED_DECLARATIONS #include "llvm/IR/DiagnosticInfo.h" #include "llvm/IR/DiagnosticPrinter.h" #include "llvm/IR/Function.h" -#include "llvm/IR/Instructions.h" -#include "llvm/IR/IntrinsicInst.h" #include "llvm/IR/LLVMContext.h" #include "llvm/IR/Module.h" #include "llvm/IR/ValueSymbolTable.h" @@ -33,111 +27,15 @@ DISABLE_WARNING_DEPRECATED_DECLARATIONS #include "llvm/Linker/Linker.h" #include "llvm/Object/Archive.h" #include "llvm/Object/Error.h" -#include "llvm/Object/ObjectFile.h" -#include "llvm/Support/FileSystem.h" #include "llvm/Support/MemoryBuffer.h" -#include "llvm/Support/Path.h" #include "llvm/Support/SourceMgr.h" -DISABLE_WARNING_POP -#include -#include -#include -#include -#include #include #include using namespace llvm; using namespace klee; -/// Based on GetAllUndefinedSymbols() from LLVM3.2 -/// -/// GetAllUndefinedSymbols - calculates the set of undefined symbols that still -/// exist in an LLVM module. This is a bit tricky because there may be two -/// symbols with the same name but different LLVM types that will be resolved to -/// each other but aren't currently (thus we need to treat it as resolved). -/// -/// Inputs: -/// M - The module in which to find undefined symbols. -/// -/// Outputs: -/// UndefinedSymbols - A set of C++ strings containing the name of all -/// undefined symbols. -/// -static void GetAllUndefinedSymbols(Module *M, - std::set &UndefinedSymbols) { - static const std::string llvmIntrinsicPrefix = "llvm."; - std::set DefinedSymbols; - UndefinedSymbols.clear(); - KLEE_DEBUG_WITH_TYPE("klee_linker", - dbgs() << "*** Computing undefined symbols for " - << M->getModuleIdentifier() << " ***\n"); - - for (auto const &Function : *M) { - if (Function.hasName()) { - if (Function.isDeclaration()) - UndefinedSymbols.insert(Function.getName().str()); - else if (!Function.hasLocalLinkage()) { - assert(!Function.hasDLLImportStorageClass() && - "Found dllimported non-external symbol!"); - DefinedSymbols.insert(Function.getName().str()); - } - } - } - - for (Module::const_global_iterator I = M->global_begin(), E = M->global_end(); - I != E; ++I) - if (I->hasName()) { - if (I->isDeclaration()) - UndefinedSymbols.insert(I->getName().str()); - else if (!I->hasLocalLinkage()) { - assert(!I->hasDLLImportStorageClass() && - "Found dllimported non-external symbol!"); - DefinedSymbols.insert(I->getName().str()); - } - } - - for (Module::const_alias_iterator I = M->alias_begin(), E = M->alias_end(); - I != E; ++I) - if (I->hasName()) - DefinedSymbols.insert(I->getName().str()); - - // Prune out any defined symbols from the undefined symbols set - // and other symbols we don't want to treat as an undefined symbol - std::vector SymbolsToRemove; - for (std::set::iterator I = UndefinedSymbols.begin(); - I != UndefinedSymbols.end(); ++I) { - if (DefinedSymbols.find(*I) != DefinedSymbols.end()) { - SymbolsToRemove.push_back(*I); - continue; - } - - // Strip out llvm intrinsics - if ((I->size() >= llvmIntrinsicPrefix.size()) && - (I->compare(0, llvmIntrinsicPrefix.size(), llvmIntrinsicPrefix) == 0)) { - KLEE_DEBUG_WITH_TYPE( - "klee_linker", dbgs() << "LLVM intrinsic " << *I - << " has will be removed from undefined symbols" - << "\n"); - SymbolsToRemove.push_back(*I); - continue; - } - - // Symbol really is undefined - KLEE_DEBUG_WITH_TYPE("klee_linker", - dbgs() << "Symbol " << *I << " is undefined.\n"); - } - - // Now remove the symbols from undefined set. - for (auto const &symbol : SymbolsToRemove) - UndefinedSymbols.erase(symbol); - - KLEE_DEBUG_WITH_TYPE("klee_linker", - dbgs() - << "*** Finished computing undefined symbols ***\n"); -} - bool klee::linkModules(llvm::Module *composite, std::vector> &modules, const unsigned flags, std::string &errorMsg) { diff --git a/lib/Module/OptNone.cpp b/lib/Module/OptNone.cpp index 6e57090103..6cc01adf14 100644 --- a/lib/Module/OptNone.cpp +++ b/lib/Module/OptNone.cpp @@ -9,16 +9,10 @@ #include "Passes.h" -#include "klee/Config/Version.h" - -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS #include "llvm/ADT/SmallPtrSet.h" #include "llvm/IR/Function.h" #include "llvm/IR/Instruction.h" #include "llvm/IR/Module.h" -DISABLE_WARNING_POP namespace klee { diff --git a/lib/Module/Optimize.cpp b/lib/Module/Optimize.cpp index e087ed2208..2db77d17e5 100644 --- a/lib/Module/Optimize.cpp +++ b/lib/Module/Optimize.cpp @@ -17,11 +17,7 @@ #include "klee/Config/Version.h" #include "klee/Support/OptionCategories.h" -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS #include "llvm/Analysis/GlobalsModRef.h" -#include "llvm/Analysis/LoopPass.h" #include "llvm/Analysis/Passes.h" #include "llvm/IR/DataLayout.h" #include "llvm/IR/LegacyPassManager.h" @@ -29,7 +25,6 @@ DISABLE_WARNING_DEPRECATED_DECLARATIONS #include "llvm/IR/Verifier.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/DynamicLibrary.h" -#include "llvm/Support/PluginLoader.h" #include "llvm/Target/TargetMachine.h" #include "llvm/Transforms/IPO.h" #include "llvm/Transforms/IPO/FunctionAttrs.h" @@ -37,7 +32,6 @@ DISABLE_WARNING_DEPRECATED_DECLARATIONS #include "llvm/Transforms/Scalar.h" #include "llvm/Transforms/Scalar/GVN.h" #include "llvm/Transforms/Utils.h" -DISABLE_WARNING_POP using namespace llvm; diff --git a/lib/Module/Passes.h b/lib/Module/Passes.h index 432f030a51..7e7bc33f38 100644 --- a/lib/Module/Passes.h +++ b/lib/Module/Passes.h @@ -10,18 +10,11 @@ #ifndef KLEE_PASSES_H #define KLEE_PASSES_H -#include "klee/Config/Version.h" - -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS #include "llvm/ADT/Triple.h" #include "llvm/CodeGen/IntrinsicLowering.h" -#include "llvm/IR/Constants.h" #include "llvm/IR/Instructions.h" #include "llvm/IR/Module.h" #include "llvm/Pass.h" -DISABLE_WARNING_POP namespace llvm { class Function; @@ -49,7 +42,7 @@ class RaiseAsmPass : public llvm::ModulePass { return getIntrinsic(M, IID, &Ty0, 1); } - bool runOnInstruction(llvm::Module &M, llvm::Instruction *I); + bool runOnInstruction(llvm::Instruction *I); public: RaiseAsmPass() : llvm::ModulePass(ID), TLI(0) {} diff --git a/lib/Module/RaiseAsm.cpp b/lib/Module/RaiseAsm.cpp index 09ace7f323..6869ab2b85 100644 --- a/lib/Module/RaiseAsm.cpp +++ b/lib/Module/RaiseAsm.cpp @@ -11,9 +11,6 @@ #include "klee/Config/Version.h" #include "klee/Support/ErrorHandling.h" -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS #include "llvm/CodeGen/TargetLowering.h" #include "llvm/CodeGen/TargetSubtargetInfo.h" #include "llvm/IR/Function.h" @@ -28,7 +25,6 @@ DISABLE_WARNING_DEPRECATED_DECLARATIONS #include "llvm/Support/TargetRegistry.h" #endif #include "llvm/Target/TargetMachine.h" -DISABLE_WARNING_POP using namespace llvm; using namespace klee; @@ -43,7 +39,7 @@ Function *RaiseAsmPass::getIntrinsic(llvm::Module &M, unsigned IID, Type **Tys, // FIXME: This should just be implemented as a patch to // X86TargetAsmInfo.cpp, then everyone will benefit. -bool RaiseAsmPass::runOnInstruction(Module &M, Instruction *I) { +bool RaiseAsmPass::runOnInstruction(Instruction *I) { // We can just raise inline assembler using calls CallInst *ci = dyn_cast(I); if (!ci) @@ -108,7 +104,7 @@ bool RaiseAsmPass::runOnModule(Module &M) { for (BasicBlock::iterator ii = bi->begin(), ie = bi->end(); ii != ie;) { Instruction *i = &*ii; ++ii; - changed |= runOnInstruction(M, i); + changed |= runOnInstruction(i); } } } diff --git a/lib/Module/ReturnLocationFinderPass.cpp b/lib/Module/ReturnLocationFinderPass.cpp index 77c79ec4ae..1a75c4e528 100644 --- a/lib/Module/ReturnLocationFinderPass.cpp +++ b/lib/Module/ReturnLocationFinderPass.cpp @@ -8,10 +8,6 @@ //===----------------------------------------------------------------------===// #include "Passes.h" -#include "klee/Support/CompilerWarning.h" - -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS #include "llvm/IR/BasicBlock.h" #include "llvm/IR/CFG.h" #include "llvm/IR/Constant.h" @@ -20,9 +16,6 @@ DISABLE_WARNING_DEPRECATED_DECLARATIONS #include "llvm/IR/Instructions.h" #include "llvm/IR/Metadata.h" #include "llvm/Support/Casting.h" -DISABLE_WARNING_POP - -#include using namespace klee; diff --git a/lib/Module/ReturnSplitter.cpp b/lib/Module/ReturnSplitter.cpp index 56ed05b8f0..21b89fd566 100644 --- a/lib/Module/ReturnSplitter.cpp +++ b/lib/Module/ReturnSplitter.cpp @@ -10,14 +10,9 @@ #include "Passes.h" -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS #include "llvm/IR/Function.h" #include "llvm/IR/Instruction.h" -#include "llvm/IR/Module.h" #include "llvm/Transforms/Utils/BasicBlockUtils.h" -DISABLE_WARNING_POP using namespace llvm; diff --git a/lib/Module/SarifReport.cpp b/lib/Module/SarifReport.cpp index 728e775c24..13a5fae844 100644 --- a/lib/Module/SarifReport.cpp +++ b/lib/Module/SarifReport.cpp @@ -14,11 +14,7 @@ #include "klee/Module/LocationInfo.h" #include "klee/Support/ErrorHandling.h" -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS #include "llvm/IR/IntrinsicInst.h" -DISABLE_WARNING_POP using namespace llvm; using namespace klee; @@ -237,7 +233,7 @@ class NumericTraceId : public TraceId { public: std::string toString() const override { return std::to_string(id); } - void getNextId(const klee::ResultJson &resultJson) override { id++; } + void getNextId(const klee::ResultJson &) override { id++; } }; TraceId *createTraceId(const std::string &toolName, diff --git a/lib/Module/Target.cpp b/lib/Module/Target.cpp index d2dde07919..722f06924a 100644 --- a/lib/Module/Target.cpp +++ b/lib/Module/Target.cpp @@ -10,10 +10,10 @@ #include "klee/Module/Target.h" #include "klee/Module/TargetHash.h" -#include "klee/Module/CodeGraphInfo.h" #include "klee/Module/KInstruction.h" -#include +#include + #include #include diff --git a/lib/Module/TargetForest.cpp b/lib/Module/TargetForest.cpp index 0d40b5b4c3..d1ef8076f1 100644 --- a/lib/Module/TargetForest.cpp +++ b/lib/Module/TargetForest.cpp @@ -11,12 +11,9 @@ #include "klee/Core/TargetedExecutionReporter.h" #include "klee/Expr/Expr.h" -#include "klee/Module/KInstruction.h" #include "klee/Module/KModule.h" #include "klee/Module/TargetHash.h" -#include "klee/Support/ErrorHandling.h" - using namespace klee; using namespace llvm; @@ -379,7 +376,6 @@ TargetForest::Layer *TargetForest::Layer::replaceChildWith( } TargetForest::Layer *TargetForest::Layer::replaceChildWith( - ref child, const std::unordered_set, UnorderedTargetsSetHash, UnorderedTargetsSetCmp> &other) const { std::vector layers; @@ -504,7 +500,7 @@ void TargetForest::stepTo(ref loc) { return; } history = history->add(loc); - forest = forest->replaceChildWith(loc, res->second); + forest = forest->replaceChildWith(res->second); } void TargetForest::add(ref target) { diff --git a/lib/Solver/AlphaEquivalenceSolver.cpp b/lib/Solver/AlphaEquivalenceSolver.cpp index b15f24c3ff..a265d7d576 100644 --- a/lib/Solver/AlphaEquivalenceSolver.cpp +++ b/lib/Solver/AlphaEquivalenceSolver.cpp @@ -18,14 +18,6 @@ #include "klee/Expr/Constraints.h" #include "klee/Expr/ExprHashMap.h" #include "klee/Solver/SolverImpl.h" -#include "klee/Support/Debug.h" - -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS -#include "llvm/Support/Casting.h" -#include "llvm/Support/raw_ostream.h" -DISABLE_WARNING_POP using namespace klee; using namespace llvm; diff --git a/lib/Solver/BitwuzlaBuilder.cpp b/lib/Solver/BitwuzlaBuilder.cpp index 3d58b8299c..5ee530a873 100644 --- a/lib/Solver/BitwuzlaBuilder.cpp +++ b/lib/Solver/BitwuzlaBuilder.cpp @@ -20,13 +20,8 @@ #include "klee/Solver/SolverStats.h" #include "klee/Support/ErrorHandling.h" -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS #include "llvm/ADT/APFloat.h" #include "llvm/ADT/StringExtras.h" -#include "llvm/Support/CommandLine.h" -DISABLE_WARNING_POP namespace klee { @@ -72,7 +67,7 @@ Term BitwuzlaBuilder::buildArray(const char *name, unsigned indexWidth, return mk_const(t, std::string(name)); } -Term BitwuzlaBuilder::buildConstantArray(const char *name, unsigned indexWidth, +Term BitwuzlaBuilder::buildConstantArray(const char *, unsigned indexWidth, unsigned valueWidth, unsigned value) { Sort domainSort = getBvSort(indexWidth); Sort rangeSort = getBvSort(valueWidth); @@ -454,7 +449,8 @@ Term BitwuzlaBuilder::construct(ref e, int *width_out) { } } -void BitwuzlaBuilder::FPCastWidthAssert(int *width_out, char const *msg) { +void BitwuzlaBuilder::FPCastWidthAssert([[maybe_unused]] int *width_out, + [[maybe_unused]] char const *msg) { assert(&(ConstantExpr::widthToFloatSemantics(*width_out)) != &(llvm::APFloat::Bogus()) && msg); diff --git a/lib/Solver/BitwuzlaBuilder.h b/lib/Solver/BitwuzlaBuilder.h index 4e260f832a..c470782e5c 100644 --- a/lib/Solver/BitwuzlaBuilder.h +++ b/lib/Solver/BitwuzlaBuilder.h @@ -10,15 +10,10 @@ #ifndef BITWUZLABUILDER_H_ #define BITWUZLABUILDER_H_ -#include "klee/Config/config.h" #include "klee/Expr/ArrayExprHash.h" #include "klee/Expr/ExprHashMap.h" -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS #include "llvm/ADT/APFloat.h" -DISABLE_WARNING_POP #include #include diff --git a/lib/Solver/BitwuzlaHashConfig.h b/lib/Solver/BitwuzlaHashConfig.h index a4a2d97bb1..d70ebea67f 100644 --- a/lib/Solver/BitwuzlaHashConfig.h +++ b/lib/Solver/BitwuzlaHashConfig.h @@ -11,13 +11,7 @@ #ifndef KLEE_BITWUZLAHASHCONFIG_H #define KLEE_BITWUZLAHASHCONFIG_H -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS #include "llvm/Support/CommandLine.h" -DISABLE_WARNING_POP - -#include namespace BitwuzlaHashConfig { extern llvm::cl::opt UseConstructHashBitwuzla; diff --git a/lib/Solver/BitwuzlaSolver.cpp b/lib/Solver/BitwuzlaSolver.cpp index 753916b68c..5e6a2c35d3 100644 --- a/lib/Solver/BitwuzlaSolver.cpp +++ b/lib/Solver/BitwuzlaSolver.cpp @@ -10,6 +10,8 @@ //===----------------------------------------------------------------------===// #include "klee/Config/config.h" +#include "klee/Solver/SolverStats.h" +#include "klee/Statistics/TimerStatIncrementer.h" #ifdef ENABLE_BITWUZLA @@ -23,8 +25,6 @@ #include "klee/Expr/ExprUtil.h" #include "klee/Solver/Solver.h" #include "klee/Solver/SolverImpl.h" -#include "klee/Support/ErrorHandling.h" -#include "klee/Support/FileHandling.h" #include "klee/Support/OptionCategories.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/raw_ostream.h" @@ -52,16 +52,12 @@ llvm::cl::opt BitwuzlaVerbosityLevel( llvm::cl::cat(klee::SolvingCat)); } // namespace -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS #include "llvm/Support/ErrorHandling.h" -DISABLE_WARNING_POP namespace { bool interrupted = false; -void signal_handler(int signum) { interrupted = true; } +void signal_handler(int) { interrupted = true; } } // namespace namespace klee { @@ -680,8 +676,8 @@ class BitwuzlaNonIncSolverImpl final : public BitwuzlaSolverImpl { BitwuzlaNonIncSolverImpl() = default; /// implementation of BitwuzlaSolverImpl interface - Bitwuzla &initNativeBitwuzla(const ConstraintQuery &query, - BitwuzlaASTIncSet &assertions) override { + Bitwuzla &initNativeBitwuzla(const ConstraintQuery &, + BitwuzlaASTIncSet &) override { theSolver.emplace(solverParameters); return theSolver.value(); } @@ -690,7 +686,7 @@ class BitwuzlaNonIncSolverImpl final : public BitwuzlaSolverImpl { deleteNativeBitwuzla(theSolver); } - void push(Bitwuzla &s) override {} + void push(Bitwuzla &) override {} /// implementation of the SolverImpl interface bool computeTruth(const Query &query, bool &isValid) override { @@ -723,7 +719,7 @@ class BitwuzlaNonIncSolverImpl final : public BitwuzlaSolverImpl { return BitwuzlaSolverImpl::computeValidityCore( ConstraintQuery(query, false), env, validityCore, isValid); } - void notifyStateTermination(std::uint32_t id) override {} + void notifyStateTermination(std::uint32_t) override {} }; BitwuzlaSolver::BitwuzlaSolver() @@ -867,11 +863,11 @@ class BitwuzlaTreeSolverImpl final : public BitwuzlaSolverImpl { BitwuzlaTreeSolverImpl(size_t maxSolvers) : maxSolvers(maxSolvers){}; /// implementation of BitwuzlaSolverImpl interface - Bitwuzla &initNativeBitwuzla(const ConstraintQuery &query, - BitwuzlaASTIncSet &assertions) override { + Bitwuzla &initNativeBitwuzla(const ConstraintQuery &, + BitwuzlaASTIncSet &) override { return currentSolver->getOrInit(); } - void deinitNativeBitwuzla(Bitwuzla &theSolver) override { + void deinitNativeBitwuzla(Bitwuzla &) override { assert(currentSolver->isConsistent()); solvers.push_back(std::move(currentSolver)); } diff --git a/lib/Solver/CMakeLists.txt b/lib/Solver/CMakeLists.txt index b4523d1594..9fb6edb865 100644 --- a/lib/Solver/CMakeLists.txt +++ b/lib/Solver/CMakeLists.txt @@ -48,7 +48,9 @@ target_link_libraries(kleaverSolver PRIVATE kleeSupport kleeModule ${KLEE_SOLVER_LIBRARIES}) -target_include_directories(kleaverSolver PRIVATE ${KLEE_INCLUDE_DIRS} ${LLVM_INCLUDE_DIRS} ${KLEE_SOLVER_INCLUDE_DIRS}) + +target_include_directories(kleaverSolver PRIVATE ${KLEE_INCLUDE_DIRS}) +target_include_directories(kleaverSolver SYSTEM PRIVATE ${KLEE_SOLVER_INCLUDE_DIRS} ${LLVM_INCLUDE_DIRS}) target_compile_options(kleaverSolver PRIVATE ${KLEE_COMPONENT_CXX_FLAGS}) target_compile_definitions(kleaverSolver PRIVATE ${KLEE_COMPONENT_CXX_DEFINES}) diff --git a/lib/Solver/CexCachingSolver.cpp b/lib/Solver/CexCachingSolver.cpp index cebf8f7025..69f347b608 100644 --- a/lib/Solver/CexCachingSolver.cpp +++ b/lib/Solver/CexCachingSolver.cpp @@ -19,11 +19,7 @@ #include "klee/Support/ErrorHandling.h" #include "klee/Support/OptionCategories.h" -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS #include "llvm/Support/CommandLine.h" -DISABLE_WARNING_POP #include #include diff --git a/lib/Solver/ConcretizingSolver.cpp b/lib/Solver/ConcretizingSolver.cpp index b9140c5b62..1d2a75047c 100644 --- a/lib/Solver/ConcretizingSolver.cpp +++ b/lib/Solver/ConcretizingSolver.cpp @@ -24,13 +24,6 @@ #include "klee/Solver/SolverImpl.h" #include "klee/Solver/SolverUtil.h" -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS -#include "llvm/Support/Casting.h" -DISABLE_WARNING_POP - -#include #include #include @@ -172,7 +165,7 @@ bool ConcretizingSolver::getBrokenArrays( } ValidityCore validityCore; - bool success = result->tryGetValidityCore(validityCore); + [[maybe_unused]] bool success = result->tryGetValidityCore(validityCore); assert(success); constraints_ty allValidityCoreConstraints = validityCore.constraints; @@ -219,7 +212,7 @@ bool ConcretizingSolver::relaxSymcreteConstraints(const Query &query, std::queue arrayQueue; - bool addressArrayPresent = false; + [[maybe_unused]] bool addressArrayPresent = false; for (const Array *array : currentlyBrokenSymcretizedArrays) { if (symcretesDependentFromArrays.count(array) && usedSymcretizedArrays.insert(array).second) { @@ -500,7 +493,7 @@ bool ConcretizingSolver::computeValidityCore(const Query &query, cache.insert(key, assign); isValid = false; } else { - bool success = result->tryGetValidityCore(validityCore); + [[maybe_unused]] bool success = result->tryGetValidityCore(validityCore); assert(success); } } diff --git a/lib/Solver/ConstructSolverChain.cpp b/lib/Solver/ConstructSolverChain.cpp index 80908272f9..7b81fd96d9 100644 --- a/lib/Solver/ConstructSolverChain.cpp +++ b/lib/Solver/ConstructSolverChain.cpp @@ -17,12 +17,6 @@ #include "klee/Support/ErrorHandling.h" #include "klee/System/Time.h" -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS -#include "llvm/Support/raw_ostream.h" -DISABLE_WARNING_POP - #include #include #include diff --git a/lib/Solver/CoreSolver.cpp b/lib/Solver/CoreSolver.cpp index a82dfc6a44..ae3c9ceaf1 100644 --- a/lib/Solver/CoreSolver.cpp +++ b/lib/Solver/CoreSolver.cpp @@ -7,21 +7,29 @@ // //===----------------------------------------------------------------------===// +#include "klee/Config/config.h" + +#ifdef ENABLE_BITWUZLA #include "BitwuzlaSolver.h" +#endif + +#ifdef ENABLE_METASMT #include "MetaSMTSolver.h" +#endif + +#ifdef ENABLE_STP #include "STPSolver.h" +#endif + +#ifdef ENABLE_Z3 #include "Z3Solver.h" +#endif #include "klee/Solver/Solver.h" #include "klee/Solver/SolverCmdLine.h" #include "klee/Support/ErrorHandling.h" -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS #include "llvm/Support/ErrorHandling.h" -#include "llvm/Support/raw_ostream.h" -DISABLE_WARNING_POP #include #include diff --git a/lib/Solver/DummySolver.cpp b/lib/Solver/DummySolver.cpp index 8b9c01f73d..e7e5d7c02f 100644 --- a/lib/Solver/DummySolver.cpp +++ b/lib/Solver/DummySolver.cpp @@ -35,42 +35,41 @@ class DummySolverImpl : public SolverImpl { DummySolverImpl::DummySolverImpl() {} -bool DummySolverImpl::computeValidity(const Query &, PartialValidity &result) { +bool DummySolverImpl::computeValidity(const Query &, PartialValidity &) { ++stats::solverQueries; // FIXME: We should have stats::queriesFail; return false; } -bool DummySolverImpl::computeTruth(const Query &, bool &isValid) { +bool DummySolverImpl::computeTruth(const Query &, bool &) { ++stats::solverQueries; // FIXME: We should have stats::queriesFail; return false; } -bool DummySolverImpl::computeValue(const Query &, ref &result) { +bool DummySolverImpl::computeValue(const Query &, ref &) { ++stats::solverQueries; ++stats::queryCounterexamples; return false; } bool DummySolverImpl::computeInitialValues( - const Query &, const std::vector &objects, - std::vector> &values, bool &hasSolution) { + const Query &, const std::vector &, + std::vector> &, bool &) { ++stats::solverQueries; ++stats::queryCounterexamples; return false; } -bool DummySolverImpl::check(const Query &query, ref &result) { +bool DummySolverImpl::check(const Query &, ref &) { ++stats::solverQueries; ++stats::queryCounterexamples; ++stats::queryValidityCores; return false; } -bool DummySolverImpl::computeValidityCore(const Query &query, - ValidityCore &validityCore, - bool &isValid) { +bool DummySolverImpl::computeValidityCore(const Query &, ValidityCore &, + bool &) { ++stats::solverQueries; ++stats::queryValidityCores; return false; @@ -80,7 +79,7 @@ SolverImpl::SolverRunStatus DummySolverImpl::getOperationStatusCode() { return SOLVER_RUN_STATUS_FAILURE; } -void DummySolverImpl::notifyStateTermination(std::uint32_t id) {} +void DummySolverImpl::notifyStateTermination(std::uint32_t) {} std::unique_ptr createDummySolver() { return std::make_unique(std::make_unique()); diff --git a/lib/Solver/FastCexSolver.cpp b/lib/Solver/FastCexSolver.cpp index 7e3d851667..2f831118aa 100644 --- a/lib/Solver/FastCexSolver.cpp +++ b/lib/Solver/FastCexSolver.cpp @@ -14,21 +14,15 @@ #include "klee/Expr/Expr.h" #include "klee/Expr/ExprEvaluator.h" #include "klee/Expr/ExprRangeEvaluator.h" -#include "klee/Expr/ExprVisitor.h" #include "klee/Solver/IncompleteSolver.h" #include "klee/Support/Debug.h" #include "klee/Support/ErrorHandling.h" -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS #include "llvm/ADT/APInt.h" #include "llvm/Support/raw_ostream.h" -DISABLE_WARNING_POP #include #include -#include #include #include @@ -232,25 +226,25 @@ class ValueRange { bits64::maxValueOfNBits(maxBit - lowBit)); } - ValueRange add(const ValueRange &b, unsigned width) const { + ValueRange add(const ValueRange &, unsigned width) const { return ValueRange(0, bits64::maxValueOfNBits(width)); } - ValueRange sub(const ValueRange &b, unsigned width) const { + ValueRange sub(const ValueRange &, unsigned width) const { return ValueRange(0, bits64::maxValueOfNBits(width)); } - ValueRange mul(const ValueRange &b, unsigned width) const { + ValueRange mul(const ValueRange &, unsigned width) const { return ValueRange(0, bits64::maxValueOfNBits(width)); } - ValueRange udiv(const ValueRange &b, unsigned width) const { + ValueRange udiv(const ValueRange &, unsigned width) const { return ValueRange(0, bits64::maxValueOfNBits(width)); } - ValueRange sdiv(const ValueRange &b, unsigned width) const { + ValueRange sdiv(const ValueRange &, unsigned width) const { return ValueRange(0, bits64::maxValueOfNBits(width)); } - ValueRange urem(const ValueRange &b, unsigned width) const { + ValueRange urem(const ValueRange &, unsigned width) const { return ValueRange(0, bits64::maxValueOfNBits(width)); } - ValueRange srem(const ValueRange &b, unsigned width) const { + ValueRange srem(const ValueRange &, unsigned width) const { return ValueRange(0, bits64::maxValueOfNBits(width)); } diff --git a/lib/Solver/IndependentSolver.cpp b/lib/Solver/IndependentSolver.cpp index 3eff03047c..e0f4e41ade 100644 --- a/lib/Solver/IndependentSolver.cpp +++ b/lib/Solver/IndependentSolver.cpp @@ -16,24 +16,12 @@ #include "klee/Expr/Assignment.h" #include "klee/Expr/Constraints.h" #include "klee/Expr/Expr.h" -#include "klee/Expr/ExprHashMap.h" #include "klee/Expr/ExprUtil.h" #include "klee/Expr/IndependentConstraintSetUnion.h" #include "klee/Expr/IndependentSet.h" #include "klee/Solver/SolverImpl.h" -#include "klee/Support/Debug.h" -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS -#include "llvm/Support/Casting.h" -#include "llvm/Support/raw_ostream.h" -DISABLE_WARNING_POP - -#include -#include #include -#include #include #include @@ -199,7 +187,7 @@ bool IndependentSolver::computeInitialValues( continue; } else if (it->exprs.size() == 0) { ref tempResult = new InvalidResponse(); - bool success = + [[maybe_unused]] bool success = tempResult->tryGetInitialValuesFor(arraysInFactor, tempValues); assert(success && "Can not get initial values (Independent solver)!"); } else { @@ -284,8 +272,9 @@ bool IndependentSolver::check(const Query &query, ref &result) { result = dependentFactorsResult; return true; } else { - bool success = dependentFactorsResult->tryGetInitialValuesFor( - dependentFactorsObjects, dependentFactorsValues); + [[maybe_unused]] bool success = + dependentFactorsResult->tryGetInitialValuesFor( + dependentFactorsObjects, dependentFactorsValues); assert(success && "Can not get initial values (Independent solver)!"); retMap = Assignment(dependentFactorsObjects, dependentFactorsValues); } @@ -315,7 +304,7 @@ bool IndependentSolver::check(const Query &query, ref &result) { result = tempResult; return true; } else { - bool success = + [[maybe_unused]] bool success = tempResult->tryGetInitialValuesFor(arraysInFactor, tempValues); assert(success && "Can not get initial values (Independent solver)!"); assert(tempValues.size() == arraysInFactor.size() && @@ -328,7 +317,7 @@ bool IndependentSolver::check(const Query &query, ref &result) { } result = new InvalidResponse(retMap.bindings); Assignment::bindings_ty bindings; - bool success = result->tryGetInitialValues(bindings); + [[maybe_unused]] bool success = result->tryGetInitialValues(bindings); assert(success); assert(assertCreatedPointEvaluatesToTrue(query, bindings, retMap.bindings) && "should satisfy the equation"); diff --git a/lib/Solver/MetaSMTBuilder.h b/lib/Solver/MetaSMTBuilder.h index 5f225ead82..aa32b70b05 100644 --- a/lib/Solver/MetaSMTBuilder.h +++ b/lib/Solver/MetaSMTBuilder.h @@ -10,28 +10,29 @@ #ifndef KLEE_METASMTBUILDER_H #define KLEE_METASMTBUILDER_H +#include "klee/Config/config.h" + +#ifdef ENABLE_METASMT + #include "ConstantDivision.h" -#include "klee/Config/config.h" +#include "klee/ADT/Bits.h" #include "klee/Expr/ArrayExprHash.h" #include "klee/Expr/Expr.h" #include "klee/Expr/ExprHashMap.h" -#include "klee/Expr/ExprPPrinter.h" - -#ifdef ENABLE_METASMT - +#include "klee/Solver/SolverStats.h" #include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS + #include "llvm/ADT/iterator_range.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/ErrorHandling.h" -DISABLE_WARNING_POP #include #include #include +#include + using namespace metaSMT; using namespace metaSMT::logic::QF_BV; @@ -751,12 +752,13 @@ MetaSMTBuilder::constructActual(ref e, int *width_out) { *width_out = ce->getWidth(); unsigned numKids = ce->getNumKids(); - if (numKids > 0) { - res = evaluate(_solver, construct(ce->getKid(numKids - 1), 0)); - for (int i = numKids - 2; i >= 0; i--) { - res = evaluate(_solver, concat(construct(ce->getKid(i), 0), res)); - } + assert(numKids > 0); + + res = evaluate(_solver, construct(ce->getKid(numKids - 1), 0)); + for (int i = numKids - 2; i >= 0; i--) { + res = evaluate(_solver, concat(construct(ce->getKid(i), 0), res)); } + break; } @@ -1242,8 +1244,8 @@ MetaSMTBuilder::constructActual(ref e, int *width_out) { #endif default: - assert(false); - break; + assert(false && "unexpected expression"); + unreachable(); }; return res; } diff --git a/lib/Solver/MetaSMTSolver.cpp b/lib/Solver/MetaSMTSolver.cpp index 1ef1448aed..905a568d65 100644 --- a/lib/Solver/MetaSMTSolver.cpp +++ b/lib/Solver/MetaSMTSolver.cpp @@ -17,13 +17,11 @@ #include "klee/Expr/ExprUtil.h" #include "klee/Solver/Solver.h" #include "klee/Solver/SolverImpl.h" +#include "klee/Solver/SolverStats.h" +#include "klee/Statistics/TimerStatIncrementer.h" #include "klee/Support/ErrorHandling.h" -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS #include "llvm/Support/ErrorHandling.h" -DISABLE_WARNING_POP #include @@ -95,7 +93,7 @@ template class MetaSMTSolverImpl : public SolverImpl { char *getConstraintLog(const Query &); void setCoreSolverTimeout(time::Span timeout) { _timeout = timeout; } - void notifyStateTermination(std::uint32_t id) {} + void notifyStateTermination(std::uint32_t) {} bool computeTruth(const Query &, bool &isValid); bool computeValue(const Query &, ref &result); @@ -281,7 +279,7 @@ SolverImpl::SolverRunStatus MetaSMTSolverImpl::runAndGetCex( } } -static void metaSMTTimeoutHandler(int x) { _exit(52); } +static void metaSMTTimeoutHandler(int) { _exit(52); } template SolverImpl::SolverRunStatus diff --git a/lib/Solver/QueryLoggingSolver.h b/lib/Solver/QueryLoggingSolver.h index 4cc5395ecd..314f47ab32 100644 --- a/lib/Solver/QueryLoggingSolver.h +++ b/lib/Solver/QueryLoggingSolver.h @@ -15,11 +15,7 @@ #include "klee/Solver/SolverImpl.h" #include "klee/System/Time.h" -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS #include "llvm/Support/raw_ostream.h" -DISABLE_WARNING_POP #include diff --git a/lib/Solver/STPBuilder.cpp b/lib/Solver/STPBuilder.cpp index f2890de0f8..b8bff79a19 100644 --- a/lib/Solver/STPBuilder.cpp +++ b/lib/Solver/STPBuilder.cpp @@ -17,15 +17,9 @@ #include "ConstantDivision.h" -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS #include "llvm/ADT/StringExtras.h" #include "llvm/ADT/iterator_range.h" #include "llvm/Support/CommandLine.h" -DISABLE_WARNING_POP - -#include #define vc_bvBoolExtract IAMTHESPAWNOFSATAN // unclear return @@ -41,8 +35,6 @@ DISABLE_WARNING_POP #include // max, min #include -#include -#include #include using namespace klee; diff --git a/lib/Solver/STPSolver.cpp b/lib/Solver/STPSolver.cpp index 5390a0191a..455da3749e 100644 --- a/lib/Solver/STPSolver.cpp +++ b/lib/Solver/STPSolver.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// #include "klee/Config/config.h" +#include "klee/Solver/SolverStats.h" +#include "klee/Statistics/TimerStatIncrementer.h" #ifdef ENABLE_STP @@ -20,12 +22,8 @@ #include "klee/Support/ErrorHandling.h" #include "klee/Support/OptionCategories.h" -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS #include "llvm/Support/CommandLine.h" #include "llvm/Support/Errno.h" -DISABLE_WARNING_POP #include #include @@ -104,7 +102,7 @@ class STPSolverImpl : public SolverImpl { void setCoreSolverTimeout(time::Span timeout) override { this->timeout = timeout; } - void notifyStateTermination(std::uint32_t id) override {} + void notifyStateTermination(std::uint32_t) override {} bool computeTruth(const Query &, bool &isValid) override; bool computeValue(const Query &, ref &result) override; @@ -286,7 +284,7 @@ runAndGetCex(::VC vc, STPBuilder *builder, ::VCExpr q, return SolverImpl::SOLVER_RUN_STATUS_SUCCESS_SOLVABLE; } -static void stpTimeoutHandler(int x) { _exit(52); } +static void stpTimeoutHandler(int) { _exit(52); } static SolverImpl::SolverRunStatus runAndGetCexForked(::VC vc, STPBuilder *builder, ::VCExpr q, diff --git a/lib/Solver/Solver.cpp b/lib/Solver/Solver.cpp index fe018ea03f..0050870f5a 100644 --- a/lib/Solver/Solver.cpp +++ b/lib/Solver/Solver.cpp @@ -9,6 +9,7 @@ #include "klee/Solver/Solver.h" +#include "klee/ADT/Bits.h" #include "klee/Expr/Constraints.h" #include "klee/Expr/Expr.h" #include "klee/Expr/ExprUtil.h" diff --git a/lib/Solver/SolverCmdLine.cpp b/lib/Solver/SolverCmdLine.cpp index 41f8324e7c..ae2f49d5d8 100644 --- a/lib/Solver/SolverCmdLine.cpp +++ b/lib/Solver/SolverCmdLine.cpp @@ -12,18 +12,14 @@ * data that are common to both KLEE and Kleaver. */ +#include "klee/Config/config.h" + #include "klee/Solver/SolverCmdLine.h" -#include "klee/Config/Version.h" #include "klee/Support/OptionCategories.h" -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS -#include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/StringMap.h" #include "llvm/Support/CommandLine.h" -DISABLE_WARNING_POP using namespace llvm; diff --git a/lib/Solver/SolverUtil.cpp b/lib/Solver/SolverUtil.cpp index 77336d852d..3794baa802 100644 --- a/lib/Solver/SolverUtil.cpp +++ b/lib/Solver/SolverUtil.cpp @@ -1,4 +1,5 @@ #include "klee/Solver/SolverUtil.h" +#include "klee/Support/CompilerWarning.h" namespace klee { @@ -16,6 +17,8 @@ const char *pv_to_str(PartialValidity pv) { return "TrueOrFalse"; case PValidity::None: return "None"; + default: + unreachable(); } } @@ -29,6 +32,7 @@ Validity fromPartial(PartialValidity pv) { return Validity::Unknown; default: assert(0 && "PV not convertible to Validity"); + unreachable(); } } @@ -40,13 +44,13 @@ PartialValidity toPartial(Validity v) { return PValidity::MustBeFalse; case Validity::Unknown: return PValidity::TrueOrFalse; + default: + unreachable(); } } PartialValidity negatePartialValidity(PartialValidity pv) { switch (pv) { - default: - assert(0 && "invalid partial validity"); case PValidity::MustBeTrue: return PValidity::MustBeFalse; case PValidity::MustBeFalse: @@ -57,6 +61,9 @@ PartialValidity negatePartialValidity(PartialValidity pv) { return PValidity::MayBeTrue; case PValidity::TrueOrFalse: return PValidity::TrueOrFalse; + default: + assert(0 && "invalid partial validity"); + unreachable(); } } diff --git a/lib/Solver/Z3BitvectorBuilder.cpp b/lib/Solver/Z3BitvectorBuilder.cpp index aa957b450a..1491ac9cc6 100644 --- a/lib/Solver/Z3BitvectorBuilder.cpp +++ b/lib/Solver/Z3BitvectorBuilder.cpp @@ -17,15 +17,8 @@ #include "klee/Expr/Expr.h" #include "klee/Solver/Solver.h" #include "klee/Solver/SolverStats.h" -#include "klee/Support/ErrorHandling.h" -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS #include "llvm/ADT/APFloat.h" -#include "llvm/ADT/StringExtras.h" -#include "llvm/Support/CommandLine.h" -DISABLE_WARNING_POP using namespace klee; @@ -262,7 +255,8 @@ Z3ASTHandle Z3BitvectorBuilder::constructAShrByConstant(Z3ASTHandle expr, } } -void Z3BitvectorBuilder::FPCastWidthAssert(int *width_out, char const *msg) { +void Z3BitvectorBuilder::FPCastWidthAssert([[maybe_unused]] int *width_out, + [[maybe_unused]] char const *msg) { assert(&(ConstantExpr::widthToFloatSemantics(*width_out)) != &(llvm::APFloat::Bogus()) && msg); @@ -936,6 +930,7 @@ Z3SortHandle Z3BitvectorBuilder::getFloatSortFromBitWidth(unsigned bitWidth) { default: assert(0 && "bitWidth cannot converted to a IEEE-754 binary-* number by Z3"); + unreachable(); } } diff --git a/lib/Solver/Z3BitvectorBuilder.h b/lib/Solver/Z3BitvectorBuilder.h index d6f9a3d3bd..565cdfb41f 100644 --- a/lib/Solver/Z3BitvectorBuilder.h +++ b/lib/Solver/Z3BitvectorBuilder.h @@ -10,22 +10,17 @@ #ifndef KLEE_Z3_BITVECTOR_BUILDER_H #define KLEE_Z3_BITVECTOR_BUILDER_H -#include "Z3BitvectorBuilder.h" #include "Z3Builder.h" -#include "klee/Config/config.h" -#include "klee/Expr/ArrayExprHash.h" -#include "klee/Expr/ExprHashMap.h" -#include #include -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS #include "llvm/ADT/APFloat.h" -DISABLE_WARNING_POP namespace klee { + +class Expr; +template class ref; + class Z3BitvectorBuilder : public Z3Builder { private: void FPCastWidthAssert(int *width_out, char const *msg); diff --git a/lib/Solver/Z3Builder.cpp b/lib/Solver/Z3Builder.cpp index 9b3b042466..5a0a35abbb 100644 --- a/lib/Solver/Z3Builder.cpp +++ b/lib/Solver/Z3Builder.cpp @@ -18,13 +18,8 @@ #include "klee/Solver/SolverStats.h" #include "klee/Support/ErrorHandling.h" -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS #include "llvm/ADT/StringExtras.h" #include "llvm/ADT/iterator_range.h" -#include "llvm/Support/CommandLine.h" -DISABLE_WARNING_POP using namespace klee; @@ -147,7 +142,7 @@ Z3ASTHandle Z3Builder::buildArray(const char *name, unsigned indexWidth, return Z3ASTHandle(Z3_mk_const(ctx, s, t), ctx); } -Z3ASTHandle Z3Builder::buildConstantArray(const char *name, unsigned indexWidth, +Z3ASTHandle Z3Builder::buildConstantArray(const char *, unsigned indexWidth, unsigned valueWidth, unsigned value) { Z3SortHandle domainSort = getBvSort(indexWidth); Z3ASTHandle defaultValue = bvZExtConst(valueWidth, value); diff --git a/lib/Solver/Z3CoreBuilder.cpp b/lib/Solver/Z3CoreBuilder.cpp index f1d454ea9b..74bf166e3a 100644 --- a/lib/Solver/Z3CoreBuilder.cpp +++ b/lib/Solver/Z3CoreBuilder.cpp @@ -17,12 +17,6 @@ #include "klee/Expr/Expr.h" #include "klee/Solver/SolverStats.h" -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS -#include "llvm/Support/CommandLine.h" -DISABLE_WARNING_POP - using namespace klee; namespace klee { diff --git a/lib/Solver/Z3HashConfig.h b/lib/Solver/Z3HashConfig.h index 87c8d347ec..e9c524854f 100644 --- a/lib/Solver/Z3HashConfig.h +++ b/lib/Solver/Z3HashConfig.h @@ -10,11 +10,7 @@ #ifndef KLEE_Z3HASHCONFIG_H #define KLEE_Z3HASHCONFIG_H -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS #include "llvm/Support/CommandLine.h" -DISABLE_WARNING_POP #include diff --git a/lib/Solver/Z3Solver.cpp b/lib/Solver/Z3Solver.cpp index a27938d41b..caf530b4c9 100644 --- a/lib/Solver/Z3Solver.cpp +++ b/lib/Solver/Z3Solver.cpp @@ -8,6 +8,8 @@ //===----------------------------------------------------------------------===// #include "klee/Config/config.h" +#include "klee/Solver/SolverStats.h" +#include "klee/Statistics/TimerStatIncrementer.h" #ifdef ENABLE_Z3 @@ -57,11 +59,7 @@ llvm::cl::opt llvm::cl::cat(klee::SolvingCat)); } // namespace -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS #include "llvm/Support/ErrorHandling.h" -DISABLE_WARNING_POP namespace klee { @@ -200,12 +198,13 @@ void Z3SolverEnv::clear() { const Z3SolverEnv::arr_vec * Z3SolverEnv::getObjectsForGetModel(ObjectAssignment oa) const { switch (oa) { - case ObjectAssignment::NotNeeded: - return nullptr; case ObjectAssignment::NeededForObjectsFromEnv: return &objectsForGetModel; case ObjectAssignment::NeededForObjectsFromQuery: return &objects.v; + case ObjectAssignment::NotNeeded: + default: + return nullptr; } } @@ -692,33 +691,48 @@ SolverImpl::SolverRunStatus Z3SolverImpl::handleSolverResponse( SparseStorageImpl data; ::Z3_ast arraySizeExpr; - Z3_model_eval(builder->ctx, theModel, builder->construct(array->size), - Z3_TRUE, &arraySizeExpr); + if (!Z3_model_eval(builder->ctx, theModel, + builder->construct(array->size), Z3_TRUE, + &arraySizeExpr)) { + Z3_model_dec_ref(builder->ctx, theModel); + return SolverImpl::SOLVER_RUN_STATUS_FAILURE; + } Z3_inc_ref(builder->ctx, arraySizeExpr); - ::Z3_ast_kind arraySizeExprKind = - Z3_get_ast_kind(builder->ctx, arraySizeExpr); - assert(arraySizeExprKind == Z3_NUMERAL_AST && + + assert(Z3_get_ast_kind(builder->ctx, arraySizeExpr) == Z3_NUMERAL_AST && "Evaluated size expression has wrong sort"); uint64_t arraySize = 0; - bool success = - Z3_get_numeral_uint64(builder->ctx, arraySizeExpr, &arraySize); - assert(success && "Failed to get size"); + if (!Z3_get_numeral_uint64(builder->ctx, arraySizeExpr, &arraySize)) { + Z3_dec_ref(builder->ctx, arraySizeExpr); + Z3_model_dec_ref(builder->ctx, theModel); + return SolverImpl::SOLVER_RUN_STATUS_FAILURE; + } if (env.usedArrayBytes.count(array)) { std::unordered_set offsetValues; for (const ref &offsetExpr : env.usedArrayBytes.at(array)) { ::Z3_ast arrayElementOffsetExpr; - Z3_model_eval(builder->ctx, theModel, builder->construct(offsetExpr), - Z3_TRUE, &arrayElementOffsetExpr); + if (!Z3_model_eval(builder->ctx, theModel, + builder->construct(offsetExpr), Z3_TRUE, + &arrayElementOffsetExpr)) { + Z3_dec_ref(builder->ctx, arraySizeExpr); + Z3_model_dec_ref(builder->ctx, theModel); + return SolverImpl::SOLVER_RUN_STATUS_FAILURE; + } + Z3_inc_ref(builder->ctx, arrayElementOffsetExpr); - ::Z3_ast_kind arrayElementOffsetExprKind = - Z3_get_ast_kind(builder->ctx, arrayElementOffsetExpr); - assert(arrayElementOffsetExprKind == Z3_NUMERAL_AST && + + assert(Z3_get_ast_kind(builder->ctx, arrayElementOffsetExpr) == + Z3_NUMERAL_AST && "Evaluated size expression has wrong sort"); uint64_t concretizedOffsetValue = 0; - bool success = Z3_get_numeral_uint64( - builder->ctx, arrayElementOffsetExpr, &concretizedOffsetValue); - assert(success && "Failed to get size"); + if (!Z3_get_numeral_uint64(builder->ctx, arrayElementOffsetExpr, + &concretizedOffsetValue)) { + Z3_dec_ref(builder->ctx, arrayElementOffsetExpr); + Z3_dec_ref(builder->ctx, arraySizeExpr); + Z3_model_dec_ref(builder->ctx, theModel); + return SolverImpl::SOLVER_RUN_STATUS_FAILURE; + } offsetValues.insert(concretizedOffsetValue); Z3_dec_ref(builder->ctx, arrayElementOffsetExpr); } @@ -728,19 +742,25 @@ SolverImpl::SolverRunStatus Z3SolverImpl::handleSolverResponse( ::Z3_ast arrayElementExpr; Z3ASTHandle initial_read = builder->getInitialRead(array, offset); - __attribute__((unused)) bool successfulEval = - Z3_model_eval(builder->ctx, theModel, initial_read, - /*model_completion=*/Z3_TRUE, &arrayElementExpr); - assert(successfulEval && "Failed to evaluate model"); + if (!Z3_model_eval(builder->ctx, theModel, initial_read, + /*model_completion=*/Z3_TRUE, &arrayElementExpr)) { + Z3_dec_ref(builder->ctx, arraySizeExpr); + Z3_model_dec_ref(builder->ctx, theModel); + return SolverImpl::SOLVER_RUN_STATUS_FAILURE; + } Z3_inc_ref(builder->ctx, arrayElementExpr); assert(Z3_get_ast_kind(builder->ctx, arrayElementExpr) == Z3_NUMERAL_AST && "Evaluated expression has wrong sort"); int arrayElementValue = 0; - __attribute__((unused)) bool successGet = Z3_get_numeral_int( - builder->ctx, arrayElementExpr, &arrayElementValue); - assert(successGet && "failed to get value back"); + if (!Z3_get_numeral_int(builder->ctx, arrayElementExpr, + &arrayElementValue)) { + Z3_dec_ref(builder->ctx, arrayElementExpr); + Z3_dec_ref(builder->ctx, arraySizeExpr); + Z3_model_dec_ref(builder->ctx, theModel); + return SolverImpl::SOLVER_RUN_STATUS_FAILURE; + } assert(arrayElementValue >= 0 && arrayElementValue <= 255 && "Integer from model is out of range"); data.store(offset, arrayElementValue); @@ -886,7 +906,7 @@ class Z3NonIncSolverImpl final : public Z3SolverImpl { void deinitNativeZ3(Z3_solver theSolver) override { deleteNativeZ3(builder->ctx, theSolver); } - void push(Z3_context c, Z3_solver s) override {} + void push(Z3_context, Z3_solver) override {} /// implementation of the SolverImpl interface bool computeTruth(const Query &query, bool &isValid) override { @@ -918,7 +938,7 @@ class Z3NonIncSolverImpl final : public Z3SolverImpl { return Z3SolverImpl::computeValidityCore(ConstraintQuery(query, false), env, validityCore, isValid); } - void notifyStateTermination(std::uint32_t id) override {} + void notifyStateTermination(std::uint32_t) override {} }; Z3Solver::Z3Solver(Z3BuilderType type) @@ -1072,11 +1092,10 @@ class Z3TreeSolverImpl final : public Z3SolverImpl { : Z3SolverImpl(type), maxSolvers(maxSolvers){}; /// implementation of Z3SolverImpl interface - Z3_solver initNativeZ3(const ConstraintQuery &query, - Z3ASTIncSet &assertions) override { + Z3_solver initNativeZ3(const ConstraintQuery &, Z3ASTIncSet &) override { return currentSolver->getOrInit(); } - void deinitNativeZ3(Z3_solver theSolver) override { + void deinitNativeZ3(Z3_solver) override { assert(currentSolver->isConsistent()); solvers.push_back(std::move(currentSolver)); } diff --git a/lib/Support/CMakeLists.txt b/lib/Support/CMakeLists.txt index 6e32058a96..2baf09f80a 100644 --- a/lib/Support/CMakeLists.txt +++ b/lib/Support/CMakeLists.txt @@ -22,6 +22,8 @@ add_library(kleeSupport llvm_config(kleeSupport "${USE_LLVM_SHARED}" support) target_link_libraries(kleeSupport PRIVATE ${ZLIB_LIBRARIES} ${TCMALLOC_LIBRARIES}) -target_include_directories(kleeSupport PRIVATE ${KLEE_INCLUDE_DIRS} ${LLVM_INCLUDE_DIRS} ${TCMALLOC_INCLUDE_DIR}) + +target_include_directories(kleeSupport PRIVATE ${KLEE_INCLUDE_DIRS}) +target_include_directories(kleeSupport SYSTEM PRIVATE ${LLVM_INCLUDE_DIRS} ${TCMALLOC_INCLUDE_DIR}) target_compile_options(kleeSupport PRIVATE ${KLEE_COMPONENT_CXX_FLAGS}) target_compile_definitions(kleeSupport PRIVATE ${KLEE_COMPONENT_CXX_DEFINES}) diff --git a/lib/Support/CompressionStream.cpp b/lib/Support/CompressionStream.cpp index 1b81048738..ff68eb2dd0 100644 --- a/lib/Support/CompressionStream.cpp +++ b/lib/Support/CompressionStream.cpp @@ -6,16 +6,11 @@ // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// -#include "klee/Config/Version.h" #include "klee/Config/config.h" #ifdef HAVE_ZLIB_H #include "klee/Support/CompressionStream.h" -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS #include "llvm/Support/FileSystem.h" -DISABLE_WARNING_POP #include #include diff --git a/lib/Support/ErrorHandling.cpp b/lib/Support/ErrorHandling.cpp index 685ac5c52b..86c099fdf9 100644 --- a/lib/Support/ErrorHandling.cpp +++ b/lib/Support/ErrorHandling.cpp @@ -8,18 +8,13 @@ //===----------------------------------------------------------------------===// #include "klee/Support/ErrorHandling.h" -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS #include "llvm/ADT/StringRef.h" #include "llvm/Support/CommandLine.h" -DISABLE_WARNING_POP -#include -#include -#include -#include -#include +#include +#include +#include +#include #include diff --git a/lib/Support/FileHandling.cpp b/lib/Support/FileHandling.cpp index 17a2fc0697..5469d53723 100644 --- a/lib/Support/FileHandling.cpp +++ b/lib/Support/FileHandling.cpp @@ -8,15 +8,9 @@ //===----------------------------------------------------------------------===// #include "klee/Support/FileHandling.h" -#include "klee/Config/Version.h" #include "klee/Config/config.h" -#include "klee/Support/ErrorHandling.h" -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS #include "llvm/Support/FileSystem.h" -DISABLE_WARNING_POP #ifdef HAVE_ZLIB_H #include "klee/Support/CompressionStream.h" diff --git a/lib/Support/PrintVersion.cpp b/lib/Support/PrintVersion.cpp index ad799f9dfb..27d87ea763 100644 --- a/lib/Support/PrintVersion.cpp +++ b/lib/Support/PrintVersion.cpp @@ -9,15 +9,10 @@ #include "klee/Support/PrintVersion.h" #include "klee/Config/CompileTimeInfo.h" -#include "klee/Config/Version.h" #include "klee/Config/config.h" -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS #include "llvm/Support/CommandLine.h" #include "llvm/Support/raw_ostream.h" -DISABLE_WARNING_POP void klee::printVersion(llvm::raw_ostream &OS) { OS << PACKAGE_STRING " (" PACKAGE_URL ")\n"; diff --git a/lib/Support/RoundingModeUtil.cpp b/lib/Support/RoundingModeUtil.cpp index 70428cf56c..6a33229fa4 100644 --- a/lib/Support/RoundingModeUtil.cpp +++ b/lib/Support/RoundingModeUtil.cpp @@ -8,12 +8,8 @@ //===----------------------------------------------------------------------===// #include "klee/Support/RoundingModeUtil.h" -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS #include "llvm/ADT/APFloat.h" #include "llvm/Support/ErrorHandling.h" -DISABLE_WARNING_POP #include diff --git a/lib/Support/TreeStream.cpp b/lib/Support/TreeStream.cpp index 55c85de174..9dc72a6ce8 100644 --- a/lib/Support/TreeStream.cpp +++ b/lib/Support/TreeStream.cpp @@ -11,20 +11,15 @@ #include "klee/ADT/TreeStream.h" #include "klee/Support/Debug.h" +#ifdef ENABLE_KLEE_DEBUG +#include "llvm/Support/raw_ostream.h" +#endif #include #include -#include -#include #include -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS -#include "llvm/Support/raw_ostream.h" -DISABLE_WARNING_POP - -#include +#include using namespace klee; diff --git a/runtime/CMakeLists.txt b/runtime/CMakeLists.txt index d1c8a17d2f..be7074a449 100644 --- a/runtime/CMakeLists.txt +++ b/runtime/CMakeLists.txt @@ -78,6 +78,8 @@ set(COMMON_CC_FLAGS -D__STDC_CONSTANT_MACROS -Wall -Wwrite-strings + -Wno-unused-command-line-argument + -Wno-override-module -Xclang -disable-O0-optnone ) diff --git a/runtime/POSIX/fd_init.c b/runtime/POSIX/fd_init.c index 02469b8696..0fbb1a6bd8 100644 --- a/runtime/POSIX/fd_init.c +++ b/runtime/POSIX/fd_init.c @@ -60,7 +60,8 @@ static void __create_new_dfile(exe_disk_file_t *dfile, unsigned size, if (!standart_io) { char read_bytes_name[64]; char write_bytes_name[64]; - for (const char *sp = name; *sp; ++sp) { + const char *sp = name; + for (; *sp; ++sp) { read_bytes_name[sp - name] = *sp; write_bytes_name[sp - name] = *sp; } @@ -119,7 +120,7 @@ static void __create_new_dfile(exe_disk_file_t *dfile, unsigned size, dfile->stat = s; } -static unsigned __sym_uint32(const char *name) { +__attribute__((unused)) static unsigned __sym_uint32(const char *name) { unsigned x; klee_make_symbolic(&x, sizeof x, name); return x; @@ -162,8 +163,8 @@ void klee_init_fds(unsigned n_files, unsigned file_length, unsigned int i; for (i = 0; i < stdin_length; i++) { klee_prefer_cex(__exe_fs.sym_stdin, - 32 <= __exe_fs.sym_stdin->contents[i] & - __exe_fs.sym_stdin->contents[i] <= 126); + (32 <= __exe_fs.sym_stdin->contents[i]) & + (__exe_fs.sym_stdin->contents[i] <= 126)); } __exe_env.fds[0].dfile = __exe_fs.sym_stdin; off64_t *ptr = malloc(sizeof(off64_t)); diff --git a/runtime/POSIX/input_output.c b/runtime/POSIX/input_output.c index 14daa68af8..4172415fbe 100644 --- a/runtime/POSIX/input_output.c +++ b/runtime/POSIX/input_output.c @@ -3,6 +3,7 @@ #include #include #include +#include /* * Return the (stdio) flags for a given mode. Store the flags @@ -211,7 +212,7 @@ size_t fwrite(const void *buffer, size_t size, size_t count, FILE *stream) { } int fd = get_file_descriptor(stream); - void *cop_buf = buffer; + const void *cop_buf = buffer; int write_byte = write(fd, cop_buf, size * count); if (write_byte == -1) { return 0; diff --git a/runtime/POSIX/klee_init_env.c b/runtime/POSIX/klee_init_env.c index 919bc2969b..1265849cde 100644 --- a/runtime/POSIX/klee_init_env.c +++ b/runtime/POSIX/klee_init_env.c @@ -13,7 +13,6 @@ #endif #include "fd.h" -#include #include #include @@ -242,7 +241,8 @@ int __klee_posix_wrapped_main(int argc, char **argv, char **envp); void check_stdin_read() { klee_assume(__exe_env.stdin_off == __exe_env.max_off); - for (int i = 0; i < __exe_fs.n_sym_files; i++) { + unsigned i = 0; + for (; i < __exe_fs.n_sym_files; i++) { klee_assume(__exe_fs.sym_files[i].read_bytes_real == __exe_fs.sym_files[i].read_bytes_symbolic); klee_assume(__exe_fs.sym_files[i].write_bytes_real == diff --git a/runtime/POSIX/stubs.c b/runtime/POSIX/stubs.c index 29ee93c1a2..b7532fa4cb 100644 --- a/runtime/POSIX/stubs.c +++ b/runtime/POSIX/stubs.c @@ -31,6 +31,12 @@ #include #include "klee/Config/config.h" +#include "klee/Support/CompilerWarning.h" + +DISABLE_WARNING_PUSH +// clang-format off +DISABLE_WARNING(-Wignored-attributes) +// clang-format on void klee_warning(const char *); void klee_warning_once(const char *); @@ -622,3 +628,4 @@ int munmap(void *start, size_t length) { errno = EPERM; return -1; } +DISABLE_WARNING_POP diff --git a/runtime/Runtest/intrinsics.c b/runtime/Runtest/intrinsics.c index 16766ca91f..f85d8a7978 100644 --- a/runtime/Runtest/intrinsics.c +++ b/runtime/Runtest/intrinsics.c @@ -16,7 +16,6 @@ #include #include #include -#include #include "klee/klee.h" @@ -205,10 +204,11 @@ int klee_range(int begin, int end, const char *name) { return x; } -void klee_prefer_cex(void *object, uintptr_t condition) {} +void klee_prefer_cex(__attribute__((unused)) void *object, + __attribute__((unused)) uintptr_t condition) {} void klee_abort() { abort(); } -void klee_print_expr(const char *msg, ...) {} +void klee_print_expr(__attribute__((unused)) const char *msg, ...) {} -void klee_set_forking(unsigned enable) {} +void klee_set_forking(__attribute__((unused)) unsigned enable) {} diff --git a/runtime/klee-fp/fpclassify.c b/runtime/klee-fp/fpclassify.c index 0e0b1b179d..82e94eea5d 100644 --- a/runtime/klee-fp/fpclassify.c +++ b/runtime/klee-fp/fpclassify.c @@ -62,18 +62,18 @@ int fpclassifyl(long double f) { return __fpclassifyl(f); } // __finitef int __finitef(float f) { - return (!klee_is_nan_float(f)) & (!klee_is_infinite_float(f)); + return (!klee_is_nan_float(f)) && (!klee_is_infinite_float(f)); } int finitef(float f) { return __finitef(f); } // __finite int __finite(double f) { - return (!klee_is_nan_double(f)) & (!klee_is_infinite_double(f)); + return (!klee_is_nan_double(f)) && (!klee_is_infinite_double(f)); } int finite(double f) { return __finite(f); } // __finitel int __finitel(long double f) { - return (!klee_is_nan_long_double(f)) & (!klee_is_infinite_long_double(f)); + return (!klee_is_nan_long_double(f)) && (!klee_is_infinite_long_double(f)); } -int finitel(long double f) { return finitel(f); } +int finitel(long double f) { return __finitel(f); } diff --git a/scripts/build/p-klee.inc b/scripts/build/p-klee.inc index c3ba6b12f9..7f84e0a998 100644 --- a/scripts/build/p-klee.inc +++ b/scripts/build/p-klee.inc @@ -24,7 +24,6 @@ build_klee() { "-DENABLE_UNIT_TESTS=TRUE" "-DENABLE_SYSTEM_TESTS=TRUE" "-DENABLE_DOXYGEN=${ENABLE_DOXYGEN}" - "-DBUILD_SUFFIX=${BUILD_SUFFIX}" "-DLIT_ARGS=\"-v;--time-tests\"" ) @@ -164,6 +163,12 @@ fi CMAKE_ARGUMENTS+=("-DCMAKE_BUILD_TYPE=Debug") fi + if [ "X${ENABLE_WARNINGS_AS_ERRORS}" == "X1" ]; then + CMAKE_ARGUMENTS+=("-DWARNINGS_AS_ERRORS=TRUE") + else + CMAKE_ARGUMENTS+=("-DWARNINGS_AS_ERRORS=FALSE") + fi + CMAKE_ARGUMENTS+=("-DKLEE_RUNTIME_BUILD_TYPE=${KLEE_RUNTIME_BUILD}") # TODO: We should support Ninja too diff --git a/scripts/build/v-klee.inc b/scripts/build/v-klee.inc index 86103d60cb..4a1107e18e 100644 --- a/scripts/build/v-klee.inc +++ b/scripts/build/v-klee.inc @@ -6,6 +6,7 @@ required_variables_klee=( "USE_TCMALLOC" "USE_LIBCXX" "ENABLE_DOXYGEN" + "ENABLE_WARNINGS_AS_ERRORS" ) required_variables_check_klee() { @@ -13,6 +14,7 @@ required_variables_check_klee() { check_bool "USE_TCMALLOC" check_bool "USE_LIBCXX" check_bool "ENABLE_DOXYGEN" + check_bool "ENABLE_WARNINGS_AS_ERRORS" } # On which artifacts does KLEE depend on diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index c7d14ed87e..0c9b211329 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -116,7 +116,7 @@ if (DOWNLOAD_FILECHECK_SOURCE) ${FILECHECK_SRC_FILE} ) llvm_config(FileCheck "${USE_LLVM_SHARED}" support) - target_include_directories(FileCheck PRIVATE ${LLVM_INCLUDE_DIRS}) + target_include_directories(FileCheck SYSTEM PRIVATE ${LLVM_INCLUDE_DIRS}) target_link_libraries(FileCheck PRIVATE ${FILECHECK_NEEDED_LIBS}) endif() @@ -137,7 +137,7 @@ if (DOWNLOAD_NOT_SOURCE) ${NOT_SRC_FILE} ) llvm_config("not" "${USE_LLVM_SHARED}" support) - target_include_directories("not" PRIVATE ${LLVM_INCLUDE_DIRS}) + target_include_directories("not" SYSTEM PRIVATE ${LLVM_INCLUDE_DIRS}) target_link_libraries("not" PRIVATE ${NOT_NEEDED_LIBS}) endif() diff --git a/tools/kleaver/CMakeLists.txt b/tools/kleaver/CMakeLists.txt index c2960a7e88..b3e21e2613 100644 --- a/tools/kleaver/CMakeLists.txt +++ b/tools/kleaver/CMakeLists.txt @@ -13,7 +13,8 @@ add_executable(kleaver llvm_config(kleaver "${USE_LLVM_SHARED}" core support) target_link_libraries(kleaver PRIVATE kleaverSolver) -target_include_directories(kleaver PRIVATE ${KLEE_INCLUDE_DIRS} ${LLVM_INCLUDE_DIRS}) +target_include_directories(kleaver SYSTEM PRIVATE ${LLVM_INCLUDE_DIRS}) +target_include_directories(kleaver PRIVATE ${KLEE_INCLUDE_DIRS}) target_compile_options(kleaver PRIVATE ${KLEE_COMPONENT_CXX_FLAGS}) target_compile_definitions(kleaver PRIVATE ${KLEE_COMPONENT_CXX_DEFINES}) diff --git a/tools/kleaver/main.cpp b/tools/kleaver/main.cpp index 712d3e5b5f..45b59e3b24 100644 --- a/tools/kleaver/main.cpp +++ b/tools/kleaver/main.cpp @@ -10,13 +10,11 @@ #include "klee/ADT/SparseStorage.h" #include "klee/Config/Version.h" #include "klee/Expr/ArrayCache.h" -#include "klee/Expr/Constraints.h" #include "klee/Expr/Expr.h" #include "klee/Expr/ExprBuilder.h" #include "klee/Expr/ExprHashMap.h" #include "klee/Expr/ExprPPrinter.h" #include "klee/Expr/ExprSMTLIBPrinter.h" -#include "klee/Expr/ExprVisitor.h" #include "klee/Expr/Parser/Lexer.h" #include "klee/Expr/Parser/Parser.h" #include "klee/Solver/Common.h" @@ -27,16 +25,12 @@ #include "klee/Support/OptionCategories.h" #include "klee/Support/PrintVersion.h" -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS #include "llvm/ADT/StringExtras.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/ManagedStatic.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/Signals.h" #include "llvm/Support/raw_ostream.h" -DISABLE_WARNING_POP #include #include diff --git a/tools/klee-replay/file-creator.c b/tools/klee-replay/file-creator.c index eea62a4b92..0529775b5d 100644 --- a/tools/klee-replay/file-creator.c +++ b/tools/klee-replay/file-creator.c @@ -66,7 +66,7 @@ static int create_link(const char *fname, exe_disk_file_t *dfile, } static int create_dir(const char *fname, exe_disk_file_t *dfile, - const char *tmpdir) { + __attribute__((unused)) const char *tmpdir) { int res = mkdir(fname, dfile->stat->st_mode); if (res < 0) { perror("mkdir"); @@ -101,7 +101,7 @@ int wait_for_timeout_or_exit(pid_t pid, const char *name, int *statusp) { } static int create_char_dev(const char *fname, exe_disk_file_t *dfile, - const char *tmpdir) { + __attribute__((unused)) const char *tmpdir) { struct stat64 *s = dfile->stat; unsigned flen = dfile->size; char *contents = dfile->contents; @@ -228,8 +228,9 @@ static int create_char_dev(const char *fname, exe_disk_file_t *dfile, } } -static int create_pipe(const char *fname, exe_disk_file_t *dfile, - const char *tmpdir) { +static int create_pipe(__attribute__((unused)) const char *fname, + exe_disk_file_t *dfile, + __attribute__((unused)) const char *tmpdir) { // struct stat64 *s = dfile->stat; unsigned flen = dfile->size; char *contents = dfile->contents; @@ -291,7 +292,7 @@ static int create_pipe(const char *fname, exe_disk_file_t *dfile, int futimes(int fd, const struct timeval tv[2]); static int create_reg_file(const char *fname, exe_disk_file_t *dfile, - const char *tmpdir) { + __attribute__((unused)) const char *tmpdir) { struct stat64 *s = dfile->stat; char *contents = dfile->contents; unsigned flen = dfile->size; diff --git a/tools/klee-replay/klee-replay.c b/tools/klee-replay/klee-replay.c index 4e53bc6440..089210c9a6 100644 --- a/tools/klee-replay/klee-replay.c +++ b/tools/klee-replay/klee-replay.c @@ -11,7 +11,6 @@ #include "klee/ADT/KTest.h" -#include #include #include #include @@ -120,7 +119,7 @@ static void int_handler(int signal) { } } -static void timeout_handler(int signal) { +static void timeout_handler(__attribute__((unused)) int signum) { fprintf(stderr, "KLEE-REPLAY: NOTE: EXIT STATUS: TIMED OUT (%d seconds)\n", monitored_timeout); if (monitored_pid) { @@ -168,7 +167,9 @@ static inline char *strip_root_dir(char *executable, char *rootdir) { return executable + strlen(rootdir); } -static void run_monitored(char *executable, int argc, char **argv) { +static void run_monitored(__attribute__((unused)) char *executable, + __attribute__((unused)) int argc, + __attribute__((unused)) char **argv) { int pid; const char *t = getenv("KLEE_REPLAY_TIMEOUT"); if (!t) @@ -458,11 +459,17 @@ unsigned klee_assume(uintptr_t x) { return 0; } -unsigned klee_is_symbolic(uintptr_t x) { return 0; } +unsigned klee_is_symbolic(__attribute__((unused)) uintptr_t x) { return 0; } -void klee_prefer_cex(void *buffer, uintptr_t condition) { ; } +void klee_prefer_cex(__attribute__((unused)) void *buffer, + __attribute__((unused)) uintptr_t condition) { + ; +} -void klee_posix_prefer_cex(void *buffer, uintptr_t condition) { ; } +void klee_posix_prefer_cex(__attribute__((unused)) void *buffer, + __attribute__((unused)) uintptr_t condition) { + ; +} void klee_make_symbolic(void *addr, size_t nbytes, const char *name) { if (obj_index >= input->numObjects) { @@ -510,12 +517,14 @@ int klee_range(int start, int end, const char *name) { } } -void klee_report_error(const char *file, int line, const char *message, - const char *suffix) { +void klee_report_error(__attribute__((unused)) const char *file, + __attribute__((unused)) int line, + __attribute__((unused)) const char *message, + __attribute__((unused)) const char *suffix) { __emit_error(message); } -void klee_mark_global(void *object) { ; } +void klee_mark_global(__attribute__((unused)) void *object) { ; } /*** HELPER FUNCTIONS ***/ diff --git a/tools/klee-replay/klee_init_env.c b/tools/klee-replay/klee_init_env.c index c697975e1b..05a1647487 100644 --- a/tools/klee-replay/klee_init_env.c +++ b/tools/klee-replay/klee_init_env.c @@ -1,4 +1,8 @@ #define _LARGEFILE64_SOURCE #include "../../runtime/POSIX/klee_init_env.c" -int __klee_posix_wrapped_main(int argc, char **argv, char **envp) { return 0; } +int __klee_posix_wrapped_main(__attribute__((unused)) int argc, + __attribute__((unused)) char **argv, + __attribute__((unused)) char **envp) { + return 0; +} diff --git a/tools/klee/CMakeLists.txt b/tools/klee/CMakeLists.txt index 5d63f93901..d6664882bc 100644 --- a/tools/klee/CMakeLists.txt +++ b/tools/klee/CMakeLists.txt @@ -15,7 +15,8 @@ set(KLEE_LIBS ) target_link_libraries(klee ${KLEE_LIBS}) -target_include_directories(klee PRIVATE ${KLEE_INCLUDE_DIRS} ${LLVM_INCLUDE_DIRS}) +target_include_directories(klee SYSTEM PRIVATE ${LLVM_INCLUDE_DIRS}) +target_include_directories(klee PRIVATE ${KLEE_INCLUDE_DIRS}) target_compile_options(klee PRIVATE ${KLEE_COMPONENT_CXX_FLAGS}) target_compile_definitions(klee PRIVATE ${KLEE_COMPONENT_CXX_DEFINES}) diff --git a/tools/klee/main.cpp b/tools/klee/main.cpp index 29651bbf91..9cd06abbf7 100644 --- a/tools/klee/main.cpp +++ b/tools/klee/main.cpp @@ -17,7 +17,6 @@ #include "klee/Core/TargetedExecutionReporter.h" #include "klee/Module/LocationInfo.h" #include "klee/Module/SarifReport.h" -#include "klee/Module/TargetForest.h" #include "klee/Solver/SolverCmdLine.h" #include "klee/Statistics/Statistics.h" #include "klee/Support/Debug.h" @@ -29,12 +28,10 @@ #include "klee/System/Time.h" #include "klee/Support/CompilerWarning.h" -#include "llvm/Analysis/CallGraph.h" -#include "llvm/IR/Attributes.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS #include "llvm/ADT/APFloat.h" +#include "llvm/Analysis/CallGraph.h" #include "llvm/Bitcode/BitcodeReader.h" +#include "llvm/IR/Attributes.h" #include "llvm/IR/Constants.h" #include "llvm/IR/IRBuilder.h" #include "llvm/IR/InstIterator.h" @@ -46,13 +43,11 @@ DISABLE_WARNING_DEPRECATED_DECLARATIONS #include "llvm/Support/FileSystem.h" #include "llvm/Support/Host.h" #include "llvm/Support/ManagedStatic.h" -#include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/Path.h" #include "llvm/Support/raw_ostream.h" #include "llvm/Support/Signals.h" #include "llvm/Support/TargetSelect.h" -DISABLE_WARNING_POP #include #include @@ -65,7 +60,6 @@ DISABLE_WARNING_POP #include #include #include -#include #include using json = nlohmann::json; @@ -457,25 +451,27 @@ class KleeHandler : public InterpreterHandler { KleeHandler(int argc, char **argv); ~KleeHandler(); - llvm::raw_ostream &getInfoStream() const { return *m_infoFile; } + llvm::raw_ostream &getInfoStream() const override { return *m_infoFile; } /// Returns the number of test cases successfully generated so far unsigned getNumTestCases() { return m_numGeneratedTests; } unsigned getNumPathsCompleted() { return m_pathsCompleted; } unsigned getNumPathsExplored() { return m_pathsExplored; } - void incPathsCompleted() { ++m_pathsCompleted; } - void incPathsExplored(std::uint32_t num = 1) { m_pathsExplored += num; } + void incPathsCompleted() override { ++m_pathsCompleted; } + void incPathsExplored(std::uint32_t num = 1) override { + m_pathsExplored += num; + } void setInterpreter(Interpreter *i); void processTestCase(const ExecutionState &state, const char *message, - const char *suffix, bool isError = false); + const char *suffix, bool isError = false) override; void writeTestCaseXML(bool isError, const KTest &out, unsigned id, unsigned version = 0); - std::string getOutputFilename(const std::string &filename); + std::string getOutputFilename(const std::string &filename) override; std::unique_ptr - openOutputFile(const std::string &filename); + openOutputFile(const std::string &filename) override; std::string getTestFilename(const std::string &suffix, unsigned id, unsigned version = 0); std::unique_ptr diff --git a/unittests/Assignment/AssignmentTest.cpp b/unittests/Assignment/AssignmentTest.cpp index 0cef29239a..34072755aa 100644 --- a/unittests/Assignment/AssignmentTest.cpp +++ b/unittests/Assignment/AssignmentTest.cpp @@ -5,7 +5,6 @@ #include "klee/Expr/Assignment.h" #include "klee/Expr/SourceBuilder.h" -#include #include int finished = 0; diff --git a/unittests/CMakeLists.txt b/unittests/CMakeLists.txt index e08637aee2..549f06f8ba 100644 --- a/unittests/CMakeLists.txt +++ b/unittests/CMakeLists.txt @@ -148,9 +148,9 @@ else() endif() # add includes for LLVM's modifications - target_include_directories(gtest BEFORE PRIVATE ${LLVM_INCLUDE_DIRS}) + target_include_directories(gtest SYSTEM BEFORE PRIVATE ${LLVM_INCLUDE_DIRS}) # we cannot disable gtest_main, but will not use it later - target_include_directories(gtest_main BEFORE PRIVATE ${LLVM_INCLUDE_DIRS}) + target_include_directories(gtest_main SYSTEM BEFORE PRIVATE ${LLVM_INCLUDE_DIRS}) endif() # try using system installation of GTest instead @@ -248,9 +248,9 @@ target_link_libraries(unittest_main ${GTEST_TARGET_NAME} ) target_include_directories(unittest_main + SYSTEM INTERFACE ${KLEE_COMPONENT_EXTRA_INCLUDE_DIRS} - PRIVATE ${LLVM_INCLUDE_DIRS} ) diff --git a/unittests/DiscretePDF/DiscretePDFTest.cpp b/unittests/DiscretePDF/DiscretePDFTest.cpp index 502a43ab5a..cdec74add2 100644 --- a/unittests/DiscretePDF/DiscretePDFTest.cpp +++ b/unittests/DiscretePDF/DiscretePDFTest.cpp @@ -1,7 +1,5 @@ #include "klee/ADT/DiscretePDF.h" #include "gtest/gtest.h" -#include -#include int finished = 0; diff --git a/unittests/Expr/ArrayExprTest.cpp b/unittests/Expr/ArrayExprTest.cpp index 9d0811268a..d6eb799d57 100644 --- a/unittests/Expr/ArrayExprTest.cpp +++ b/unittests/Expr/ArrayExprTest.cpp @@ -16,13 +16,7 @@ #include "klee/Expr/Expr.h" #include "klee/Expr/SourceBuilder.h" -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS #include "llvm/Support/CommandLine.h" -DISABLE_WARNING_POP - -#include using namespace klee; namespace klee { diff --git a/unittests/Expr/ExprTest.cpp b/unittests/Expr/ExprTest.cpp index 67d2b0fbda..e854dc7b68 100644 --- a/unittests/Expr/ExprTest.cpp +++ b/unittests/Expr/ExprTest.cpp @@ -8,7 +8,6 @@ //===----------------------------------------------------------------------===// #include "gtest/gtest.h" -#include #include "klee/Expr/ArrayCache.h" #include "klee/Expr/Expr.h" diff --git a/unittests/Ref/CMakeLists.txt b/unittests/Ref/CMakeLists.txt index f60927d85e..79d41795fa 100644 --- a/unittests/Ref/CMakeLists.txt +++ b/unittests/Ref/CMakeLists.txt @@ -1,7 +1,7 @@ add_klee_unit_test(RefTest RefTest.cpp) target_link_libraries(RefTest PRIVATE kleaverExpr) -target_compile_options(RefTest PRIVATE ${KLEE_COMPONENT_CXX_FLAGS}) +target_compile_options(RefTest PRIVATE ${KLEE_COMPONENT_CXX_FLAGS} "-Wno-self-assign-overloaded" "-Wno-self-move") target_compile_definitions(RefTest PRIVATE ${KLEE_COMPONENT_CXX_DEFINES}) target_include_directories(RefTest PRIVATE ${KLEE_INCLUDE_DIRS}) diff --git a/unittests/Ref/RefTest.cpp b/unittests/Ref/RefTest.cpp index bf313513a9..c9ca495f71 100644 --- a/unittests/Ref/RefTest.cpp +++ b/unittests/Ref/RefTest.cpp @@ -13,7 +13,6 @@ #include "klee/ADT/Ref.h" #include "gtest/gtest.h" -#include using klee::ref; diff --git a/unittests/Searcher/SearcherTest.cpp b/unittests/Searcher/SearcherTest.cpp index 7cabaf8474..0317280766 100644 --- a/unittests/Searcher/SearcherTest.cpp +++ b/unittests/Searcher/SearcherTest.cpp @@ -6,7 +6,7 @@ // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// -#include "klee/Core/BranchTypes.h" + #define KLEE_UNITTEST #include "gtest/gtest.h" @@ -17,11 +17,7 @@ #include "Core/Searcher.h" #include "klee/ADT/RNG.h" -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS #include "llvm/Support/raw_ostream.h" -DISABLE_WARNING_POP using namespace klee; @@ -46,7 +42,7 @@ TEST(SearcherTest, RandomPath) { // Two states ExecutionState es1(es); - processForest.attach(es.ptreeNode, &es1, &es, BranchType::NONE); + processForest.attach(es.ptreeNode, &es1, &es); rp.update(&es, {&es1}, {}); // Random path seed dependant @@ -80,7 +76,7 @@ TEST(SearcherTest, TwoRandomPath) { ->root.getPointer(); ExecutionState es(root); - processForest.attach(root.ptreeNode, &es, &root, BranchType::NONE); + processForest.attach(root.ptreeNode, &es, &root); RNG rng, rng1; RandomPathSearcher rp(processForest, rng); @@ -95,7 +91,7 @@ TEST(SearcherTest, TwoRandomPath) { // Two states ExecutionState es1(es); - processForest.attach(es.ptreeNode, &es1, &es, BranchType::NONE); + processForest.attach(es.ptreeNode, &es1, &es); rp.update(&es, {}, {}); rp1.update(nullptr, {&es1}, {}); @@ -142,7 +138,7 @@ TEST(SearcherTest, TwoRandomPathDot) { rootPNode = root.ptreeNode; ExecutionState es(root); - processForest.attach(root.ptreeNode, &es, &root, BranchType::NONE); + processForest.attach(root.ptreeNode, &es, &root); rightLeafPNode = root.ptreeNode; esParentPNode = es.ptreeNode; @@ -153,7 +149,7 @@ TEST(SearcherTest, TwoRandomPathDot) { rp.update(nullptr, {&es}, {}); ExecutionState es1(es); - processForest.attach(es.ptreeNode, &es1, &es, BranchType::NONE); + processForest.attach(es.ptreeNode, &es1, &es); esLeafPNode = es.ptreeNode; es1LeafPNode = es1.ptreeNode; diff --git a/unittests/Solver/SolverTest.cpp b/unittests/Solver/SolverTest.cpp index 04cdddec05..81744bc9aa 100644 --- a/unittests/Solver/SolverTest.cpp +++ b/unittests/Solver/SolverTest.cpp @@ -16,14 +16,6 @@ #include "klee/Solver/Solver.h" #include "klee/Solver/SolverCmdLine.h" -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS -#include "llvm/ADT/StringExtras.h" -DISABLE_WARNING_POP - -#include - using namespace klee; namespace { diff --git a/unittests/Solver/Z3SolverTest.cpp b/unittests/Solver/Z3SolverTest.cpp index 8820263332..97d110b209 100644 --- a/unittests/Solver/Z3SolverTest.cpp +++ b/unittests/Solver/Z3SolverTest.cpp @@ -8,15 +8,12 @@ // //===----------------------------------------------------------------------===// -#include -#include #include #include "gtest/gtest.h" #include "klee/ADT/SparseStorage.h" #include "klee/Expr/ArrayCache.h" -#include "klee/Expr/Constraints.h" #include "klee/Expr/Expr.h" #include "klee/Expr/SourceBuilder.h" #include "klee/Solver/Solver.h" diff --git a/unittests/TestMain.cpp b/unittests/TestMain.cpp index b6400d6630..9512e59a79 100644 --- a/unittests/TestMain.cpp +++ b/unittests/TestMain.cpp @@ -7,12 +7,8 @@ // //===----------------------------------------------------------------------===// -#include "klee/Support/CompilerWarning.h" -DISABLE_WARNING_PUSH -DISABLE_WARNING_DEPRECATED_DECLARATIONS #include "llvm/ADT/StringRef.h" #include "llvm/Support/Signals.h" -DISABLE_WARNING_POP #include "gtest/gtest.h"