Ted Kremenek 915542850b 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).

llvm-svn: 119337
2010-11-16 08:15:36 +00:00

54 lines
1.4 KiB
C++

//===- CXString.h - Routines for manipulating CXStrings -------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file defines routines for manipulating CXStrings.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_CLANG_CXSTRING_H
#define LLVM_CLANG_CXSTRING_H
#include "clang-c/Index.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/SmallString.h"
namespace clang {
namespace cxstring {
struct CXStringBuf {
llvm::SmallString<128> Data;
CXTranslationUnit TU;
CXStringBuf(CXTranslationUnit tu) : TU(tu) {}
};
/// \brief Create a CXString object from a C string.
CXString createCXString(const char *String, bool DupString = false);
/// \brief Create a CXString object from a StringRef.
CXString createCXString(llvm::StringRef String, bool DupString = true);
/// \brief Create a CXString object that is backed by a string buffer.
CXString createCXString(CXStringBuf *buf);
/// \brief Create an opaque string pool used for fast geneneration of strings.
void *createCXStringPool();
/// \brief Dispose of a string pool.
void disposeCXStringPool(void *pool);
CXStringBuf *getCXStringBuf(CXTranslationUnit TU);
void disposeCXStringBuf(CXStringBuf *buf);
}
}
#endif