summaryrefslogtreecommitdiff
path: root/src/ir/function.rs
diff options
context:
space:
mode:
authorzzhu <zzhu@mozilla.com>2017-08-02 11:19:14 -0700
committerZhiting Zhu <zzhu@mozilla.com>2017-08-09 15:19:00 -0700
commit923ee36d64039b83b0a9ffce7b92e1602fc79abd (patch)
treefed373a5bb4eb87b3d60f08ffaba66ed72b84544 /src/ir/function.rs
parentb6400942670694782d87ec0e2393463646e44eb9 (diff)
Can derive Hash analysis
Diffstat (limited to 'src/ir/function.rs')
-rw-r--r--src/ir/function.rs19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/ir/function.rs b/src/ir/function.rs
index 99ab8772..20c026a4 100644
--- a/src/ir/function.rs
+++ b/src/ir/function.rs
@@ -8,11 +8,13 @@ use super::traversal::{EdgeKind, Trace, Tracer};
use super::ty::TypeKind;
use clang;
use clang_sys::{self, CXCallingConv};
-use ir::derive::CanTriviallyDeriveDebug;
+use ir::derive::{CanTriviallyDeriveDebug, CanTriviallyDeriveHash};
use parse::{ClangItemParser, ClangSubItemParser, ParseError, ParseResult};
use std::io;
use syntax::abi;
+const RUST_DERIVE_FUNPTR_LIMIT: usize = 12;
+
/// What kind of a function are we looking at?
#[derive(Debug, Copy, Clone, PartialEq)]
pub enum FunctionKind {
@@ -481,7 +483,20 @@ impl Trace for FunctionSig {
// Note that copy is always derived, so we don't need to implement it.
impl CanTriviallyDeriveDebug for FunctionSig {
fn can_trivially_derive_debug(&self) -> bool {
- const RUST_DERIVE_FUNPTR_LIMIT: usize = 12;
+ if self.argument_types.len() > RUST_DERIVE_FUNPTR_LIMIT {
+ return false;
+ }
+
+ match self.abi {
+ Abi::Known(abi::Abi::C) |
+ Abi::Unknown(..) => true,
+ _ => false,
+ }
+ }
+}
+
+impl CanTriviallyDeriveHash for FunctionSig {
+ fn can_trivially_derive_hash(&self) -> bool {
if self.argument_types.len() > RUST_DERIVE_FUNPTR_LIMIT {
return false;
}