libclang: introduce cxstring::{createRef,createDup} for StringRefs

Also migrate all clients from the old API.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174263 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/tools/libclang/CXString.h b/tools/libclang/CXString.h
index 3b86826..7032033 100644
--- a/tools/libclang/CXString.h
+++ b/tools/libclang/CXString.h
@@ -18,7 +18,9 @@
 #include "clang/Basic/LLVM.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Compiler.h"
 #include <vector>
+#include <string>
 
 namespace clang {
 namespace cxstring {
@@ -45,8 +47,23 @@
 /// \p String can be changed or freed by the caller.
 CXString createDup(const char *String);
 
-/// \brief Create a CXString object from a StringRef.
-CXString createCXString(StringRef String, bool DupString = true);
+/// \brief Create a CXString object from a StringRef.  New CXString may
+/// contain a pointer to the undrelying data of \p String.
+///
+/// \p String should not be changed by the caller afterwards.
+CXString createRef(StringRef String);
+
+/// \brief Create a CXString object from a StringRef.  New CXString will
+/// contain a copy of \p String.
+///
+/// \p String can be changed or freed by the caller.
+CXString createDup(StringRef String);
+
+// Usually std::string is intended to be used as backing storage for CXString.
+// In this case, call \c createRef(String.c_str()).
+//
+// If you need to make a copy, call \c createDup(StringRef(String)).
+CXString createRef(std::string String) LLVM_DELETED_FUNCTION;
 
 /// \brief Create a CXString object that is backed by a string buffer.
 CXString createCXString(CXStringBuf *buf);