Avoid dubious IdentifierInfo::getNameStart() uses
These cases in particular were incurring an extra strlen() when we already knew
the length. They appear to be leftovers from when the interfaces worked with C
strings that have continued to compile due to the implicit StringRef ctor.
llvm-svn: 210403
diff --git a/clang/tools/libclang/CXString.cpp b/clang/tools/libclang/CXString.cpp
index 1523034..662b0f9 100644
--- a/clang/tools/libclang/CXString.cpp
+++ b/clang/tools/libclang/CXString.cpp
@@ -81,7 +81,11 @@
CXString createRef(StringRef String) {
// If the string is not nul-terminated, we have to make a copy.
- // This is doing a one past end read, and should be removed!
+
+ // FIXME: This is doing a one past end read, and should be removed! For memory
+ // we don't manage, the API string can become unterminated at any time outside
+ // our control.
+
if (!String.empty() && String.data()[String.size()] != 0)
return createDup(String);