Don't rely on a StringRef being null-terminated (it's not) for deprecation messages.
Store pointer and length of the message in DelayedDiagnostic and hide the gory union details.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@116153 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index e35b6c2..38287e4 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -57,11 +57,8 @@
 ///
 bool Sema::DiagnoseUseOfDecl(NamedDecl *D, SourceLocation Loc) {
   // See if the decl is deprecated.
-  if (const DeprecatedAttr *DA = D->getAttr<DeprecatedAttr>()) {
-    const char *Message = 
-      DA->getMessage().empty() ? 0 : DA->getMessage().data();
-    EmitDeprecationWarning(D, Message, Loc);
-  }
+  if (const DeprecatedAttr *DA = D->getAttr<DeprecatedAttr>())
+    EmitDeprecationWarning(D, DA->getMessage(), Loc);
 
   // See if the decl is unavailable
   if (const UnavailableAttr *UA = D->getAttr<UnavailableAttr>()) {
@@ -69,7 +66,7 @@
       Diag(Loc, diag::err_unavailable) << D->getDeclName();
     else
       Diag(Loc, diag::err_unavailable_message) 
-        << D->getDeclName() << UA->getMessage().data();
+        << D->getDeclName() << UA->getMessage();
     Diag(D->getLocation(), diag::note_unavailable_here) << 0;
   }