summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/clang.rs10
-rw-r--r--src/ir/var.rs29
2 files changed, 6 insertions, 33 deletions
diff --git a/src/clang.rs b/src/clang.rs
index 9c09f71c..357a6dd5 100644
--- a/src/clang.rs
+++ b/src/clang.rs
@@ -237,14 +237,8 @@ impl Cursor {
}
/// Is this Cursor pointing to a function-like macro definition?
- /// Returns None if this cannot be determined with the available libclang
- /// (it requires 3.9 or greater).
- pub fn is_macro_function_like(&self) -> Option<bool> {
- if clang_Cursor_isMacroFunctionLike::is_loaded() {
- Some(unsafe { clang_Cursor_isMacroFunctionLike(self.x) != 0 })
- } else {
- None
- }
+ pub fn is_macro_function_like(&self) -> bool {
+ unsafe { clang_Cursor_isMacroFunctionLike(self.x) != 0 }
}
/// Get the kind of referent this cursor is pointing to.
diff --git a/src/ir/var.rs b/src/ir/var.rs
index 67b2e348..ef963503 100644
--- a/src/ir/var.rs
+++ b/src/ir/var.rs
@@ -141,31 +141,10 @@ fn handle_function_macro(
tokens: &[ClangToken],
callbacks: &dyn crate::callbacks::ParseCallbacks,
) -> Result<(), ParseError> {
- fn is_abutting(a: &ClangToken, b: &ClangToken) -> bool {
- unsafe {
- clang_sys::clang_equalLocations(
- clang_sys::clang_getRangeEnd(a.extent),
- clang_sys::clang_getRangeStart(b.extent),
- ) != 0
- }
- }
-
- let is_functional_macro =
- // If we have libclang >= 3.9, we can use `is_macro_function_like()` and
- // avoid checking for abutting tokens ourselves.
- cursor.is_macro_function_like().unwrap_or_else(|| {
- // If we cannot get a definitive answer from clang, we instead check
- // for a parenthesis token immediately adjacent to (that is,
- // abutting) the first token in the macro definition.
- // TODO: Once we don't need the fallback check here, we can hoist
- // the `is_macro_function_like` check into this function's caller,
- // and thus avoid allocating the `tokens` vector for non-functional
- // macros.
- match tokens.get(0..2) {
- Some([a, b]) => is_abutting(&a, &b) && b.spelling() == b"(",
- _ => false,
- }
- });
+ // TODO: Hoist the `is_macro_function_like` check into this function's
+ // caller, and thus avoid allocating the `tokens` vector for non-functional
+ // macros.
+ let is_functional_macro = cursor.is_macro_function_like();
if !is_functional_macro {
return Ok(());