]> granicus.if.org Git - llvm/commitdiff
[llvm-config] Fix obviously wrong code in parsing DyLib components.
authorMarcello Maggioni <hayarms@gmail.com>
Thu, 12 Jan 2017 19:47:38 +0000 (19:47 +0000)
committerMarcello Maggioni <hayarms@gmail.com>
Thu, 12 Jan 2017 19:47:38 +0000 (19:47 +0000)
The code parsing the string was using the offset returned from
StringRef::find() wrong, assuming it was relative to the staring
offset that is passed to the function, but the returned offset
is always relative to the beginning of the line.

This causes odd behaviour while parsing the component string.
Spotted thanks to the newly added test:

tools/llvm-config/booleans.test

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@291803 91177308-0d34-0410-b5e6-96231b3b80d8

tools/llvm-config/llvm-config.cpp

index 52982453433446a1bc709356122e0dd944e663cb..25344e4cd01180906b9d9f32b59fc57bd7c52e18 100644 (file)
@@ -242,7 +242,7 @@ std::vector<std::string> GetAllDyLibComponents(const bool IsInDevelopmentTree,
   size_t Offset = 0;
   while (true) {
     const size_t NextOffset = DyLibComponentsStr.find(';', Offset);
-    DyLibComponents.push_back(DyLibComponentsStr.substr(Offset, NextOffset));
+    DyLibComponents.push_back(DyLibComponentsStr.substr(Offset, NextOffset-Offset));
     if (NextOffset == std::string::npos) {
       break;
     }