From 6719dde6f3b5a94712a143da016ee5e214dc5f60 Mon Sep 17 00:00:00 2001 From: Alp Toker Date: Sat, 7 Jun 2014 23:30:53 +0000 Subject: 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@210403 91177308-0d34-0410-b5e6-96231b3b80d8 --- tools/libclang/CXString.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'tools') diff --git a/tools/libclang/CXString.cpp b/tools/libclang/CXString.cpp index 1523034dbd..662b0f94db 100644 --- a/tools/libclang/CXString.cpp +++ b/tools/libclang/CXString.cpp @@ -81,7 +81,11 @@ CXString createDup(const char *String) { 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); -- cgit v1.2.3