From a5f1ff1afadbcff2f90757828b5f8a1147521c1c Mon Sep 17 00:00:00 2001 From: Marcello Maggioni Date: Thu, 12 Jan 2017 19:47:38 +0000 Subject: [PATCH] [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 llvm-svn: 291803 --- llvm/tools/llvm-config/llvm-config.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/llvm/tools/llvm-config/llvm-config.cpp b/llvm/tools/llvm-config/llvm-config.cpp index 529824534334..25344e4cd011 100644 --- a/llvm/tools/llvm-config/llvm-config.cpp +++ b/llvm/tools/llvm-config/llvm-config.cpp @@ -242,7 +242,7 @@ std::vector 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; }