diff options
author | Ted Kremenek <kremenek@apple.com> | 2010-11-16 01:56:27 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2010-11-16 01:56:27 +0000 |
commit | ed122735639d83c10f18c28c7fd117bfcd0f62cb (patch) | |
tree | 622fbb3a83937c8666777a6aeb8b873e5186876b /tools/libclang/CIndex.cpp | |
parent | e3fe4cb0565694c7913349e5b14434a0e3c99fa5 (diff) |
Move CXString creation/management routines into
their own .cpp file and make the interpretation
of its flags private.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@119319 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/libclang/CIndex.cpp')
-rw-r--r-- | tools/libclang/CIndex.cpp | 46 |
1 files changed, 1 insertions, 45 deletions
diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp index b573c067a8..a25570e0c1 100644 --- a/tools/libclang/CIndex.cpp +++ b/tools/libclang/CIndex.cpp @@ -14,6 +14,7 @@ #include "CIndexer.h" #include "CXCursor.h" +#include "CXString.h" #include "CXType.h" #include "CXSourceLocation.h" #include "CIndexDiagnostic.h" @@ -4575,51 +4576,6 @@ CXType clang_getIBOutletCollectionType(CXCursor C) { } // end: extern "C" //===----------------------------------------------------------------------===// -// CXString Operations. -//===----------------------------------------------------------------------===// - -extern "C" { -const char *clang_getCString(CXString string) { - return string.Spelling; -} - -void clang_disposeString(CXString string) { - if (string.MustFreeString && string.Spelling) - free((void*)string.Spelling); -} - -} // end: extern "C" - -namespace clang { namespace cxstring { -CXString createCXString(const char *String, bool DupString){ - CXString Str; - if (DupString) { - Str.Spelling = strdup(String); - Str.MustFreeString = 1; - } else { - Str.Spelling = String; - Str.MustFreeString = 0; - } - return Str; -} - -CXString createCXString(llvm::StringRef String, bool DupString) { - CXString Result; - if (DupString || (!String.empty() && String.data()[String.size()] != 0)) { - char *Spelling = (char *)malloc(String.size() + 1); - memmove(Spelling, String.data(), String.size()); - Spelling[String.size()] = 0; - Result.Spelling = Spelling; - Result.MustFreeString = 1; - } else { - Result.Spelling = String.data(); - Result.MustFreeString = 0; - } - return Result; -} -}} - -//===----------------------------------------------------------------------===// // Misc. utility functions. //===----------------------------------------------------------------------===// |