diff options
author | Philip Chimento <philip.chimento@gmail.com> | 2019-12-12 20:25:05 -0800 |
---|---|---|
committer | Philip Chimento <philip.chimento@gmail.com> | 2019-12-16 15:39:34 -0500 |
commit | 5fb0dafcafbb34a503b301f807fb5c8a6efe326a (patch) | |
tree | 5c2811f1e7b0ebf9e4676420168ca2da9fb67811 | |
parent | 5ff697b4d9d173f1c131811b0c30b4eeb3dbc26d (diff) |
clang-plugin: Support LLVM 9.0
The main difference here is that evalCall checkers have changed to take
a CallEvent& parameter rather than a CallExpr* parameter. For version 9
we convert the CallEvent& into a CallExpr* as soon as we receive it.
This may need to be refactored in the future, as CallEvent is the more
modern API and covers syntax that CallExpr doesn't cover, but that is a
large refactor better left for when it becomes necessary or when LLVM 9
becomes the minimum version.
-rw-r--r-- | clang-plugin/gerror-checker.cpp | 12 | ||||
-rw-r--r-- | clang-plugin/gerror-checker.h | 9 | ||||
-rw-r--r-- | configure.ac | 3 |
3 files changed, 22 insertions, 2 deletions
diff --git a/clang-plugin/gerror-checker.cpp b/clang-plugin/gerror-checker.cpp index 8301a44..df9f5c7 100644 --- a/clang-plugin/gerror-checker.cpp +++ b/clang-plugin/gerror-checker.cpp @@ -505,9 +505,19 @@ GErrorChecker::checkPreCall (const CallEvent &call, /* Dispatch call-evaluation events to the different per-function handlers. * Return true iff the call was evaluated. */ bool -GErrorChecker::evalCall (const CallExpr *call, +GErrorChecker::evalCall ( +#ifdef HAVE_LLVM_9_0 + const CallEvent &call_event, +#else + const CallExpr *call, +#endif CheckerContext &context) const { +#ifdef HAVE_LLVM_9_0 + const CallExpr *call = llvm::dyn_cast<CallExpr>(call_event.getOriginExpr()); + if (!call) + return false; +#endif const FunctionDecl *func_decl = context.getCalleeDecl (call); if (func_decl == NULL || diff --git a/clang-plugin/gerror-checker.h b/clang-plugin/gerror-checker.h index 5fdff0e..1d7ce80 100644 --- a/clang-plugin/gerror-checker.h +++ b/clang-plugin/gerror-checker.h @@ -23,6 +23,8 @@ #ifndef TARTAN_GERROR_CHECKER_H #define TARTAN_GERROR_CHECKER_H +#include "config.h" + #include <clang/AST/AST.h> #include <clang/StaticAnalyzer/Core/BugReporter/BugType.h> #include <clang/StaticAnalyzer/Core/Checker.h> @@ -159,7 +161,12 @@ private: public: void checkPreCall (const CallEvent &call, CheckerContext &context) const; - bool evalCall (const CallExpr *call, + bool evalCall ( +#ifdef HAVE_LLVM_9_0 + const CallEvent &call_event, +#else + const CallExpr *call, +#endif CheckerContext &context) const; void checkBind (SVal loc, SVal val, const Stmt *stmt, CheckerContext &context) const; diff --git a/configure.ac b/configure.ac index 89ef86a..ab6e12b 100644 --- a/configure.ac +++ b/configure.ac @@ -91,6 +91,9 @@ AC_DEFINE_UNQUOTED([LLVM_CONFIG_VERSION],"$llvm_version", AS_IF([test "$major" -ge 8],[ AC_DEFINE([HAVE_LLVM_8_0], [1], [Whether LLVM ≥ 8.0 is available]) ]) +AS_IF([test "$major" -ge 9],[ + AC_DEFINE([HAVE_LLVM_9_0], [1], [Whether LLVM ≥ 9.0 is available]) +]) # Clang dependency (e.g. the clang-devel package on Fedora) AC_LANG_PUSH([C++]) |