[llvm-dwp] Include the debug_line.dwo section
[oota-llvm.git] / tools / llvm-config / llvm-config.cpp
index 44ab715f965d5c26556876db31356172a9a25143..80f627936d0cf1068245f0d1ad81ef4bfe469e4a 100644 (file)
@@ -56,10 +56,10 @@ using namespace llvm;
 /// libraries.
 /// \param GetComponentNames - Get the component names instead of the
 /// library name.
-static void VisitComponent(StringRef Name,
+static void VisitComponent(const std::string& Name,
                            const StringMap<AvailableComponent*> &ComponentMap,
                            std::set<AvailableComponent*> &VisitedComponents,
-                           std::vector<StringRef> &RequiredLibs,
+                           std::vector<std::string> &RequiredLibs,
                            bool IncludeNonInstalled, bool GetComponentNames,
                            const std::string *ActiveLibDir, bool *HasMissing) {
   // Lookup the component.
@@ -102,17 +102,15 @@ static void VisitComponent(StringRef Name,
 /// appear prior to their dependencies).
 ///
 /// \param Components - The names of the components to find libraries for.
-/// \param RequiredLibs [out] - On return, the ordered list of libraries that
-/// are required to link the given components.
 /// \param IncludeNonInstalled - Whether non-installed components should be
 /// reported.
 /// \param GetComponentNames - True if one would prefer the component names.
-static void ComputeLibsForComponents(const std::vector<StringRef> &Components,
-                                     std::vector<StringRef> &RequiredLibs,
-                                     bool IncludeNonInstalled, bool GetComponentNames,
-                                     const std::string *ActiveLibDir,
-                                     bool *HasMissing) {
-  std::set<AvailableComponent*> VisitedComponents;
+static std::vector<std::string>
+ComputeLibsForComponents(const std::vector<StringRef> &Components,
+                         bool IncludeNonInstalled, bool GetComponentNames,
+                         const std::string *ActiveLibDir, bool *HasMissing) {
+  std::vector<std::string> RequiredLibs;
+  std::set<AvailableComponent *> VisitedComponents;
 
   // Build a map of component names to information.
   StringMap<AvailableComponent*> ComponentMap;
@@ -141,6 +139,8 @@ static void ComputeLibsForComponents(const std::vector<StringRef> &Components,
   // The list is now ordered with leafs first, we want the libraries to printed
   // in the reverse order of dependency.
   std::reverse(RequiredLibs.begin(), RequiredLibs.end());
+
+  return RequiredLibs;
 }
 
 /* *** */
@@ -195,30 +195,26 @@ std::string GetExecutablePath(const char *Argv0) {
 
 /// \brief Expand the semi-colon delimited LLVM_DYLIB_COMPONENTS into
 /// the full list of components.
-std::vector<StringRef> GetAllDyLibComponents(const bool IsInDevelopmentTree,
-                                             const bool GetComponentNames) {
+std::vector<std::string> GetAllDyLibComponents(const bool IsInDevelopmentTree,
+                                               const bool GetComponentNames) {
   std::vector<StringRef> DyLibComponents;
-  {
-    StringRef DyLibComponentsStr(LLVM_DYLIB_COMPONENTS);
-    size_t Offset = 0;
-    while (true) {
-      const size_t NextOffset = DyLibComponentsStr.find(';', Offset);
-      DyLibComponents.push_back(DyLibComponentsStr.substr(Offset, NextOffset));
-      if (NextOffset == std::string::npos) {
-        break;
-      }
-      Offset = NextOffset + 1;
-    }
 
-    assert(DyLibComponents.size() > 0);
+  StringRef DyLibComponentsStr(LLVM_DYLIB_COMPONENTS);
+  size_t Offset = 0;
+  while (true) {
+    const size_t NextOffset = DyLibComponentsStr.find(';', Offset);
+    DyLibComponents.push_back(DyLibComponentsStr.substr(Offset, NextOffset));
+    if (NextOffset == std::string::npos) {
+      break;
+    }
+    Offset = NextOffset + 1;
   }
 
-  std::vector<StringRef> Components;
-  ComputeLibsForComponents(DyLibComponents, Components,
-                           /*IncludeNonInstalled=*/IsInDevelopmentTree,
-                           GetComponentNames, nullptr, nullptr);
+  assert(!DyLibComponents.empty());
 
-  return std::move(Components);
+  return ComputeLibsForComponents(DyLibComponents,
+                                  /*IncludeNonInstalled=*/IsInDevelopmentTree,
+                                  GetComponentNames, nullptr, nullptr);
 }
 
 int main(int argc, char **argv) {
@@ -335,7 +331,7 @@ int main(int argc, char **argv) {
     StaticExt = "a";
     SharedDir = ActiveBinDir;
     StaticDir = ActiveLibDir;
-    StaticPrefix = SharedPrefix = "";
+    StaticPrefix = SharedPrefix = "lib";
   } else if (HostTriple.isOSDarwin()) {
     SharedExt = "dylib";
     SharedVersionedExt = PACKAGE_VERSION ".dylib";
@@ -457,7 +453,7 @@ int main(int argc, char **argv) {
         /// If there are missing static archives and a dylib was
         /// built, print LLVM_DYLIB_COMPONENTS instead of everything
         /// in the manifest.
-        std::vector<StringRef> Components;
+        std::vector<std::string> Components;
         for (unsigned j = 0; j != array_lengthof(AvailableComponents); ++j) {
           // Only include non-installed components when in a development tree.
           if (!AvailableComponents[j].IsInstalled && !IsInDevelopmentTree)
@@ -529,15 +525,15 @@ int main(int argc, char **argv) {
       Components.push_back("all");
 
     // Construct the list of all the required libraries.
-    std::vector<StringRef> RequiredLibs;
     bool HasMissing = false;
-    ComputeLibsForComponents(Components, RequiredLibs,
-                             /*IncludeNonInstalled=*/IsInDevelopmentTree, false,
-                             &ActiveLibDir, &HasMissing);
+    std::vector<std::string> RequiredLibs =
+        ComputeLibsForComponents(Components,
+                                 /*IncludeNonInstalled=*/IsInDevelopmentTree,
+                                 false, &ActiveLibDir, &HasMissing);
 
     if (PrintSharedMode) {
       std::unordered_set<std::string> FullDyLibComponents;
-      std::vector<StringRef> DyLibComponents =
+      std::vector<std::string> DyLibComponents =
           GetAllDyLibComponents(IsInDevelopmentTree, false);
 
       for (auto &Component : DyLibComponents) {
@@ -589,7 +585,7 @@ int main(int argc, char **argv) {
         PrintForLib(DyLibName, true);
       } else {
         for (unsigned i = 0, e = RequiredLibs.size(); i != e; ++i) {
-          StringRef Lib = RequiredLibs[i];
+          auto Lib = RequiredLibs[i];
           if (i)
             OS << ' ';