summaryrefslogtreecommitdiffstats
path: root/lldb/source/Core/ConstString.cpp
diff options
context:
space:
mode:
authorZachary Turner <zturner@google.com>2016-02-24 21:26:47 +0000
committerZachary Turner <zturner@google.com>2016-02-24 21:26:47 +0000
commit47c03462f52a13ba79ac257e7de88a74dd23f5d7 (patch)
tree33978281912ffc0642edc2732b252f5bb4698176 /lldb/source/Core/ConstString.cpp
parent72c57f49c4b5638626f5a6ff91187f33976c321f (diff)
downloadbcm5719-llvm-47c03462f52a13ba79ac257e7de88a74dd23f5d7.tar.gz
bcm5719-llvm-47c03462f52a13ba79ac257e7de88a74dd23f5d7.zip
Some fixes for case insensitive paths on Windows.
Paths on Windows are not case-sensitive. Because of this, if a file is called main.cpp, you should be able to set a breakpoint on it by using the name Main.cpp. In an ideal world, you could just tell people to match the case, but in practice this can be a real problem as it requires you to know whether the person who compiled the program ran "clang++ main.cpp" or "clang++ Main.cpp", both of which would work, regardless of what the file was actually called. This fixes http://llvm.org/pr22667 Patch by Petr Hons Differential Revision: http://reviews.llvm.org/D17492 Reviewed by: zturner llvm-svn: 261771
Diffstat (limited to 'lldb/source/Core/ConstString.cpp')
-rw-r--r--lldb/source/Core/ConstString.cpp29
1 files changed, 27 insertions, 2 deletions
diff --git a/lldb/source/Core/ConstString.cpp b/lldb/source/Core/ConstString.cpp
index c2e95d80172..b2f61ddf453 100644
--- a/lldb/source/Core/ConstString.cpp
+++ b/lldb/source/Core/ConstString.cpp
@@ -265,8 +265,25 @@ ConstString::GetLength () const
return StringPool().GetConstCStringLength (m_string);
}
+bool
+ConstString::Equals(const ConstString &lhs, const ConstString &rhs, const bool case_sensitive)
+{
+ if (lhs.m_string == rhs.m_string)
+ return true;
+
+ // Since the pointers weren't equal, and identical ConstStrings always have identical pointers,
+ // the result must be false for case sensitive equality test.
+ if (case_sensitive)
+ return false;
+
+ // perform case insensitive equality test
+ llvm::StringRef lhs_string_ref(lhs.m_string, StringPool().GetConstCStringLength(lhs.m_string));
+ llvm::StringRef rhs_string_ref(rhs.m_string, StringPool().GetConstCStringLength(rhs.m_string));
+ return lhs_string_ref.equals_lower(rhs_string_ref);
+}
+
int
-ConstString::Compare (const ConstString& lhs, const ConstString& rhs)
+ConstString::Compare(const ConstString &lhs, const ConstString &rhs, const bool case_sensitive)
{
// If the iterators are the same, this is the same string
const char *lhs_cstr = lhs.m_string;
@@ -277,7 +294,15 @@ ConstString::Compare (const ConstString& lhs, const ConstString& rhs)
{
llvm::StringRef lhs_string_ref (lhs_cstr, StringPool().GetConstCStringLength (lhs_cstr));
llvm::StringRef rhs_string_ref (rhs_cstr, StringPool().GetConstCStringLength (rhs_cstr));
- return lhs_string_ref.compare(rhs_string_ref);
+
+ if (case_sensitive)
+ {
+ return lhs_string_ref.compare(rhs_string_ref);
+ }
+ else
+ {
+ return lhs_string_ref.compare_lower(rhs_string_ref);
+ }
}
if (lhs_cstr)
OpenPOWER on IntegriCloud