summaryrefslogtreecommitdiff
path: root/tools/llvm-config
diff options
context:
space:
mode:
authorDavid Blaikie <dblaikie@gmail.com>2015-11-09 23:51:45 +0000
committerDavid Blaikie <dblaikie@gmail.com>2015-11-09 23:51:45 +0000
commit53b5ea7f56654f675eb197bece7af6c348fdf7d8 (patch)
tree534a0a4bfa69cff3b9c9a2ff723efa83cd33551f /tools/llvm-config
parentd4f7699f94e234873e3d8d78b80daba82c8e42be (diff)
Simplify some APIs I was cleaning up while fixing -Wpessimizing-move warning
(Reid fixed the original error, but this seems nice to do in any case) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@252548 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/llvm-config')
-rw-r--r--tools/llvm-config/llvm-config.cpp52
1 files changed, 25 insertions, 27 deletions
diff --git a/tools/llvm-config/llvm-config.cpp b/tools/llvm-config/llvm-config.cpp
index 934d710d497..f6d55b42260 100644
--- a/tools/llvm-config/llvm-config.cpp
+++ b/tools/llvm-config/llvm-config.cpp
@@ -107,12 +107,12 @@ static void VisitComponent(StringRef Name,
/// \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<StringRef>
+ComputeLibsForComponents(const std::vector<StringRef> &Components,
+ bool IncludeNonInstalled, bool GetComponentNames,
+ const std::string *ActiveLibDir, bool *HasMissing) {
+ std::vector<StringRef> RequiredLibs;
+ std::set<AvailableComponent *> VisitedComponents;
// Build a map of component names to information.
StringMap<AvailableComponent*> ComponentMap;
@@ -141,6 +141,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;
}
/* *** */
@@ -198,27 +200,23 @@ std::string GetExecutablePath(const char *Argv0) {
std::vector<StringRef> 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 Components;
+ return ComputeLibsForComponents(DyLibComponents,
+ /*IncludeNonInstalled=*/IsInDevelopmentTree,
+ GetComponentNames, nullptr, nullptr);
}
int main(int argc, char **argv) {
@@ -529,11 +527,11 @@ 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<StringRef> RequiredLibs =
+ ComputeLibsForComponents(Components,
+ /*IncludeNonInstalled=*/IsInDevelopmentTree,
+ false, &ActiveLibDir, &HasMissing);
if (PrintSharedMode) {
std::unordered_set<std::string> FullDyLibComponents;