Skip to content

Commit

Permalink
More robust "KnownNames" resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
davidsemakula committed Jan 1, 2025
1 parent f08968e commit 5768d8e
Show file tree
Hide file tree
Showing 7 changed files with 489 additions and 452 deletions.
57 changes: 33 additions & 24 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified binaries/summary_store.tar
Binary file not shown.
5 changes: 1 addition & 4 deletions checker/src/block_visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use rustc_span::source_map::Spanned;
use rustc_target::abi::{FieldIdx, Primitive, TagEncoding, VariantIdx, Variants};
use rustc_trait_selection::infer::TyCtxtInferExt;

use crate::abstract_value::{AbstractValue, AbstractValueTrait, BOTTOM};
use crate::abstract_value::{self, AbstractValue, AbstractValueTrait, BOTTOM};
use crate::body_visitor::BodyVisitor;
use crate::call_visitor::CallVisitor;
use crate::constant_domain::{ConstantDomain, FunctionReference};
Expand All @@ -43,7 +43,6 @@ use crate::summaries::Precondition;
use crate::tag_domain::Tag;
use crate::type_visitor::TypeVisitor;
use crate::utils;
use crate::{abstract_value, known_names};

/// Holds the state for the basic block visitor
pub struct BlockVisitor<'block, 'analysis, 'compilation, 'tcx> {
Expand Down Expand Up @@ -722,7 +721,6 @@ impl<'block, 'analysis, 'compilation, 'tcx> BlockVisitor<'block, 'analysis, 'com
.block_to_call
.insert(current_location, callee_def_id);

let tcx = self.bv.tcx;
let mut call_visitor = CallVisitor::new(
self,
callee_def_id,
Expand Down Expand Up @@ -753,7 +751,6 @@ impl<'block, 'analysis, 'compilation, 'tcx> BlockVisitor<'block, 'analysis, 'com
.already_reported_errors_for_call_to
.insert(call_visitor.callee_fun_val.clone())
{
let _kn = known_names::KnownNamesCache::get_known_name_for(tcx, callee_def_id);
call_visitor.block_visitor.report_missing_summary();
if known_name != KnownNames::StdCloneClone
&& !call_visitor.block_visitor.bv.analysis_is_incomplete
Expand Down
3 changes: 2 additions & 1 deletion checker/src/callbacks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,14 +151,15 @@ impl MiraiCallbacks {
self.file_name, summary_store_path
);
let call_graph_config = self.options.call_graph_config.to_owned();
let lang_items = tcx.lang_items();
let mut crate_visitor = CrateVisitor {
buffered_diagnostics: Vec::new(),
constant_time_tag_cache: None,
constant_time_tag_not_found: false,
constant_value_cache: ConstantValueCache::default(),
diagnostics_for: HashMap::new(),
file_name: self.file_name.as_str(),
known_names_cache: KnownNamesCache::create_cache_from_language_items(),
known_names_cache: KnownNamesCache::create_cache_from_language_items(lang_items),
options: &std::mem::take(&mut self.options),
session: &compiler.sess,
generic_args_cache: HashMap::new(),
Expand Down
2 changes: 1 addition & 1 deletion checker/src/crate_visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ pub struct CrateVisitor<'compilation, 'tcx> {
pub diagnostics_for: HashMap<DefId, Vec<Diag<'compilation, ()>>>,
pub file_name: &'compilation str,
pub generic_args_cache: HashMap<DefId, GenericArgsRef<'tcx>>,
pub known_names_cache: KnownNamesCache,
pub known_names_cache: KnownNamesCache<'tcx>,
pub options: &'compilation Options,
pub session: &'compilation Session,
pub summary_cache: SummaryCache<'tcx>,
Expand Down
Loading

0 comments on commit 5768d8e

Please sign in to comment.