Skip to content

Commit

Permalink
Improves documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
TobiasWienand committed Sep 2, 2024
1 parent 1a1d3ed commit 1edbfea
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
1 change: 0 additions & 1 deletion Sources/Fuzzilli/Compiler/Compiler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,6 @@ public class JavaScriptCompiler {
case .breakStatement:
// If we're in both .loop and .switch context, then the loop must be the most recent context
// (switch blocks don't propagate an outer .loop context) so we just need to check for .loop here
// TODO remove this comment once the Analyzer bug fixs has been merged. Until then the code in this switch case is buggy.
if contextAnalyzer.context.contains(.loop){
emit(LoopBreak())
} else if contextAnalyzer.context.contains(.switchBlock){
Expand Down
3 changes: 2 additions & 1 deletion Sources/Fuzzilli/FuzzIL/Analyzer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,8 @@ struct ContextAnalyzer: Analyzer {
newContext.formUnion(contextStack.secondToTop)
}

// If we are in a loop, we don't want to propagate the switch context and vice versa.
// If we are in a loop, we don't want to propagate the switch context and vice versa. Otherwise we couldn't determine which break operation to emit.
// TODO Make this generic for similar logic cases as well. E.g. by using a instr.op.contextClosed list.
if (instr.op.contextOpened.contains(.switchBlock) || instr.op.contextOpened.contains(.switchCase)) {
newContext.remove(.loop)
} else if (instr.op.contextOpened.contains(.loop)) {
Expand Down
2 changes: 2 additions & 0 deletions Tests/FuzzilliTests/AnalyzerTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,8 @@ class AnalyzerTests: XCTestCase {
let _ = b.finalize()
}

// Tests if the context is correctly identified in nested loops and switches.
// Needs to work to distinguish when to emit LoopBreak and SwitchBreak.
func testBreakContext() {
let fuzzer = makeMockFuzzer()
let b = fuzzer.makeBuilder()
Expand Down

0 comments on commit 1edbfea

Please sign in to comment.