Merge "Improve performance of canonicalizing locals information."
diff --git a/src/main/java/com/android/tools/r8/R8Command.java b/src/main/java/com/android/tools/r8/R8Command.java
index 9a11817..564aa9c 100644
--- a/src/main/java/com/android/tools/r8/R8Command.java
+++ b/src/main/java/com/android/tools/r8/R8Command.java
@@ -43,8 +43,8 @@
       super(CompilationMode.RELEASE);
     }
 
-    protected Builder(boolean forceProguardCompatibility) {
-      super(CompilationMode.RELEASE);
+    protected Builder(boolean ignoreDexInArchive, boolean forceProguardCompatibility) {
+      super(CompilationMode.RELEASE, ignoreDexInArchive);
       this.forceProguardCompatibility = forceProguardCompatibility;
     }
 
diff --git a/src/main/java/com/android/tools/r8/compatproguard/CompatProguardCommandBuilder.java b/src/main/java/com/android/tools/r8/compatproguard/CompatProguardCommandBuilder.java
index df2298c..145d0e6 100644
--- a/src/main/java/com/android/tools/r8/compatproguard/CompatProguardCommandBuilder.java
+++ b/src/main/java/com/android/tools/r8/compatproguard/CompatProguardCommandBuilder.java
@@ -8,6 +8,6 @@
 
 public class CompatProguardCommandBuilder extends R8Command.Builder {
   CompatProguardCommandBuilder(boolean forceProguardCompatibility) {
-    super(forceProguardCompatibility);
+    super(true, forceProguardCompatibility);
   }
 }
diff --git a/src/main/java/com/android/tools/r8/shaking/ProguardConfiguration.java b/src/main/java/com/android/tools/r8/shaking/ProguardConfiguration.java
index d23822f..9ad96e2 100644
--- a/src/main/java/com/android/tools/r8/shaking/ProguardConfiguration.java
+++ b/src/main/java/com/android/tools/r8/shaking/ProguardConfiguration.java
@@ -19,22 +19,22 @@
 
     private final List<FilteredClassPath> injars = new ArrayList<>();
     private final List<FilteredClassPath> libraryjars = new ArrayList<>();
-    private PackageObfuscationMode packageObfuscationMode = PackageObfuscationMode.NONE;
-    private String packagePrefix = "";
-    private boolean allowAccessModification = false;
-    private boolean ignoreWarnings = false;
-    private boolean optimizing = true;
-    private boolean obfuscating = true;
-    private boolean shrinking = true;
-    private boolean printUsage = false;
+    private PackageObfuscationMode packageObfuscationMode;
+    private String packagePrefix;
+    private boolean allowAccessModification;
+    private boolean ignoreWarnings;
+    private boolean optimizing;
+    private boolean obfuscating;
+    private boolean shrinking;
+    private boolean printUsage;
     private Path printUsageFile;
     private boolean printMapping;
     private Path printMappingFile;
-    private Path applyMappingFile = null;
-    private boolean verbose = false;
-    private String renameSourceFileAttribute = null;
+    private Path applyMappingFile;
+    private boolean verbose;
+    private String renameSourceFileAttribute;
     private final List<String> keepAttributePatterns = new ArrayList<>();
-    private ProguardClassNameList dontWarnPatterns = ProguardClassNameList.emptyList();
+    private ProguardClassNameList dontWarnPatterns;
     protected final List<ProguardConfigurationRule> rules = new ArrayList<>();
     private final DexItemFactory dexItemFactory;
     private boolean printSeeds;
@@ -47,6 +47,36 @@
 
     private Builder(DexItemFactory dexItemFactory) {
       this.dexItemFactory = dexItemFactory;
+      resetProguardDefaults();
+    }
+
+    public void resetProguardDefaults() {
+      injars.clear();
+      libraryjars.clear();
+      packageObfuscationMode = PackageObfuscationMode.NONE;
+      packagePrefix = "";
+      allowAccessModification = false;
+      ignoreWarnings = false;
+      optimizing = true;
+      obfuscating = true;
+      shrinking = true;
+      printUsage = false;
+      printUsageFile = null;
+      printMapping = false;
+      printMappingFile = null;
+      applyMappingFile = null;
+      verbose = false;
+      renameSourceFileAttribute = null;
+      keepAttributePatterns.clear();
+      dontWarnPatterns = ProguardClassNameList.emptyList();
+      rules.clear();
+      printSeeds = false;
+      seedFile = null;
+      obfuscationDictionary = null;
+      classObfuscationDictionary = null;
+      packageObfuscationDictionary = null;
+      useUniqueClassMemberNames = false;
+      keepParameterNames = false;
     }
 
     public void addInjars(List<FilteredClassPath> injars) {
diff --git a/src/test/java/com/android/tools/r8/debug/DebugTestBase.java b/src/test/java/com/android/tools/r8/debug/DebugTestBase.java
index 6686635..3b12b43 100644
--- a/src/test/java/com/android/tools/r8/debug/DebugTestBase.java
+++ b/src/test/java/com/android/tools/r8/debug/DebugTestBase.java
@@ -19,7 +19,6 @@
 import com.android.tools.r8.utils.DescriptorUtils;
 import com.android.tools.r8.utils.InternalOptions;
 import com.android.tools.r8.utils.OffOrAuto;
-import com.google.common.collect.ImmutableList;
 import it.unimi.dsi.fastutil.longs.LongArrayList;
 import it.unimi.dsi.fastutil.longs.LongList;
 import java.io.File;
@@ -208,10 +207,7 @@
             .setMode(CompilationMode.DEBUG)
             .addLibraryFiles(Paths.get(ToolHelper.getAndroidJar(minSdk)));
     if (pgConsumer != null) {
-      builder
-          .addProguardConfiguration(
-              ImmutableList.of("-keepattributes SourceFile,LineNumberTable"))
-          .addProguardConfigurationConsumer(pgConsumer);
+      builder.addProguardConfigurationConsumer(pgConsumer);
     }
     ToolHelper.runR8(builder.build(), optionsConsumer);
     return dexOutputDir.resolve("classes.dex");
diff --git a/src/test/java/com/android/tools/r8/naming/RenameSourceFileDebugTest.java b/src/test/java/com/android/tools/r8/naming/RenameSourceFileDebugTest.java
index 2547d7f..427c253 100644
--- a/src/test/java/com/android/tools/r8/naming/RenameSourceFileDebugTest.java
+++ b/src/test/java/com/android/tools/r8/naming/RenameSourceFileDebugTest.java
@@ -5,6 +5,7 @@
 
 import com.android.tools.r8.debug.DebugTestBase;
 import com.android.tools.r8.shaking.ProguardKeepRule;
+import com.google.common.collect.ImmutableList;
 import org.junit.BeforeClass;
 import org.junit.Test;
 
@@ -17,10 +18,14 @@
 
   @BeforeClass
   public static void setUp() throws Exception {
-    setUp(null, pg -> {
-      pg.addRule(ProguardKeepRule.defaultKeepAllRule());
-      pg.setRenameSourceFileAttribute(TEST_FILE);
-    });
+    setUp(
+        null,
+        pg -> {
+          pg.resetProguardDefaults();
+          pg.addRule(ProguardKeepRule.defaultKeepAllRule());
+          pg.setRenameSourceFileAttribute(TEST_FILE);
+          pg.addKeepAttributePatterns(ImmutableList.of("SourceFile", "LineNumberTable"));
+        });
   }
 
   /**