Skip to content

Commit

Permalink
Add an option switch off dead code analysis
Browse files Browse the repository at this point in the history
  • Loading branch information
daniellansun committed Jan 4, 2024
1 parent 103cfa0 commit b6870c6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -759,8 +759,10 @@ public void call(final SourceUnit source, final GeneratorContext context, final
getErrorCollector().addError(new SyntaxException(rpe.getMessage(), rpe.getNode()), source);
}

visitor = new DeadCodeAnalyzer(source);
visitor.visitClass(classNode);
if (Boolean.TRUE.equals(configuration.getOptimizationOptions().get(CompilerConfiguration.ANALYZE_DEAD_CODE))) {
visitor = new DeadCodeAnalyzer(source);
visitor.visitClass(classNode);
}

visitor = new LabelVerifier(source);
visitor.visitClass(classNode);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ public class CompilerConfiguration {
/** Joint Compilation Option for enabling generating stubs in memory. */
public static final String MEM_STUB = "memStub";

/** Optimization Option for enabling dead code analysis */
public static final String ANALYZE_DEAD_CODE = "analyzeDeadCode";

/** This (<code>"1.4"</code>) is the value for targetBytecode to compile for a JDK 1.4. */
@Deprecated public static final String JDK4 = "1.4";
/** This (<code>"1.5"</code>) is the value for targetBytecode to compile for a JDK 1.5. */
Expand Down Expand Up @@ -469,6 +472,8 @@ public CompilerConfiguration() {
handleOptimizationOption(GROOVYDOC, getSystemPropertySafe("groovy.attach.groovydoc"));
handleOptimizationOption(RUNTIME_GROOVYDOC, getSystemPropertySafe("groovy.attach.runtime.groovydoc"));
handleOptimizationOption(PARALLEL_PARSE, getSystemPropertySafe("groovy.parallel.parse", "true"));
handleOptimizationOption(ANALYZE_DEAD_CODE, getSystemPropertySafe("groovy.analyze.deadcode", "true"));


if (getBooleanSafe("groovy.mem.stub")) {
jointCompilationOptions = new HashMap<>(2);
Expand Down

0 comments on commit b6870c6

Please sign in to comment.