Change CXTranslationUnit to not directly cast to an ASTUnit*,
but to wrap both an ASTUnit and a "string pool"
that will be used for fast USR generation.

This requires a bunch of mechanical changes, as
there was a ton of code that assumed that CXTranslationUnit
and ASTUnit* were the same.

Along with this change, introduce CXStringBuf,
which provides an llvm::SmallVector<char> backing
for repeatedly generating CXStrings without a huge
amount of malloc() traffic.  This requires making
some changes to the representation of CXString
by renaming a few fields (but keeping the size
of the object the same).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@119337 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/tools/libclang/CIndexDiagnostic.cpp b/tools/libclang/CIndexDiagnostic.cpp
index 84f39e3..31ca679 100644
--- a/tools/libclang/CIndexDiagnostic.cpp
+++ b/tools/libclang/CIndexDiagnostic.cpp
@@ -33,12 +33,12 @@
 extern "C" {
 
 unsigned clang_getNumDiagnostics(CXTranslationUnit Unit) {
-  ASTUnit *CXXUnit = static_cast<ASTUnit *>(Unit);
+  ASTUnit *CXXUnit = static_cast<ASTUnit *>(Unit->TUData);
   return CXXUnit? CXXUnit->stored_diag_size() : 0;
 }
 
 CXDiagnostic clang_getDiagnostic(CXTranslationUnit Unit, unsigned Index) {
-  ASTUnit *CXXUnit = static_cast<ASTUnit *>(Unit);
+  ASTUnit *CXXUnit = static_cast<ASTUnit *>(Unit->TUData);
   if (!CXXUnit || Index >= CXXUnit->stored_diag_size())
     return 0;