diff options
author | Ian Lance Taylor <iant@golang.org> | 2021-09-13 10:37:49 -0700 |
---|---|---|
committer | Ian Lance Taylor <iant@golang.org> | 2021-09-13 10:37:49 -0700 |
commit | e252b51ccde010cbd2a146485d8045103cd99533 (patch) | |
tree | e060f101cdc32bf5e520de8e5275db9d4236b74c /gcc/analyzer/sm-pattern-test.cc | |
parent | f10c7c4596dda99d2ee872c995ae4aeda65adbdf (diff) | |
parent | 104c05c5284b7822d770ee51a7d91946c7e56d50 (diff) | |
download | gcc-e252b51ccde010cbd2a146485d8045103cd99533.zip gcc-e252b51ccde010cbd2a146485d8045103cd99533.tar.gz gcc-e252b51ccde010cbd2a146485d8045103cd99533.tar.bz2 |
Merge from trunk revision 104c05c5284b7822d770ee51a7d91946c7e56d50.
Diffstat (limited to 'gcc/analyzer/sm-pattern-test.cc')
-rw-r--r-- | gcc/analyzer/sm-pattern-test.cc | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/gcc/analyzer/sm-pattern-test.cc b/gcc/analyzer/sm-pattern-test.cc index 43b8475..4e28549 100644 --- a/gcc/analyzer/sm-pattern-test.cc +++ b/gcc/analyzer/sm-pattern-test.cc @@ -37,6 +37,12 @@ along with GCC; see the file COPYING3. If not see #include "analyzer/analyzer-logging.h" #include "analyzer/sm.h" #include "analyzer/pending-diagnostic.h" +#include "tristate.h" +#include "selftest.h" +#include "analyzer/call-string.h" +#include "analyzer/program-point.h" +#include "analyzer/store.h" +#include "analyzer/region-model.h" #if ENABLE_ANALYZER @@ -61,9 +67,9 @@ public: void on_condition (sm_context *sm_ctxt, const supernode *node, const gimple *stmt, - tree lhs, + const svalue *lhs, enum tree_code op, - tree rhs) const FINAL OVERRIDE; + const svalue *rhs) const FINAL OVERRIDE; bool can_purge_p (state_t s) const FINAL OVERRIDE; }; @@ -118,18 +124,22 @@ void pattern_test_state_machine::on_condition (sm_context *sm_ctxt, const supernode *node, const gimple *stmt, - tree lhs, + const svalue *lhs, enum tree_code op, - tree rhs) const + const svalue *rhs) const { if (stmt == NULL) return; - if (!CONSTANT_CLASS_P (rhs)) + tree rhs_cst = rhs->maybe_get_constant (); + if (!rhs_cst) return; - pending_diagnostic *diag = new pattern_match (lhs, op, rhs); - sm_ctxt->warn (node, stmt, lhs, diag); + if (tree lhs_expr = sm_ctxt->get_diagnostic_tree (lhs)) + { + pending_diagnostic *diag = new pattern_match (lhs_expr, op, rhs_cst); + sm_ctxt->warn (node, stmt, lhs_expr, diag); + } } bool |