Comment to XML conversion: escape XML special chars correctly; use correct
regex for version tuples.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165104 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/tools/libclang/CXComment.cpp b/tools/libclang/CXComment.cpp
index c0e5bc2..b0e190a 100644
--- a/tools/libclang/CXComment.cpp
+++ b/tools/libclang/CXComment.cpp
@@ -1180,18 +1180,18 @@
           if (DA->getMessage().empty())
             Result << "<Deprecated/>";
           else {
-            Result << "<Deprecated>"
-                   << DA->getMessage()
-                   << "</Deprecated>";
+            Result << "<Deprecated>";
+            appendToResultWithXMLEscaping(DA->getMessage());
+            Result << "</Deprecated>";
           }
         }
         else if (const UnavailableAttr *UA = dyn_cast<UnavailableAttr>(Attrs[i])) {
           if (UA->getMessage().empty())
             Result << "<Unavailable/>";
           else {
-            Result << "<Unavailable>"
-                   << UA->getMessage()
-                   << "</Unavailable>";
+            Result << "<Unavailable>";
+            appendToResultWithXMLEscaping(UA->getMessage());
+            Result << "</Unavailable>";
           }
         }
         continue;
@@ -1225,14 +1225,12 @@
                << RemovedAfterVersion.getAsString()
                << "</RemovedAfterVersion>";
       }
-      // 'deprecated' attribute.
       StringRef DeprecationSummary = AA->getMessage();
       if (!DeprecationSummary.empty()) {
-        Result << " <DeprecationSummary>"
-               << DeprecationSummary
-               << "</DeprecationSummary>";
+        Result << "<DeprecationSummary>";
+        appendToResultWithXMLEscaping(DeprecationSummary);
+        Result << "</DeprecationSummary>";
       }
-      // 'unavailable' attribute.
       if (AA->getUnavailable())
         Result << "<Unavailable/>";
       Result << "</Availability>";