Skip to content

Commit 9721a9e

Browse files
committed
Implement m_inlined function matcher
1 parent 2e36256 commit 9721a9e

File tree

4 files changed

+24
-0
lines changed

4 files changed

+24
-0
lines changed

docs/MatcherFunctions.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
| m_function_def | () | FunctionMatcher | Create Matcher to match template definition |
77
| m_template_function | () | FunctionMatcher | Create Matcher to match template function |
88
| m_conversion_function | () | FunctionMatcher | Create Matcher to match conversion function |
9+
| m_inlined | () | FunctionMatcher | Create Matcher to match inlined function |
910
| m_virtual | () | FunctionMatcher | Create Matcher to match virtual function |
1011
| m_pure_virtual | () | FunctionMatcher | Create Matcher to match pure virtual function |
1112
| m_method | () | FunctionMatcher | Create Matcher to match method |

src/clang_ql/functions/matchers/function.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ use crate::clang_ql::matchers::IsDeletedMethodMatcher;
1717
use crate::clang_ql::matchers::IsDestructorMatcher;
1818
use crate::clang_ql::matchers::IsFunctionDeclaration;
1919
use crate::clang_ql::matchers::IsFunctionDefination;
20+
use crate::clang_ql::matchers::IsInlineFunction;
2021
use crate::clang_ql::matchers::IsMethodMatcher;
2122
use crate::clang_ql::matchers::IsMoveConstructorMatcher;
2223
use crate::clang_ql::matchers::IsPureVirtualMatcher;
@@ -38,6 +39,7 @@ pub(crate) fn register_function_matchers_functions(
3839
map.insert("m_function_def", match_function_defination);
3940
map.insert("m_template_function", match_template_function);
4041
map.insert("m_conversion_function", match_conversion_function);
42+
map.insert("m_inlined", match_inlined_function);
4143
map.insert("m_virtual", match_virtual_function);
4244
map.insert("m_pure_virtual", match_pure_virtual_function);
4345
map.insert("m_static", match_static_function);
@@ -84,6 +86,11 @@ pub(crate) fn register_function_matchers_signatures(map: &mut HashMap<&'static s
8486
Signature::with_return(Box::new(FunctionMatcherType)),
8587
);
8688

89+
map.insert(
90+
"m_inlined",
91+
Signature::with_return(Box::new(FunctionMatcherType)),
92+
);
93+
8794
map.insert(
8895
"m_conversion_function",
8996
Signature::with_return(Box::new(FunctionMatcherType)),
@@ -190,6 +197,11 @@ fn match_conversion_function(_values: &[Box<dyn Value>]) -> Box<dyn Value> {
190197
Box::new(FunctionMatcherValue::new(matcher))
191198
}
192199

200+
fn match_inlined_function(_values: &[Box<dyn Value>]) -> Box<dyn Value> {
201+
let matcher = Box::new(IsInlineFunction);
202+
Box::new(FunctionMatcherValue::new(matcher))
203+
}
204+
193205
fn match_virtual_function(_values: &[Box<dyn Value>]) -> Box<dyn Value> {
194206
let matcher = Box::new(IsVirtualMatcher);
195207
Box::new(FunctionMatcherValue::new(matcher))

src/clang_ql/matchers/function.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use clang_sys::clang_CXXMethod_isConst;
66
use clang_sys::clang_CXXMethod_isPureVirtual;
77
use clang_sys::clang_CXXMethod_isStatic;
88
use clang_sys::clang_CXXMethod_isVirtual;
9+
use clang_sys::clang_Cursor_isFunctionInlined;
910
use clang_sys::clang_getCXXAccessSpecifier;
1011
use clang_sys::clang_getCursorKind;
1112
use clang_sys::clang_isCursorDefinition;
@@ -42,6 +43,15 @@ impl Matcher<FunctionNode> for IsFunctionDefination {
4243
}
4344
}
4445

46+
#[derive(Clone)]
47+
pub struct IsInlineFunction;
48+
49+
impl Matcher<FunctionNode> for IsInlineFunction {
50+
fn is_match(&self, function: &FunctionNode) -> bool {
51+
unsafe { clang_Cursor_isFunctionInlined(function.cursor) != 0 }
52+
}
53+
}
54+
4555
#[derive(Clone)]
4656
pub struct IsTemplateFunction;
4757

src/clang_ql/matchers/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ pub use function::IsDeletedMethodMatcher;
1212
pub use function::IsDestructorMatcher;
1313
pub use function::IsFunctionDeclaration;
1414
pub use function::IsFunctionDefination;
15+
pub use function::IsInlineFunction;
1516
pub use function::IsMethodMatcher;
1617
pub use function::IsMoveConstructorMatcher;
1718
pub use function::IsPureVirtualMatcher;

0 commit comments

Comments
 (0)