[PATCH] D52031: [analyzer] Small SMT API improvement

2018-10-13 Thread Enrico Steffinlongo via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC344463: [analyzer] Small SMT API improvement (authored by 
esteffin, committed by ).
Herald added subscribers: cfe-commits, donat.nagy.

Repository:
  rC Clang

https://reviews.llvm.org/D52031

Files:
  include/clang/StaticAnalyzer/Core/PathSensitive/SMTSolver.h
  lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp


Index: lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp
===
--- lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp
+++ lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp
@@ -859,7 +859,7 @@
   }
 
   /// Reset the solver and remove all constraints.
-  void reset() const override { Z3_solver_reset(Context.Context, Solver); }
+  void reset() override { Z3_solver_reset(Context.Context, Solver); }
 
   void print(raw_ostream &OS) const override {
 OS << Z3_solver_to_string(Context.Context, Solver);
Index: include/clang/StaticAnalyzer/Core/PathSensitive/SMTSolver.h
===
--- include/clang/StaticAnalyzer/Core/PathSensitive/SMTSolver.h
+++ include/clang/StaticAnalyzer/Core/PathSensitive/SMTSolver.h
@@ -283,7 +283,7 @@
   virtual void pop(unsigned NumStates = 1) = 0;
 
   /// Reset the solver and remove all constraints.
-  virtual void reset() const = 0;
+  virtual void reset() = 0;
 
   virtual void print(raw_ostream &OS) const = 0;
 };


Index: lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp
===
--- lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp
+++ lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp
@@ -859,7 +859,7 @@
   }
 
   /// Reset the solver and remove all constraints.
-  void reset() const override { Z3_solver_reset(Context.Context, Solver); }
+  void reset() override { Z3_solver_reset(Context.Context, Solver); }
 
   void print(raw_ostream &OS) const override {
 OS << Z3_solver_to_string(Context.Context, Solver);
Index: include/clang/StaticAnalyzer/Core/PathSensitive/SMTSolver.h
===
--- include/clang/StaticAnalyzer/Core/PathSensitive/SMTSolver.h
+++ include/clang/StaticAnalyzer/Core/PathSensitive/SMTSolver.h
@@ -283,7 +283,7 @@
   virtual void pop(unsigned NumStates = 1) = 0;
 
   /// Reset the solver and remove all constraints.
-  virtual void reset() const = 0;
+  virtual void reset() = 0;
 
   virtual void print(raw_ostream &OS) const = 0;
 };
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D50818: [analyzer] Improved cmake configuration for Z3

2018-10-13 Thread Enrico Steffinlongo via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC344464: [analyzer] Improved cmake configuration for Z3 
(authored by esteffin, committed by ).
Herald added subscribers: cfe-commits, donat.nagy.

Repository:
  rC Clang

https://reviews.llvm.org/D50818

Files:
  CMakeLists.txt
  cmake/modules/FindZ3.cmake
  lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp

Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -394,22 +394,35 @@
 option(CLANG_ENABLE_ARCMT "Build ARCMT." ON)
 option(CLANG_ENABLE_STATIC_ANALYZER "Build static analyzer." ON)
 
-option(CLANG_ANALYZER_BUILD_Z3
-  "Build the static analyzer with the Z3 constraint manager." OFF)
+set(CLANG_ANALYZER_Z3_INSTALL_DIR "" CACHE STRING "Install directory of the Z3 solver.")
 
-option(CLANG_ENABLE_PROTO_FUZZER "Build Clang protobuf fuzzer." OFF)
+find_package(Z3 4.7.1 EXACT)
 
-if(NOT CLANG_ENABLE_STATIC_ANALYZER AND (CLANG_ENABLE_ARCMT OR CLANG_ANALYZER_BUILD_Z3))
-  message(FATAL_ERROR "Cannot disable static analyzer while enabling ARCMT or Z3")
+if (CLANG_ANALYZER_Z3_INSTALL_DIR)
+  if (NOT Z3_FOUND)
+message(FATAL_ERROR "Z3 4.7.1 has not been found in CLANG_ANALYZER_Z3_INSTALL_DIR: ${CLANG_ANALYZER_Z3_INSTALL_DIR}.")
+  endif()
 endif()
 
-if(CLANG_ANALYZER_BUILD_Z3)
-  find_package(Z3 4.5)
-  if(Z3_FOUND)
-set(CLANG_ANALYZER_WITH_Z3 1)
-  else()
-message(FATAL_ERROR "Cannot find Z3 header file or shared library")
+set(CLANG_ANALYZER_ENABLE_Z3_SOLVER_DEFAULT "${Z3_FOUND}")
+
+option(CLANG_ANALYZER_ENABLE_Z3_SOLVER
+  "Enable Support for the Z3 constraint solver in the Clang Static Analyzer."
+  ${CLANG_ANALYZER_ENABLE_Z3_SOLVER_DEFAULT}
+)
+
+if (CLANG_ANALYZER_ENABLE_Z3_SOLVER)
+  if (NOT Z3_FOUND)
+message(FATAL_ERROR "CLANG_ANALYZER_ENABLE_Z3_SOLVER cannot be enabled when Z3 is not available.")
   endif()
+
+  set(CLANG_ANALYZER_WITH_Z3 1)
+endif()
+
+option(CLANG_ENABLE_PROTO_FUZZER "Build Clang protobuf fuzzer." OFF)
+
+if(NOT CLANG_ENABLE_STATIC_ANALYZER AND (CLANG_ENABLE_ARCMT OR CLANG_ANALYZER_ENABLE_Z3_SOLVER))
+  message(FATAL_ERROR "Cannot disable static analyzer while enabling ARCMT or Z3")
 endif()
 
 if(CLANG_ENABLE_ARCMT)
Index: lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp
===
--- lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp
+++ lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp
@@ -926,7 +926,7 @@
   return llvm::make_unique();
 #else
   llvm::report_fatal_error("Clang was not compiled with Z3 support, rebuild "
-   "with -DCLANG_ANALYZER_BUILD_Z3=ON",
+   "with -DCLANG_ANALYZER_ENABLE_Z3_SOLVER=ON",
false);
   return nullptr;
 #endif
@@ -938,7 +938,7 @@
   return llvm::make_unique(Eng, StMgr.getSValBuilder());
 #else
   llvm::report_fatal_error("Clang was not compiled with Z3 support, rebuild "
-   "with -DCLANG_ANALYZER_BUILD_Z3=ON",
+   "with -DCLANG_ANALYZER_ENABLE_Z3_SOLVER=ON",
false);
   return nullptr;
 #endif
Index: cmake/modules/FindZ3.cmake
===
--- cmake/modules/FindZ3.cmake
+++ cmake/modules/FindZ3.cmake
@@ -1,13 +1,36 @@
+# Looking for Z3 in CLANG_ANALYZER_Z3_INSTALL_DIR
 find_path(Z3_INCLUDE_DIR NAMES z3.h
+   NO_DEFAULT_PATH
+   PATHS ${CLANG_ANALYZER_Z3_INSTALL_DIR}/include
PATH_SUFFIXES libz3 z3
)
 
 find_library(Z3_LIBRARIES NAMES z3 libz3
+   NO_DEFAULT_PATH
+   PATHS ${CLANG_ANALYZER_Z3_INSTALL_DIR}
+   PATH_SUFFIXES lib bin
)
 
-find_program(Z3_EXECUTABLE z3)
+find_program(Z3_EXECUTABLE z3
+   NO_DEFAULT_PATH
+   PATHS ${CLANG_ANALYZER_Z3_INSTALL_DIR}
+   PATH_SUFFIXES bin
+   )
+
+# If Z3 has not been found in CLANG_ANALYZER_Z3_INSTALL_DIR look in the default directories
+find_path(Z3_INCLUDE_DIR NAMES z3.h
+   PATH_SUFFIXES libz3 z3
+   )
+
+find_library(Z3_LIBRARIES NAMES z3 libz3
+   PATH_SUFFIXES lib bin
+   )
+
+find_program(Z3_EXECUTABLE z3
+   PATH_SUFFIXES bin
+   )
 
-if(Z3_INCLUDE_DIR AND Z3_EXECUTABLE)
+if(Z3_INCLUDE_DIR AND Z3_LIBRARIES AND Z3_EXECUTABLE)
 execute_process (COMMAND ${Z3_EXECUTABLE} -version
   OUTPUT_VARIABLE libz3_version_str
   ERROR_QUIET
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits