This is an archive of the discontinued LLVM Phabricator instance.

[analyzer] Don't crash if the analyzer-constraint is set to Z3, but llvm is not built with it
ClosedPublic

Authored by Szelethus on Feb 22 2022, 6:55 AM.

Details

Summary

Exactly what it says on the tin! We had a nasty crash with the following incovation:

$ clang --analyze -Xclang -analyzer-constraints=z3 test.c
fatal error: error in backend: LLVM was not compiled with Z3 support, rebuild with -DLLVM_ENABLE_Z3_SOLVER=ON
... <stack trace> ...

Diff Detail

Event Timeline

Szelethus created this revision.Feb 22 2022, 6:55 AM
Szelethus requested review of this revision.Feb 22 2022, 6:55 AM
steakhal accepted this revision.Feb 22 2022, 9:30 AM

Thanks. LGTM.

Besides abusing the -analyzer-constraints=z3 option we should really have some way displaying whether or not this clang was built w/o Z3.

I'm accepting this, given that you fix the conditional code segment.

clang/lib/Frontend/CompilerInvocation.cpp
918–922

This define is produced by the llvm/include/llvm/Config/llvm-config.h.cmake cmake configuration file.

/* Define if we have z3 and want to build it */
#cmakedefine LLVM_WITH_Z3 ${LLVM_WITH_Z3}

And according to the cmake configure_file
#cmakedefine VAR ... will be either defined or not defined.

This revision is now accepted and ready to land.Feb 22 2022, 9:30 AM
This revision was landed with ongoing or failed builds.Feb 25 2022, 7:52 AM
This revision was automatically updated to reflect the committed changes.