Skip to content

Commit 7863893

Browse files
committed
Drop last token under LLVM < 4.0
1 parent c360261 commit 7863893

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/ir/var.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,15 @@ fn handle_function_macro(
162162
let left = String::from_utf8(left.concat())
163163
.map_err(|_| ParseError::Continue)?;
164164
let right: Vec<_> = right.iter().map(Vec::as_slice).collect();
165-
func_macro(&left, &right);
165+
// Drop last token with LLVM < 4.0, due to an LLVM bug.
166+
//
167+
// See:
168+
// https://bugs.llvm.org//show_bug.cgi?id=9069
169+
let right = match (right.len(), crate::clang_version().parsed) {
170+
(len, Some((v, _))) if len > 0 && v < 4 => &right[..len - 1],
171+
_ => &right[..],
172+
};
173+
func_macro(&left, right);
166174

167175
// We handled the macro, skip future macro processing.
168176
Err(ParseError::Continue)

0 commit comments

Comments
 (0)