Use Google3 style guide with .clang-format

Test: style change only, builds ok
Change-Id: I885180e24cb2e7b58cfb4967c3bcb40058ce4078
diff --git a/tools/aapt2/Debug.cpp b/tools/aapt2/Debug.cpp
index 304e571..965db9e 100644
--- a/tools/aapt2/Debug.cpp
+++ b/tools/aapt2/Debug.cpp
@@ -17,8 +17,8 @@
 #include "Debug.h"
 #include "ResourceTable.h"
 #include "ResourceValues.h"
-#include "util/Util.h"
 #include "ValueVisitor.h"
+#include "util/Util.h"
 
 #include <algorithm>
 #include <iostream>
@@ -31,275 +31,279 @@
 namespace aapt {
 
 class PrintVisitor : public ValueVisitor {
-public:
-    using ValueVisitor::visit;
+ public:
+  using ValueVisitor::visit;
 
-    void visit(Attribute* attr) override {
-        std::cout << "(attr) type=";
-        attr->printMask(&std::cout);
-        static constexpr uint32_t kMask = android::ResTable_map::TYPE_ENUM |
-            android::ResTable_map::TYPE_FLAGS;
-        if (attr->typeMask & kMask) {
-            for (const auto& symbol : attr->symbols) {
-                std::cout << "\n        " << symbol.symbol.name.value().entry;
-                if (symbol.symbol.id) {
-                    std::cout << " (" << symbol.symbol.id.value() << ")";
-                }
-                std::cout << " = " << symbol.value;
-            }
+  void visit(Attribute* attr) override {
+    std::cout << "(attr) type=";
+    attr->printMask(&std::cout);
+    static constexpr uint32_t kMask =
+        android::ResTable_map::TYPE_ENUM | android::ResTable_map::TYPE_FLAGS;
+    if (attr->typeMask & kMask) {
+      for (const auto& symbol : attr->symbols) {
+        std::cout << "\n        " << symbol.symbol.name.value().entry;
+        if (symbol.symbol.id) {
+          std::cout << " (" << symbol.symbol.id.value() << ")";
         }
+        std::cout << " = " << symbol.value;
+      }
     }
+  }
 
-    void visit(Style* style) override {
-        std::cout << "(style)";
-        if (style->parent) {
-            const Reference& parentRef = style->parent.value();
-            std::cout << " parent=";
-            if (parentRef.name) {
-                if (parentRef.privateReference) {
-                    std::cout << "*";
-                }
-                std::cout << parentRef.name.value() << " ";
-            }
-
-            if (parentRef.id) {
-                std::cout << parentRef.id.value();
-            }
+  void visit(Style* style) override {
+    std::cout << "(style)";
+    if (style->parent) {
+      const Reference& parentRef = style->parent.value();
+      std::cout << " parent=";
+      if (parentRef.name) {
+        if (parentRef.privateReference) {
+          std::cout << "*";
         }
+        std::cout << parentRef.name.value() << " ";
+      }
 
-        for (const auto& entry : style->entries) {
-            std::cout << "\n        ";
-            if (entry.key.name) {
-                const ResourceName& name = entry.key.name.value();
-                if (!name.package.empty()) {
-                    std::cout << name.package << ":";
-                }
-                std::cout << name.entry;
-            }
+      if (parentRef.id) {
+        std::cout << parentRef.id.value();
+      }
+    }
 
-            if (entry.key.id) {
-                std::cout << "(" << entry.key.id.value() << ")";
-            }
-
-            std::cout << "=" << *entry.value;
+    for (const auto& entry : style->entries) {
+      std::cout << "\n        ";
+      if (entry.key.name) {
+        const ResourceName& name = entry.key.name.value();
+        if (!name.package.empty()) {
+          std::cout << name.package << ":";
         }
+        std::cout << name.entry;
+      }
+
+      if (entry.key.id) {
+        std::cout << "(" << entry.key.id.value() << ")";
+      }
+
+      std::cout << "=" << *entry.value;
     }
+  }
 
-    void visit(Array* array) override {
-        array->print(&std::cout);
-    }
+  void visit(Array* array) override { array->print(&std::cout); }
 
-    void visit(Plural* plural) override {
-        plural->print(&std::cout);
-    }
+  void visit(Plural* plural) override { plural->print(&std::cout); }
 
-    void visit(Styleable* styleable) override {
-        std::cout << "(styleable)";
-        for (const auto& attr : styleable->entries) {
-            std::cout << "\n        ";
-            if (attr.name) {
-                const ResourceName& name = attr.name.value();
-                if (!name.package.empty()) {
-                    std::cout << name.package << ":";
-                }
-                std::cout << name.entry;
-            }
-
-            if (attr.id) {
-                std::cout << "(" << attr.id.value() << ")";
-            }
+  void visit(Styleable* styleable) override {
+    std::cout << "(styleable)";
+    for (const auto& attr : styleable->entries) {
+      std::cout << "\n        ";
+      if (attr.name) {
+        const ResourceName& name = attr.name.value();
+        if (!name.package.empty()) {
+          std::cout << name.package << ":";
         }
-    }
+        std::cout << name.entry;
+      }
 
-    void visitItem(Item* item) override {
-        item->print(&std::cout);
+      if (attr.id) {
+        std::cout << "(" << attr.id.value() << ")";
+      }
     }
+  }
+
+  void visitItem(Item* item) override { item->print(&std::cout); }
 };
 
-void Debug::printTable(ResourceTable* table, const DebugPrintTableOptions& options) {
-    PrintVisitor visitor;
+void Debug::printTable(ResourceTable* table,
+                       const DebugPrintTableOptions& options) {
+  PrintVisitor visitor;
 
-    for (auto& package : table->packages) {
-        std::cout << "Package name=" << package->name;
-        if (package->id) {
-            std::cout << " id=" << std::hex << (int) package->id.value() << std::dec;
+  for (auto& package : table->packages) {
+    std::cout << "Package name=" << package->name;
+    if (package->id) {
+      std::cout << " id=" << std::hex << (int)package->id.value() << std::dec;
+    }
+    std::cout << std::endl;
+
+    for (const auto& type : package->types) {
+      std::cout << "\n  type " << type->type;
+      if (type->id) {
+        std::cout << " id=" << std::hex << (int)type->id.value() << std::dec;
+      }
+      std::cout << " entryCount=" << type->entries.size() << std::endl;
+
+      std::vector<const ResourceEntry*> sortedEntries;
+      for (const auto& entry : type->entries) {
+        auto iter = std::lower_bound(
+            sortedEntries.begin(), sortedEntries.end(), entry.get(),
+            [](const ResourceEntry* a, const ResourceEntry* b) -> bool {
+              if (a->id && b->id) {
+                return a->id.value() < b->id.value();
+              } else if (a->id) {
+                return true;
+              } else {
+                return false;
+              }
+            });
+        sortedEntries.insert(iter, entry.get());
+      }
+
+      for (const ResourceEntry* entry : sortedEntries) {
+        ResourceId id(package->id ? package->id.value() : uint8_t(0),
+                      type->id ? type->id.value() : uint8_t(0),
+                      entry->id ? entry->id.value() : uint16_t(0));
+        ResourceName name(package->name, type->type, entry->name);
+
+        std::cout << "    spec resource " << id << " " << name;
+        switch (entry->symbolStatus.state) {
+          case SymbolState::kPublic:
+            std::cout << " PUBLIC";
+            break;
+          case SymbolState::kPrivate:
+            std::cout << " _PRIVATE_";
+            break;
+          default:
+            break;
         }
+
         std::cout << std::endl;
 
-        for (const auto& type : package->types) {
-            std::cout << "\n  type " << type->type;
-            if (type->id) {
-                std::cout << " id=" << std::hex << (int) type->id.value() << std::dec;
-            }
-            std::cout << " entryCount=" << type->entries.size() << std::endl;
-
-            std::vector<const ResourceEntry*> sortedEntries;
-            for (const auto& entry : type->entries) {
-                auto iter = std::lower_bound(sortedEntries.begin(), sortedEntries.end(), entry.get(),
-                        [](const ResourceEntry* a, const ResourceEntry* b) -> bool {
-                            if (a->id && b->id) {
-                                return a->id.value() < b->id.value();
-                            } else if (a->id) {
-                                return true;
-                            } else {
-                                return false;
-                            }
-                        });
-                sortedEntries.insert(iter, entry.get());
-            }
-
-            for (const ResourceEntry* entry : sortedEntries) {
-                ResourceId id(package->id ? package->id.value() : uint8_t(0),
-                              type->id ? type->id.value() : uint8_t(0),
-                              entry->id ? entry->id.value() : uint16_t(0));
-                ResourceName name(package->name, type->type, entry->name);
-
-                std::cout << "    spec resource " << id << " " << name;
-                switch (entry->symbolStatus.state) {
-                case SymbolState::kPublic: std::cout << " PUBLIC"; break;
-                case SymbolState::kPrivate: std::cout << " _PRIVATE_"; break;
-                default: break;
-                }
-
-                std::cout << std::endl;
-
-                for (const auto& value : entry->values) {
-                    std::cout << "      (" << value->config << ") ";
-                    value->value->accept(&visitor);
-                    if (options.showSources && !value->value->getSource().path.empty()) {
-                        std::cout << " src=" << value->value->getSource();
-                    }
-                    std::cout << std::endl;
-                }
-            }
+        for (const auto& value : entry->values) {
+          std::cout << "      (" << value->config << ") ";
+          value->value->accept(&visitor);
+          if (options.showSources && !value->value->getSource().path.empty()) {
+            std::cout << " src=" << value->value->getSource();
+          }
+          std::cout << std::endl;
         }
+      }
     }
+  }
 }
 
-static size_t getNodeIndex(const std::vector<ResourceName>& names, const ResourceName& name) {
-    auto iter = std::lower_bound(names.begin(), names.end(), name);
-    assert(iter != names.end() && *iter == name);
-    return std::distance(names.begin(), iter);
+static size_t getNodeIndex(const std::vector<ResourceName>& names,
+                           const ResourceName& name) {
+  auto iter = std::lower_bound(names.begin(), names.end(), name);
+  assert(iter != names.end() && *iter == name);
+  return std::distance(names.begin(), iter);
 }
 
-void Debug::printStyleGraph(ResourceTable* table, const ResourceName& targetStyle) {
-    std::map<ResourceName, std::set<ResourceName>> graph;
+void Debug::printStyleGraph(ResourceTable* table,
+                            const ResourceName& targetStyle) {
+  std::map<ResourceName, std::set<ResourceName>> graph;
 
-    std::queue<ResourceName> stylesToVisit;
-    stylesToVisit.push(targetStyle);
-    for (; !stylesToVisit.empty(); stylesToVisit.pop()) {
-        const ResourceName& styleName = stylesToVisit.front();
-        std::set<ResourceName>& parents = graph[styleName];
-        if (!parents.empty()) {
-            // We've already visited this style.
-            continue;
+  std::queue<ResourceName> stylesToVisit;
+  stylesToVisit.push(targetStyle);
+  for (; !stylesToVisit.empty(); stylesToVisit.pop()) {
+    const ResourceName& styleName = stylesToVisit.front();
+    std::set<ResourceName>& parents = graph[styleName];
+    if (!parents.empty()) {
+      // We've already visited this style.
+      continue;
+    }
+
+    Maybe<ResourceTable::SearchResult> result = table->findResource(styleName);
+    if (result) {
+      ResourceEntry* entry = result.value().entry;
+      for (const auto& value : entry->values) {
+        if (Style* style = valueCast<Style>(value->value.get())) {
+          if (style->parent && style->parent.value().name) {
+            parents.insert(style->parent.value().name.value());
+            stylesToVisit.push(style->parent.value().name.value());
+          }
         }
-
-        Maybe<ResourceTable::SearchResult> result = table->findResource(styleName);
-        if (result) {
-            ResourceEntry* entry = result.value().entry;
-            for (const auto& value : entry->values) {
-                if (Style* style = valueCast<Style>(value->value.get())) {
-                    if (style->parent && style->parent.value().name) {
-                        parents.insert(style->parent.value().name.value());
-                        stylesToVisit.push(style->parent.value().name.value());
-                    }
-                }
-            }
-        }
+      }
     }
+  }
 
-    std::vector<ResourceName> names;
-    for (const auto& entry : graph) {
-        names.push_back(entry.first);
+  std::vector<ResourceName> names;
+  for (const auto& entry : graph) {
+    names.push_back(entry.first);
+  }
+
+  std::cout << "digraph styles {\n";
+  for (const auto& name : names) {
+    std::cout << "  node_" << getNodeIndex(names, name) << " [label=\"" << name
+              << "\"];\n";
+  }
+
+  for (const auto& entry : graph) {
+    const ResourceName& styleName = entry.first;
+    size_t styleNodeIndex = getNodeIndex(names, styleName);
+
+    for (const auto& parentName : entry.second) {
+      std::cout << "  node_" << styleNodeIndex << " -> "
+                << "node_" << getNodeIndex(names, parentName) << ";\n";
     }
+  }
 
-    std::cout << "digraph styles {\n";
-    for (const auto& name : names) {
-        std::cout << "  node_" << getNodeIndex(names, name)
-                  << " [label=\"" << name << "\"];\n";
-    }
-
-    for (const auto& entry : graph) {
-        const ResourceName& styleName = entry.first;
-        size_t styleNodeIndex = getNodeIndex(names, styleName);
-
-        for (const auto& parentName : entry.second) {
-            std::cout << "  node_" << styleNodeIndex << " -> "
-                      << "node_" << getNodeIndex(names, parentName) << ";\n";
-        }
-    }
-
-    std::cout << "}" << std::endl;
+  std::cout << "}" << std::endl;
 }
 
 void Debug::dumpHex(const void* data, size_t len) {
-    const uint8_t* d = (const uint8_t*) data;
-    for (size_t i = 0; i < len; i++) {
-        std::cerr << std::hex << std::setfill('0') << std::setw(2) << (uint32_t) d[i] << " ";
-        if (i % 8 == 7) {
-            std::cerr << "\n";
-        }
+  const uint8_t* d = (const uint8_t*)data;
+  for (size_t i = 0; i < len; i++) {
+    std::cerr << std::hex << std::setfill('0') << std::setw(2) << (uint32_t)d[i]
+              << " ";
+    if (i % 8 == 7) {
+      std::cerr << "\n";
     }
+  }
 
-    if (len - 1 % 8 != 7) {
-        std::cerr << std::endl;
-    }
+  if (len - 1 % 8 != 7) {
+    std::cerr << std::endl;
+  }
 }
 
 namespace {
 
 class XmlPrinter : public xml::Visitor {
-public:
-    using xml::Visitor::visit;
+ public:
+  using xml::Visitor::visit;
 
-    void visit(xml::Element* el) override {
-        std::cerr << mPrefix;
-        std::cerr << "E: ";
-        if (!el->namespaceUri.empty()) {
-            std::cerr << el->namespaceUri << ":";
-        }
-        std::cerr << el->name << " (line=" << el->lineNumber << ")\n";
+  void visit(xml::Element* el) override {
+    std::cerr << mPrefix;
+    std::cerr << "E: ";
+    if (!el->namespaceUri.empty()) {
+      std::cerr << el->namespaceUri << ":";
+    }
+    std::cerr << el->name << " (line=" << el->lineNumber << ")\n";
 
-        for (const xml::Attribute& attr : el->attributes) {
-            std::cerr << mPrefix << "  A: ";
-            if (!attr.namespaceUri.empty()) {
-                std::cerr << attr.namespaceUri << ":";
-            }
-            std::cerr << attr.name << "=" << attr.value << "\n";
-        }
-
-        const size_t previousSize = mPrefix.size();
-        mPrefix += "  ";
-        xml::Visitor::visit(el);
-        mPrefix.resize(previousSize);
+    for (const xml::Attribute& attr : el->attributes) {
+      std::cerr << mPrefix << "  A: ";
+      if (!attr.namespaceUri.empty()) {
+        std::cerr << attr.namespaceUri << ":";
+      }
+      std::cerr << attr.name << "=" << attr.value << "\n";
     }
 
-    void visit(xml::Namespace* ns) override {
-        std::cerr << mPrefix;
-        std::cerr << "N: " << ns->namespacePrefix << "=" << ns->namespaceUri
-                << " (line=" << ns->lineNumber << ")\n";
+    const size_t previousSize = mPrefix.size();
+    mPrefix += "  ";
+    xml::Visitor::visit(el);
+    mPrefix.resize(previousSize);
+  }
 
-        const size_t previousSize = mPrefix.size();
-        mPrefix += "  ";
-        xml::Visitor::visit(ns);
-        mPrefix.resize(previousSize);
-    }
+  void visit(xml::Namespace* ns) override {
+    std::cerr << mPrefix;
+    std::cerr << "N: " << ns->namespacePrefix << "=" << ns->namespaceUri
+              << " (line=" << ns->lineNumber << ")\n";
 
-    void visit(xml::Text* text) override {
-        std::cerr << mPrefix;
-        std::cerr << "T: '" << text->text << "'\n";
-    }
+    const size_t previousSize = mPrefix.size();
+    mPrefix += "  ";
+    xml::Visitor::visit(ns);
+    mPrefix.resize(previousSize);
+  }
 
-private:
-    std::string mPrefix;
+  void visit(xml::Text* text) override {
+    std::cerr << mPrefix;
+    std::cerr << "T: '" << text->text << "'\n";
+  }
+
+ private:
+  std::string mPrefix;
 };
 
-} // namespace
+}  // namespace
 
 void Debug::dumpXml(xml::XmlResource* doc) {
-    XmlPrinter printer;
-    doc->root->accept(&printer);
+  XmlPrinter printer;
+  doc->root->accept(&printer);
 }
 
-} // namespace aapt
+}  // namespace aapt