diff options
author | Philip Herron <philip.herron@embecosm.com> | 2022-03-04 15:14:12 +0000 |
---|---|---|
committer | Philip Herron <philip.herron@embecosm.com> | 2022-03-07 12:16:18 +0000 |
commit | 7820ff8b8b14e1309aade205e50ef30bb08cb3e5 (patch) | |
tree | 33ca33f20795707b58b694fab16039d0c2c7374a /gcc/rust/rust-session-manager.cc | |
parent | e00311aa9aabf447f27031cc5ffc114c5fbd8551 (diff) | |
download | gcc-7820ff8b8b14e1309aade205e50ef30bb08cb3e5.zip gcc-7820ff8b8b14e1309aade205e50ef30bb08cb3e5.tar.gz gcc-7820ff8b8b14e1309aade205e50ef30bb08cb3e5.tar.bz2 |
Remove old unused code pass this was too generic
This now uses the TREE_USED fields on GCC tree's to track the usage of
VAR_DECLS, PARM_DECLS and CONST_DECLS. The code does a pass over the body
and parameters of functions as a lint pass.
Fixes #676
Diffstat (limited to 'gcc/rust/rust-session-manager.cc')
-rw-r--r-- | gcc/rust/rust-session-manager.cc | 29 |
1 files changed, 10 insertions, 19 deletions
diff --git a/gcc/rust/rust-session-manager.cc b/gcc/rust/rust-session-manager.cc index 54a6443..396f35f 100644 --- a/gcc/rust/rust-session-manager.cc +++ b/gcc/rust/rust-session-manager.cc @@ -25,11 +25,11 @@ #include "rust-ast-resolve.h" #include "rust-ast-lower.h" #include "rust-hir-type-check.h" -#include "rust-lint-scan-deadcode.h" #include "rust-tycheck-dump.h" -#include "rust-ast-resolve-unused.h" #include "rust-compile.h" #include "rust-cfg-parser.h" +#include "rust-lint-scan-deadcode.h" +#include "rust-lint-unused-var.h" #include "diagnostic.h" #include "input.h" @@ -599,27 +599,18 @@ Session::parse_file (const char *filename) if (saw_errors ()) return; - // scan dead code - Analysis::ScanDeadcode::Scan (hir); - - if (saw_errors ()) - return; - - // scan unused has to be done after type resolution since methods are - // resolved at that point - Resolver::ScanUnused::Scan (); - - if (saw_errors ()) - return; - - // do compile + // do compile to gcc generic Compile::Context ctx (backend); Compile::CompileCrate::Compile (hir, &ctx); - if (saw_errors ()) - return; + // we can't do static analysis if there are errors to worry about + if (!saw_errors ()) + { + Analysis::ScanDeadcode::Scan (hir); + Analysis::UnusedVariables::Lint (ctx); + } - // pass to GCC + // pass to GCC middle-end ctx.write_to_backend (); } |