ART: Add -Wunused

Until the global CFLAGS are fixed, add Wunused. Fix declarations
in the optimizing compiler.

Change-Id: Ic4553f08e809dc54f3d82af57ac592622c98e000
diff --git a/build/Android.common_build.mk b/build/Android.common_build.mk
index 3000cdf..36c9342 100644
--- a/build/Android.common_build.mk
+++ b/build/Android.common_build.mk
@@ -191,6 +191,7 @@
   -Wunreachable-code \
   -Wredundant-decls \
   -Wshadow \
+  -Wunused \
   -fvisibility=protected \
   $(art_default_gc_type_cflags)
 
diff --git a/compiler/optimizing/bounds_check_elimination.h b/compiler/optimizing/bounds_check_elimination.h
index 05cb185..9e98ccf 100644
--- a/compiler/optimizing/bounds_check_elimination.h
+++ b/compiler/optimizing/bounds_check_elimination.h
@@ -23,10 +23,13 @@
 
 class BoundsCheckElimination : public HOptimization {
  public:
-  explicit BoundsCheckElimination(HGraph* graph) : HOptimization(graph, true, "BCE") {}
+  explicit BoundsCheckElimination(HGraph* graph)
+      : HOptimization(graph, true, kBoundsCheckEliminiationPassName) {}
 
   void Run() OVERRIDE;
 
+  static constexpr const char* kBoundsCheckEliminiationPassName = "BCE";
+
  private:
   DISALLOW_COPY_AND_ASSIGN(BoundsCheckElimination);
 };
diff --git a/compiler/optimizing/builder.h b/compiler/optimizing/builder.h
index 3e4a616..96196de 100644
--- a/compiler/optimizing/builder.h
+++ b/compiler/optimizing/builder.h
@@ -80,6 +80,8 @@
 
   bool BuildGraph(const DexFile::CodeItem& code);
 
+  static constexpr const char* kBuilderPassName = "builder";
+
  private:
   // Analyzes the dex instruction and adds HInstruction to the graph
   // to execute that instruction. Returns whether the instruction can
diff --git a/compiler/optimizing/graph_visualizer.cc b/compiler/optimizing/graph_visualizer.cc
index c592737..cabfa48 100644
--- a/compiler/optimizing/graph_visualizer.cc
+++ b/compiler/optimizing/graph_visualizer.cc
@@ -17,8 +17,10 @@
 #include "graph_visualizer.h"
 
 #include "code_generator.h"
+#include "licm.h"
 #include "nodes.h"
 #include "optimization.h"
+#include "register_allocator.h"
 #include "ssa_liveness_analysis.h"
 
 namespace art {
@@ -188,6 +190,10 @@
     output_ << " " << phi->GetRegNumber();
   }
 
+  bool IsPass(const char* name) {
+    return strcmp(pass_name_, name) == 0;
+  }
+
   void PrintInstruction(HInstruction* instruction) {
     output_ << instruction->DebugName();
     instruction->Accept(this);
@@ -211,7 +217,7 @@
       }
       output_ << "])";
     }
-    if (pass_name_ == kLivenessPassName
+    if (IsPass(SsaLivenessAnalysis::kLivenessPassName)
         && is_after_pass_
         && instruction->GetLifetimePosition() != kNoLifetime) {
       output_ << " (liveness: " << instruction->GetLifetimePosition();
@@ -221,7 +227,7 @@
         interval.Dump(output_);
       }
       output_ << ")";
-    } else if (pass_name_ == kRegisterAllocatorPassName && is_after_pass_) {
+    } else if (IsPass(RegisterAllocator::kRegisterAllocatorPassName) && is_after_pass_) {
       LocationSummary* locations = instruction->GetLocations();
       if (locations != nullptr) {
         output_ << " ( ";
@@ -236,7 +242,7 @@
         }
       }
       output_ << " (liveness: " << instruction->GetLifetimePosition() << ")";
-    } else if (pass_name_ == kLoopInvariantCodeMotionPassName) {
+    } else if (IsPass(LICM::kLoopInvariantCodeMotionPassName)) {
       output_ << " ( loop_header:";
       HLoopInformation* info = instruction->GetBlock()->GetLoopInformation();
       if (info == nullptr) {
diff --git a/compiler/optimizing/gvn.h b/compiler/optimizing/gvn.h
index 57e0487..e74d969 100644
--- a/compiler/optimizing/gvn.h
+++ b/compiler/optimizing/gvn.h
@@ -27,10 +27,12 @@
 class GVNOptimization : public HOptimization {
  public:
   GVNOptimization(HGraph* graph, const SideEffectsAnalysis& side_effects)
-      : HOptimization(graph, true, "GVN"), side_effects_(side_effects) {}
+      : HOptimization(graph, true, kGlobalValueNumberingPassName), side_effects_(side_effects) {}
 
   void Run() OVERRIDE;
 
+  static constexpr const char* kGlobalValueNumberingPassName = "GVN";
+
  private:
   const SideEffectsAnalysis& side_effects_;
 
diff --git a/compiler/optimizing/inliner.h b/compiler/optimizing/inliner.h
index 8e9cf83..2b08d3d 100644
--- a/compiler/optimizing/inliner.h
+++ b/compiler/optimizing/inliner.h
@@ -35,13 +35,15 @@
            CompilerDriver* compiler_driver,
            OptimizingCompilerStats* stats,
            size_t depth = 0)
-      : HOptimization(outer_graph, true, "inliner", stats),
+      : HOptimization(outer_graph, true, kInlinerPassName, stats),
         outer_compilation_unit_(outer_compilation_unit),
         compiler_driver_(compiler_driver),
         depth_(depth) {}
 
   void Run() OVERRIDE;
 
+  static constexpr const char* kInlinerPassName = "inliner";
+
  private:
   bool TryInline(HInvoke* invoke_instruction, uint32_t method_index, InvokeType invoke_type) const;
 
diff --git a/compiler/optimizing/instruction_simplifier.h b/compiler/optimizing/instruction_simplifier.h
index a7ff755..0244620 100644
--- a/compiler/optimizing/instruction_simplifier.h
+++ b/compiler/optimizing/instruction_simplifier.h
@@ -30,9 +30,11 @@
  public:
   InstructionSimplifier(HGraph* graph,
                         OptimizingCompilerStats* stats = nullptr,
-                        const char* name = "instruction_simplifier")
+                        const char* name = kInstructionSimplifierPassName)
     : HOptimization(graph, true, name, stats) {}
 
+  static constexpr const char* kInstructionSimplifierPassName = "instruction_simplifier";
+
   void Run() OVERRIDE;
 };
 
diff --git a/compiler/optimizing/intrinsics.h b/compiler/optimizing/intrinsics.h
index 29cc8ef..dbb7cba 100644
--- a/compiler/optimizing/intrinsics.h
+++ b/compiler/optimizing/intrinsics.h
@@ -29,11 +29,13 @@
 class IntrinsicsRecognizer : public HOptimization {
  public:
   IntrinsicsRecognizer(HGraph* graph, const DexFile* dex_file, CompilerDriver* driver)
-      : HOptimization(graph, true, "intrinsics_recognition"),
+      : HOptimization(graph, true, kIntrinsicsRecognizerPassName),
         dex_file_(dex_file), driver_(driver) {}
 
   void Run() OVERRIDE;
 
+  static constexpr const char* kIntrinsicsRecognizerPassName = "intrinsics_recognition";
+
  private:
   const DexFile* dex_file_;
   CompilerDriver* driver_;
diff --git a/compiler/optimizing/licm.h b/compiler/optimizing/licm.h
index 4812394..cb6170e 100644
--- a/compiler/optimizing/licm.h
+++ b/compiler/optimizing/licm.h
@@ -31,6 +31,8 @@
 
   void Run() OVERRIDE;
 
+  static constexpr const char* kLoopInvariantCodeMotionPassName = "licm";
+
  private:
   const SideEffectsAnalysis& side_effects_;
 
diff --git a/compiler/optimizing/optimization.h b/compiler/optimizing/optimization.h
index af39e09..8b20281 100644
--- a/compiler/optimizing/optimization.h
+++ b/compiler/optimizing/optimization.h
@@ -22,12 +22,6 @@
 
 namespace art {
 
-static const char* kBuilderPassName = "builder";
-static const char* kSsaBuilderPassName = "ssa_builder";
-static const char* kLivenessPassName = "liveness";
-static const char* kRegisterAllocatorPassName = "register";
-static const char* kLoopInvariantCodeMotionPassName = "licm";
-
 /**
  * Abstraction to implement an optimization pass.
  */
diff --git a/compiler/optimizing/optimizing_compiler.cc b/compiler/optimizing/optimizing_compiler.cc
index 2fef8c7..eb98424 100644
--- a/compiler/optimizing/optimizing_compiler.cc
+++ b/compiler/optimizing/optimizing_compiler.cc
@@ -56,7 +56,7 @@
  */
 class CodeVectorAllocator FINAL : public CodeAllocator {
  public:
-  CodeVectorAllocator() {}
+  CodeVectorAllocator() : size_(0) {}
 
   virtual uint8_t* Allocate(size_t size) {
     size_ = size;
@@ -361,11 +361,11 @@
   PrepareForRegisterAllocation(graph).Run();
   SsaLivenessAnalysis liveness(*graph, codegen);
   {
-    PassInfo pass_info(kLivenessPassName, pass_info_printer);
+    PassInfo pass_info(SsaLivenessAnalysis::kLivenessPassName, pass_info_printer);
     liveness.Analyze();
   }
   {
-    PassInfo pass_info(kRegisterAllocatorPassName, pass_info_printer);
+    PassInfo pass_info(RegisterAllocator::kRegisterAllocatorPassName, pass_info_printer);
     RegisterAllocator(graph->GetArena(), codegen, liveness).AllocateRegisters();
   }
 
@@ -495,7 +495,7 @@
   VLOG(compiler) << "Building " << method_name;
 
   {
-    PassInfo pass_info(kBuilderPassName, &pass_info_printer);
+    PassInfo pass_info(HGraphBuilder::kBuilderPassName, &pass_info_printer);
     if (!builder.BuildGraph(*code_item)) {
       CHECK(!shouldCompile) << "Could not build graph in optimizing compiler";
       return nullptr;
@@ -508,7 +508,7 @@
     VLOG(compiler) << "Optimizing " << method_name;
 
     {
-      PassInfo pass_info(kSsaBuilderPassName, &pass_info_printer);
+      PassInfo pass_info(SsaBuilder::kSsaBuilderPassName, &pass_info_printer);
       if (!graph->TryBuildingSsa()) {
         // We could not transform the graph to SSA, bailout.
         LOG(INFO) << "Skipping compilation of " << method_name << ": it contains a non natural loop";
diff --git a/compiler/optimizing/reference_type_propagation.h b/compiler/optimizing/reference_type_propagation.h
index 815caab..733e18e 100644
--- a/compiler/optimizing/reference_type_propagation.h
+++ b/compiler/optimizing/reference_type_propagation.h
@@ -34,7 +34,7 @@
                            const DexFile& dex_file,
                            const DexCompilationUnit& dex_compilation_unit,
                            StackHandleScopeCollection* handles)
-    : HOptimization(graph, true, "reference_type_propagation"),
+    : HOptimization(graph, true, kReferenceTypePropagationPassName),
       dex_file_(dex_file),
       dex_compilation_unit_(dex_compilation_unit),
       handles_(handles),
@@ -42,6 +42,8 @@
 
   void Run() OVERRIDE;
 
+  static constexpr const char* kReferenceTypePropagationPassName = "reference_type_propagation";
+
  private:
   void VisitNewInstance(HNewInstance* new_instance);
   void VisitLoadClass(HLoadClass* load_class);
diff --git a/compiler/optimizing/register_allocator.h b/compiler/optimizing/register_allocator.h
index ff2f106..579f069 100644
--- a/compiler/optimizing/register_allocator.h
+++ b/compiler/optimizing/register_allocator.h
@@ -81,6 +81,8 @@
         + double_spill_slots_.Size();
   }
 
+  static constexpr const char* kRegisterAllocatorPassName = "register";
+
  private:
   // Main methods of the allocator.
   void LinearScan();
diff --git a/compiler/optimizing/side_effects_analysis.h b/compiler/optimizing/side_effects_analysis.h
index f1c98ac..415d10c 100644
--- a/compiler/optimizing/side_effects_analysis.h
+++ b/compiler/optimizing/side_effects_analysis.h
@@ -25,7 +25,7 @@
 class SideEffectsAnalysis : public HOptimization {
  public:
   explicit SideEffectsAnalysis(HGraph* graph)
-      : HOptimization(graph, true, "SideEffects"),
+      : HOptimization(graph, true, kSideEffectsAnalysisPassName),
         graph_(graph),
         block_effects_(graph->GetArena(), graph->GetBlocks().Size(), SideEffects::None()),
         loop_effects_(graph->GetArena(), graph->GetBlocks().Size(), SideEffects::None()) {}
@@ -38,6 +38,8 @@
 
   bool HasRun() const { return has_run_; }
 
+  static constexpr const char* kSideEffectsAnalysisPassName = "SideEffects";
+
  private:
   void UpdateLoopEffects(HLoopInformation* info, SideEffects effects);
 
diff --git a/compiler/optimizing/ssa_builder.h b/compiler/optimizing/ssa_builder.h
index 148e959..f50da46 100644
--- a/compiler/optimizing/ssa_builder.h
+++ b/compiler/optimizing/ssa_builder.h
@@ -60,6 +60,8 @@
 
   static HInstruction* GetReferenceTypeEquivalent(HInstruction* instruction);
 
+  static constexpr const char* kSsaBuilderPassName = "ssa_builder";
+
  private:
   // Locals for the current block being visited.
   HEnvironment* current_locals_;
diff --git a/compiler/optimizing/ssa_liveness_analysis.h b/compiler/optimizing/ssa_liveness_analysis.h
index 0e68a61..be72629 100644
--- a/compiler/optimizing/ssa_liveness_analysis.h
+++ b/compiler/optimizing/ssa_liveness_analysis.h
@@ -816,6 +816,8 @@
     return number_of_ssa_values_;
   }
 
+  static constexpr const char* kLivenessPassName = "liveness";
+
  private:
   // Linearize the graph so that:
   // (1): a block is always after its dominator,
diff --git a/compiler/optimizing/ssa_phi_elimination.h b/compiler/optimizing/ssa_phi_elimination.h
index 88a5279..c4b63ab 100644
--- a/compiler/optimizing/ssa_phi_elimination.h
+++ b/compiler/optimizing/ssa_phi_elimination.h
@@ -29,7 +29,7 @@
 class SsaDeadPhiElimination : public HOptimization {
  public:
   explicit SsaDeadPhiElimination(HGraph* graph)
-      : HOptimization(graph, true, "dead_phi_elimination"),
+      : HOptimization(graph, true, kSsaDeadPhiEliminationPassName),
         worklist_(graph->GetArena(), kDefaultWorklistSize) {}
 
   void Run() OVERRIDE;
@@ -37,6 +37,8 @@
   void MarkDeadPhis();
   void EliminateDeadPhis();
 
+  static constexpr const char* kSsaDeadPhiEliminationPassName = "dead_phi_elimination";
+
  private:
   GrowableArray<HPhi*> worklist_;
 
@@ -54,11 +56,13 @@
 class SsaRedundantPhiElimination : public HOptimization {
  public:
   explicit SsaRedundantPhiElimination(HGraph* graph)
-      : HOptimization(graph, true, "redundant_phi_elimination"),
+      : HOptimization(graph, true, kSsaRedundantPhiEliminationPassName),
         worklist_(graph->GetArena(), kDefaultWorklistSize) {}
 
   void Run() OVERRIDE;
 
+  static constexpr const char* kSsaRedundantPhiEliminationPassName = "redundant_phi_elimination";
+
  private:
   GrowableArray<HPhi*> worklist_;
 
diff --git a/runtime/arch/stub_test.cc b/runtime/arch/stub_test.cc
index 6acc2a7..0d41a8f 100644
--- a/runtime/arch/stub_test.cc
+++ b/runtime/arch/stub_test.cc
@@ -278,6 +278,7 @@
           "memory");  // clobber all
     // TODO: Should we clobber the other registers?
 #else
+    UNUSED(arg0, arg1, arg2, code, referrer);
     LOG(WARNING) << "Was asked to invoke for an architecture I do not understand.";
     result = 0;
 #endif
@@ -503,6 +504,7 @@
           "memory");  // clobber all
     // TODO: Should we clobber the other registers?
 #else
+    UNUSED(arg0, arg1, arg2, code, referrer, hidden);
     LOG(WARNING) << "Was asked to invoke for an architecture I do not understand.";
     result = 0;
 #endif
@@ -792,6 +794,7 @@
 
   // Test done.
 #else
+  UNUSED(test);
   LOG(INFO) << "Skipping unlock_object as I don't know how to do that on " << kRuntimeISA;
   // Force-print to std::cout so it's also outside the logcat.
   std::cout << "Skipping unlock_object as I don't know how to do that on " << kRuntimeISA << std::endl;
@@ -1326,6 +1329,7 @@
     EXPECT_EQ(values[i], static_cast<uint8_t>(res)) << "Iteration " << i;
   }
 #else
+  UNUSED(f, self, referrer, test);
   LOG(INFO) << "Skipping set_boolean_static as I don't know how to do that on " << kRuntimeISA;
   // Force-print to std::cout so it's also outside the logcat.
   std::cout << "Skipping set_boolean_static as I don't know how to do that on " << kRuntimeISA << std::endl;
@@ -1353,6 +1357,7 @@
     EXPECT_EQ(values[i], static_cast<int8_t>(res)) << "Iteration " << i;
   }
 #else
+  UNUSED(f, self, referrer, test);
   LOG(INFO) << "Skipping set_byte_static as I don't know how to do that on " << kRuntimeISA;
   // Force-print to std::cout so it's also outside the logcat.
   std::cout << "Skipping set_byte_static as I don't know how to do that on " << kRuntimeISA << std::endl;
@@ -1388,6 +1393,7 @@
     EXPECT_EQ(res, static_cast<uint8_t>(res2));
   }
 #else
+  UNUSED(obj, f, self, referrer, test);
   LOG(INFO) << "Skipping set_boolean_instance as I don't know how to do that on " << kRuntimeISA;
   // Force-print to std::cout so it's also outside the logcat.
   std::cout << "Skipping set_boolean_instance as I don't know how to do that on " << kRuntimeISA << std::endl;
@@ -1420,6 +1426,7 @@
     EXPECT_EQ(res, static_cast<int8_t>(res2));
   }
 #else
+  UNUSED(obj, f, self, referrer, test);
   LOG(INFO) << "Skipping set_byte_instance as I don't know how to do that on " << kRuntimeISA;
   // Force-print to std::cout so it's also outside the logcat.
   std::cout << "Skipping set_byte_instance as I don't know how to do that on " << kRuntimeISA << std::endl;
@@ -1449,6 +1456,7 @@
     EXPECT_EQ(values[i], static_cast<uint16_t>(res)) << "Iteration " << i;
   }
 #else
+  UNUSED(f, self, referrer, test);
   LOG(INFO) << "Skipping set_char_static as I don't know how to do that on " << kRuntimeISA;
   // Force-print to std::cout so it's also outside the logcat.
   std::cout << "Skipping set_char_static as I don't know how to do that on " << kRuntimeISA << std::endl;
@@ -1477,6 +1485,7 @@
     EXPECT_EQ(static_cast<int16_t>(res), values[i]) << "Iteration " << i;
   }
 #else
+  UNUSED(f, self, referrer, test);
   LOG(INFO) << "Skipping set_short_static as I don't know how to do that on " << kRuntimeISA;
   // Force-print to std::cout so it's also outside the logcat.
   std::cout << "Skipping set_short_static as I don't know how to do that on " << kRuntimeISA << std::endl;
@@ -1510,6 +1519,7 @@
     EXPECT_EQ(res, static_cast<uint16_t>(res2));
   }
 #else
+  UNUSED(obj, f, self, referrer, test);
   LOG(INFO) << "Skipping set_char_instance as I don't know how to do that on " << kRuntimeISA;
   // Force-print to std::cout so it's also outside the logcat.
   std::cout << "Skipping set_char_instance as I don't know how to do that on " << kRuntimeISA << std::endl;
@@ -1542,6 +1552,7 @@
     EXPECT_EQ(res, static_cast<int16_t>(res2));
   }
 #else
+  UNUSED(obj, f, self, referrer, test);
   LOG(INFO) << "Skipping set_short_instance as I don't know how to do that on " << kRuntimeISA;
   // Force-print to std::cout so it's also outside the logcat.
   std::cout << "Skipping set_short_instance as I don't know how to do that on " << kRuntimeISA << std::endl;
@@ -1571,6 +1582,7 @@
     EXPECT_EQ(res, values[i]) << "Iteration " << i;
   }
 #else
+  UNUSED(f, self, referrer, test);
   LOG(INFO) << "Skipping set32static as I don't know how to do that on " << kRuntimeISA;
   // Force-print to std::cout so it's also outside the logcat.
   std::cout << "Skipping set32static as I don't know how to do that on " << kRuntimeISA << std::endl;
@@ -1607,6 +1619,7 @@
     EXPECT_EQ(res, static_cast<int32_t>(res2));
   }
 #else
+  UNUSED(obj, f, self, referrer, test);
   LOG(INFO) << "Skipping set32instance as I don't know how to do that on " << kRuntimeISA;
   // Force-print to std::cout so it's also outside the logcat.
   std::cout << "Skipping set32instance as I don't know how to do that on " << kRuntimeISA << std::endl;
@@ -1648,6 +1661,7 @@
 
   set_and_check_static((*f)->GetDexFieldIndex(), nullptr, self, referrer, test);
 #else
+  UNUSED(f, self, referrer, test);
   LOG(INFO) << "Skipping setObjstatic as I don't know how to do that on " << kRuntimeISA;
   // Force-print to std::cout so it's also outside the logcat.
   std::cout << "Skipping setObjstatic as I don't know how to do that on " << kRuntimeISA << std::endl;
@@ -1692,6 +1706,7 @@
 
   set_and_check_instance(f, obj->Get(), nullptr, self, referrer, test);
 #else
+  UNUSED(obj, f, self, referrer, test);
   LOG(INFO) << "Skipping setObjinstance as I don't know how to do that on " << kRuntimeISA;
   // Force-print to std::cout so it's also outside the logcat.
   std::cout << "Skipping setObjinstance as I don't know how to do that on " << kRuntimeISA << std::endl;
diff --git a/test/004-SignalTest/signaltest.cc b/test/004-SignalTest/signaltest.cc
index 31371f6..876d27e 100644
--- a/test/004-SignalTest/signaltest.cc
+++ b/test/004-SignalTest/signaltest.cc
@@ -65,6 +65,8 @@
 #elif defined(__i386__) || defined(__x86_64__)
   struct ucontext *uc = reinterpret_cast<struct ucontext*>(context);
   uc->CTX_EIP += 3;
+#else
+  UNUSED(context);
 #endif
 }