summaryrefslogtreecommitdiffstats
path: root/clang/tools/libclang/CXString.cpp
diff options
context:
space:
mode:
authorAlp Toker <alp@nuanti.com>2014-06-07 23:30:53 +0000
committerAlp Toker <alp@nuanti.com>2014-06-07 23:30:53 +0000
commit541d5070bfb4c617e389b6aecc57fdf0738ad243 (patch)
tree32d2cc604223f90772d6fff814f4fff3f16838c0 /clang/tools/libclang/CXString.cpp
parent4925ba7ffe7d5af68f2587944d0185e864c3ec77 (diff)
downloadbcm5719-llvm-541d5070bfb4c617e389b6aecc57fdf0738ad243.tar.gz
bcm5719-llvm-541d5070bfb4c617e389b6aecc57fdf0738ad243.zip
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
Diffstat (limited to 'clang/tools/libclang/CXString.cpp')
-rw-r--r--clang/tools/libclang/CXString.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/clang/tools/libclang/CXString.cpp b/clang/tools/libclang/CXString.cpp
index 1523034dbdd..662b0f94dbb 100644
--- a/clang/tools/libclang/CXString.cpp
+++ b/clang/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);
OpenPOWER on IntegriCloud