Skip to content

Commit aad9410

Browse files
romtsnclaude
andauthored
feat(r8-tests): Add R8 line number tests (#75)
Part of #40 ## R8 Retrace Test Coverage - [x] Inlining (13 tests) - inline frames, line numbers, source files, rewriteFrame rules - [x] Ambiguous Methods (21 tests) - multiple methods → same obfuscated name, <OR> alternatives - [x] Outlines (4 tests) - outline callsites, nested outlines, inline-in-outline - [x] Synthetic/Lambda (3 tests) - lambda methods, synthetic bridges - [x] Source File Edge Cases (7 tests) - colons, unicode, multiple dots, synthesized names - [x] Line Number Handling (10 tests) - spans, preambles, invalid ranges, missing lines - [ ] Exception Handling (6 tests) - obfuscated exceptions, suppressed, circular refs - [ ] Method Overloading (4 tests) - overloads with/without ranges - [ ] Special Formats (4 tests) - Java 9+ modules, logcat format, auto-detect --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent fb53ccf commit aad9410

File tree

10 files changed

+981
-374
lines changed

10 files changed

+981
-374
lines changed

src/builder.rs

Lines changed: 31 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -149,12 +149,12 @@ pub(crate) struct RewriteRule<'s> {
149149
pub(crate) struct Member<'s> {
150150
/// The method the member refers to.
151151
pub(crate) method: MethodKey<'s>,
152-
/// The obfuscated/minified start line.
153-
pub(crate) startline: usize,
154-
/// The obfuscated/minified end line.
155-
pub(crate) endline: usize,
156-
/// The original start line.
157-
pub(crate) original_startline: usize,
152+
/// The obfuscated/minified start line, `None` when no minified range prefix was present.
153+
pub(crate) startline: Option<usize>,
154+
/// The obfuscated/minified end line, `None` when no minified range prefix was present.
155+
pub(crate) endline: Option<usize>,
156+
/// The original start line, `None` when no line mapping was present.
157+
pub(crate) original_startline: Option<usize>,
158158
/// The original end line.
159159
pub(crate) original_endline: Option<usize>,
160160
/// Optional outline callsite positions map attached to this member.
@@ -291,20 +291,31 @@ impl<'s> ParsedProguardMapping<'s> {
291291
} else {
292292
None
293293
};
294-
// in case the mapping has no line records, we use `0` here.
295-
let (startline, endline) =
296-
line_mapping.as_ref().map_or((0, 0), |line_mapping| {
297-
(line_mapping.startline, line_mapping.endline)
298-
});
299-
let (original_startline, original_endline) =
300-
line_mapping.map_or((0, None), |line_mapping| {
301-
match line_mapping.original_startline {
302-
Some(original_startline) => {
303-
(original_startline, line_mapping.original_endline)
304-
}
305-
None => (line_mapping.startline, Some(line_mapping.endline)),
306-
}
307-
});
294+
let (mut startline, mut endline) = match line_mapping.as_ref() {
295+
Some(lm) => (lm.startline, lm.endline),
296+
None => (None, None),
297+
};
298+
let (mut original_startline, mut original_endline) = match line_mapping {
299+
None => (None, None),
300+
Some(lm) => match lm.original_startline {
301+
Some(os) => (Some(os), lm.original_endline),
302+
None => (startline, endline),
303+
},
304+
};
305+
306+
// Normalize inverted ranges independently.
307+
if let (Some(s), Some(e)) = (startline, endline) {
308+
if s > e {
309+
startline = Some(e);
310+
endline = Some(s);
311+
}
312+
}
313+
if let (Some(os), Some(oe)) = (original_startline, original_endline) {
314+
if os > oe {
315+
original_startline = Some(oe);
316+
original_endline = Some(os);
317+
}
318+
}
308319

309320
let Some((current_class_obfuscated, current_class_original)) =
310321
current_class_name

0 commit comments

Comments
 (0)