[llvm] r291803 - [llvm-config] Fix obviously wrong code in parsing DyLib components.
Marcello Maggioni via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 12 11:47:38 PST 2017
Author: mggm
Date: Thu Jan 12 13:47:38 2017
New Revision: 291803
URL: http://llvm.org/viewvc/llvm-project?rev=291803&view=rev
Log:
[llvm-config] Fix obviously wrong code in parsing DyLib components.
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
Modified:
llvm/trunk/tools/llvm-config/llvm-config.cpp
Modified: llvm/trunk/tools/llvm-config/llvm-config.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-config/llvm-config.cpp?rev=291803&r1=291802&r2=291803&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-config/llvm-config.cpp (original)
+++ llvm/trunk/tools/llvm-config/llvm-config.cpp Thu Jan 12 13:47:38 2017
@@ -242,7 +242,7 @@ std::vector<std::string> GetAllDyLibComp
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;
}
More information about the llvm-commits
mailing list