Remove obsolete InheritedLibraries class.

This class is no longer used in the source tree, due
to the use of TargetPublicPair and TargetPublicPairBuilder
classes in the ResolvedTargetData class.

Bug: 331
Change-Id: Ibb269bf35a7d92421b2389caf4fd5659f817c329
Reviewed-on: https://gn-review.googlesource.com/c/gn/+/14884
Reviewed-by: Takuto Ikuta <tikuta@google.com>
Commit-Queue: David Turner <digit@google.com>
diff --git a/build/gen.py b/build/gen.py
index 76fddfb..6c7ac3a 100755
--- a/build/gen.py
+++ b/build/gen.py
@@ -649,7 +649,6 @@
         'src/gn/group_target_generator.cc',
         'src/gn/header_checker.cc',
         'src/gn/import_manager.cc',
-        'src/gn/inherited_libraries.cc',
         'src/gn/input_conversion.cc',
         'src/gn/input_file.cc',
         'src/gn/input_file_manager.cc',
@@ -778,7 +777,6 @@
         'src/gn/functions_unittest.cc',
         'src/gn/hash_table_base_unittest.cc',
         'src/gn/header_checker_unittest.cc',
-        'src/gn/inherited_libraries_unittest.cc',
         'src/gn/input_conversion_unittest.cc',
         'src/gn/json_project_writer_unittest.cc',
         'src/gn/rust_project_writer_unittest.cc',
diff --git a/src/gn/inherited_libraries.cc b/src/gn/inherited_libraries.cc
deleted file mode 100644
index 977e97d..0000000
--- a/src/gn/inherited_libraries.cc
+++ /dev/null
@@ -1,52 +0,0 @@
-// Copyright 2015 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "gn/inherited_libraries.h"
-
-#include "gn/target.h"
-
-InheritedLibraries::InheritedLibraries() = default;
-
-InheritedLibraries::~InheritedLibraries() = default;
-
-std::vector<std::pair<const Target*, bool>>
-InheritedLibraries::GetOrderedAndPublicFlag() const {
-  std::vector<std::pair<const Target*, bool>> result;
-  result.reserve(targets_.size());
-  for (size_t i = 0; i < targets_.size(); ++i)
-    result.emplace_back(targets_[i], public_flags_[i]);
-  return result;
-}
-
-void InheritedLibraries::Append(const Target* target, bool is_public) {
-  // Try to insert a new node.
-  auto ret = targets_.PushBackWithIndex(target);
-  if (ret.first) {
-    public_flags_.push_back(is_public);
-  } else if (is_public) {
-    // Target already present, if |is_public|, set its flag.
-    public_flags_[ret.second] = true;
-  }
-}
-
-void InheritedLibraries::AppendInherited(const InheritedLibraries& other,
-                                         bool is_public) {
-  // Append all items in order, mark them public only if the're already public
-  // and we're adding them publicly.
-  for (size_t i = 0; i < other.targets_.size(); ++i) {
-    Append(other.targets_[i], is_public && other.public_flags_[i]);
-  }
-}
-
-void InheritedLibraries::AppendPublicSharedLibraries(
-    const InheritedLibraries& other,
-    bool is_public) {
-  for (size_t i = 0; i < other.targets_.size(); ++i) {
-    const Target* target = other.targets_[i];
-    if (target->output_type() == Target::SHARED_LIBRARY &&
-        other.public_flags_[i]) {
-      Append(target, is_public);
-    }
-  }
-}
diff --git a/src/gn/inherited_libraries.h b/src/gn/inherited_libraries.h
deleted file mode 100644
index 7a3fc25..0000000
--- a/src/gn/inherited_libraries.h
+++ /dev/null
@@ -1,63 +0,0 @@
-// Copyright 2015 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef TOOLS_GN_INHERITED_LIBRARIES_H_
-#define TOOLS_GN_INHERITED_LIBRARIES_H_
-
-#include <stddef.h>
-
-#include <utility>
-#include <vector>
-
-#include "gn/unique_vector.h"
-
-class Target;
-
-// Represents an ordered uniquified set of all shared/static libraries for
-// a given target. These are pushed up the dependency tree.
-//
-// Maintaining the order is important so GN links all libraries in the same
-// order specified in the build files.
-//
-// Since this list is uniquified, appending to the list will not actually
-// append a new item if the target already exists. However, the existing one
-// may have its is_public flag updated. "Public" always wins, so is_public will
-// be true if any dependency with that name has been set to public.
-class InheritedLibraries {
- public:
-  InheritedLibraries();
-  ~InheritedLibraries();
-
-  // Returns the list of dependencies in order, optionally with the flag
-  // indicating whether the dependency is public.
-  std::vector<const Target*> GetOrdered() const { return targets_.vector(); }
-  std::vector<std::pair<const Target*, bool>> GetOrderedAndPublicFlag() const;
-
-  // Adds a single dependency to the end of the list. See note on adding above.
-  void Append(const Target* target, bool is_public);
-
-  // Appends all items from the "other" list to the current one. The is_public
-  // parameter indicates how the current target depends on the items in
-  // "other". If is_public is true, the existing public flags of the appended
-  // items will be preserved (propagating the public-ness up the dependency
-  // chain). If is_public is false, all deps will be added as private since
-  // the current target isn't forwarding them.
-  void AppendInherited(const InheritedLibraries& other, bool is_public);
-
-  // Like AppendInherited but only appends the items in "other" that are of
-  // type SHARED_LIBRARY and only when they're marked public. This is used
-  // to push shared libraries up the dependency chain, following only public
-  // deps, to dependent targets that need to use them.
-  void AppendPublicSharedLibraries(const InheritedLibraries& other,
-                                   bool is_public);
-
- private:
-  UniqueVector<const Target*> targets_;
-  std::vector<bool> public_flags_;
-
-  InheritedLibraries(const InheritedLibraries&) = delete;
-  InheritedLibraries& operator=(const InheritedLibraries&) = delete;
-};
-
-#endif  // TOOLS_GN_INHERITED_LIBRARIES_H_
diff --git a/src/gn/inherited_libraries_unittest.cc b/src/gn/inherited_libraries_unittest.cc
deleted file mode 100644
index bd77426..0000000
--- a/src/gn/inherited_libraries_unittest.cc
+++ /dev/null
@@ -1,135 +0,0 @@
-// Copyright 2015 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "gn/inherited_libraries.h"
-#include "gn/target.h"
-#include "gn/test_with_scope.h"
-#include "util/test/test.h"
-
-namespace {
-
-// In these tests, Pair can't be used conveniently because the
-// "const" won't be inferred and the types won't match. This helper makes the
-// right type of pair with the const Target.
-std::pair<const Target*, bool> Pair(const Target* t, bool b) {
-  return std::pair<const Target*, bool>(t, b);
-}
-
-}  // namespace
-
-TEST(InheritedLibraries, Unique) {
-  TestWithScope setup;
-
-  Target a(setup.settings(), Label(SourceDir("//foo/"), "a"));
-  Target b(setup.settings(), Label(SourceDir("//foo/"), "b"));
-
-  // Setup, add the two targets as private.
-  InheritedLibraries libs;
-  libs.Append(&a, false);
-  libs.Append(&b, false);
-  auto result = libs.GetOrderedAndPublicFlag();
-  ASSERT_EQ(2u, result.size());
-  EXPECT_EQ(Pair(&a, false), result[0]);
-  EXPECT_EQ(Pair(&b, false), result[1]);
-
-  // Add again as private, this should be a NOP.
-  libs.Append(&a, false);
-  libs.Append(&b, false);
-  result = libs.GetOrderedAndPublicFlag();
-  ASSERT_EQ(2u, result.size());
-  EXPECT_EQ(Pair(&a, false), result[0]);
-  EXPECT_EQ(Pair(&b, false), result[1]);
-
-  // Add as public, this should make both public.
-  libs.Append(&a, true);
-  libs.Append(&b, true);
-  result = libs.GetOrderedAndPublicFlag();
-  ASSERT_EQ(2u, result.size());
-  EXPECT_EQ(Pair(&a, true), result[0]);
-  EXPECT_EQ(Pair(&b, true), result[1]);
-
-  // Add again private, they should stay public.
-  libs.Append(&a, false);
-  libs.Append(&b, false);
-  result = libs.GetOrderedAndPublicFlag();
-  ASSERT_EQ(2u, result.size());
-  EXPECT_EQ(Pair(&a, true), result[0]);
-  EXPECT_EQ(Pair(&b, true), result[1]);
-}
-
-TEST(InheritedLibraries, AppendInherited) {
-  TestWithScope setup;
-
-  Target a(setup.settings(), Label(SourceDir("//foo/"), "a"));
-  Target b(setup.settings(), Label(SourceDir("//foo/"), "b"));
-  Target w(setup.settings(), Label(SourceDir("//foo/"), "w"));
-  Target x(setup.settings(), Label(SourceDir("//foo/"), "x"));
-  Target y(setup.settings(), Label(SourceDir("//foo/"), "y"));
-  Target z(setup.settings(), Label(SourceDir("//foo/"), "z"));
-
-  InheritedLibraries libs;
-  libs.Append(&a, false);
-  libs.Append(&b, false);
-
-  // Appending these things with private inheritance should make them private,
-  // no matter how they're listed in the appended class.
-  InheritedLibraries append_private;
-  append_private.Append(&a, true);
-  append_private.Append(&b, false);
-  append_private.Append(&w, true);
-  append_private.Append(&x, false);
-  libs.AppendInherited(append_private, false);
-
-  auto result = libs.GetOrderedAndPublicFlag();
-  ASSERT_EQ(4u, result.size());
-  EXPECT_EQ(Pair(&a, false), result[0]);
-  EXPECT_EQ(Pair(&b, false), result[1]);
-  EXPECT_EQ(Pair(&w, false), result[2]);
-  EXPECT_EQ(Pair(&x, false), result[3]);
-
-  // Appending these things with public inheritance should convert them.
-  InheritedLibraries append_public;
-  append_public.Append(&a, true);
-  append_public.Append(&b, false);
-  append_public.Append(&y, true);
-  append_public.Append(&z, false);
-  libs.AppendInherited(append_public, true);
-
-  result = libs.GetOrderedAndPublicFlag();
-  ASSERT_EQ(6u, result.size());
-  EXPECT_EQ(Pair(&a, true), result[0]);  // Converted to public.
-  EXPECT_EQ(Pair(&b, false), result[1]);
-  EXPECT_EQ(Pair(&w, false), result[2]);
-  EXPECT_EQ(Pair(&x, false), result[3]);
-  EXPECT_EQ(Pair(&y, true), result[4]);  // Appended as public.
-  EXPECT_EQ(Pair(&z, false), result[5]);
-}
-
-TEST(InheritedLibraries, AppendPublicSharedLibraries) {
-  TestWithScope setup;
-  InheritedLibraries append;
-
-  // Two source sets.
-  Target set_pub(setup.settings(), Label(SourceDir("//foo/"), "set_pub"));
-  set_pub.set_output_type(Target::SOURCE_SET);
-  append.Append(&set_pub, true);
-  Target set_priv(setup.settings(), Label(SourceDir("//foo/"), "set_priv"));
-  set_priv.set_output_type(Target::SOURCE_SET);
-  append.Append(&set_priv, false);
-
-  // Two shared libraries.
-  Target sh_pub(setup.settings(), Label(SourceDir("//foo/"), "sh_pub"));
-  sh_pub.set_output_type(Target::SHARED_LIBRARY);
-  append.Append(&sh_pub, true);
-  Target sh_priv(setup.settings(), Label(SourceDir("//foo/"), "sh_priv"));
-  sh_priv.set_output_type(Target::SHARED_LIBRARY);
-  append.Append(&sh_priv, false);
-
-  InheritedLibraries libs;
-  libs.AppendPublicSharedLibraries(append, true);
-
-  auto result = libs.GetOrderedAndPublicFlag();
-  ASSERT_EQ(1u, result.size());
-  EXPECT_EQ(Pair(&sh_pub, true), result[0]);
-}