r252852 - libclang: add new StringSet type
Saleem Abdulrasool via cfe-commits
cfe-commits at lists.llvm.org
Wed Nov 11 19:57:17 PST 2015
Author: compnerd
Date: Wed Nov 11 21:57:16 2015
New Revision: 252852
URL: http://llvm.org/viewvc/llvm-project?rev=252852&view=rev
Log:
libclang: add new StringSet type
This allows the return of a set of CXStrings from libclang. This is setup work
for an upcoming change to permit returning multiple mangled symbols.
Modified:
cfe/trunk/include/clang-c/CXString.h
cfe/trunk/tools/libclang/CXString.cpp
cfe/trunk/tools/libclang/CXString.h
cfe/trunk/tools/libclang/libclang.exports
Modified: cfe/trunk/include/clang-c/CXString.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/CXString.h?rev=252852&r1=252851&r2=252852&view=diff
==============================================================================
--- cfe/trunk/include/clang-c/CXString.h (original)
+++ cfe/trunk/include/clang-c/CXString.h Wed Nov 11 21:57:16 2015
@@ -40,6 +40,11 @@ typedef struct {
unsigned private_flags;
} CXString;
+typedef struct {
+ CXString *Strings;
+ unsigned Count;
+} CXStringSet;
+
/**
* \brief Retrieve the character data associated with the given string.
*/
@@ -51,6 +56,11 @@ CINDEX_LINKAGE const char *clang_getCStr
CINDEX_LINKAGE void clang_disposeString(CXString string);
/**
+ * \brief Free the given string set.
+ */
+CINDEX_LINKAGE void clang_disposeStringSet(CXStringSet *set);
+
+/**
* @}
*/
Modified: cfe/trunk/tools/libclang/CXString.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CXString.cpp?rev=252852&r1=252851&r2=252852&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CXString.cpp (original)
+++ cfe/trunk/tools/libclang/CXString.cpp Wed Nov 11 21:57:16 2015
@@ -112,6 +112,15 @@ CXString createCXString(CXStringBuf *buf
return Str;
}
+CXStringSet *createSet(const std::vector<std::string> &Strings) {
+ CXStringSet *Set = new CXStringSet;
+ Set->Count = Strings.size();
+ Set->Strings = new CXString[Set->Count];
+ for (unsigned SI = 0, SE = Set->Count; SI < SE; ++SI)
+ Set->Strings[SI] = createDup(Strings[SI]);
+ return Set;
+}
+
//===----------------------------------------------------------------------===//
// String pools.
@@ -175,5 +184,11 @@ void clang_disposeString(CXString string
break;
}
}
+
+void clang_disposeStringSet(CXStringSet *set) {
+ delete[] set->Strings;
+ delete set;
+}
+
} // end: extern "C"
Modified: cfe/trunk/tools/libclang/CXString.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CXString.h?rev=252852&r1=252851&r2=252852&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CXString.h (original)
+++ cfe/trunk/tools/libclang/CXString.h Wed Nov 11 21:57:16 2015
@@ -68,6 +68,8 @@ CXString createRef(std::string String) =
/// \brief Create a CXString object that is backed by a string buffer.
CXString createCXString(CXStringBuf *buf);
+CXStringSet *createSet(const std::vector<std::string> &Strings);
+
/// \brief A string pool used for fast allocation/deallocation of strings.
class CXStringPool {
public:
Modified: cfe/trunk/tools/libclang/libclang.exports
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/libclang.exports?rev=252852&r1=252851&r2=252852&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/libclang.exports (original)
+++ cfe/trunk/tools/libclang/libclang.exports Wed Nov 11 21:57:16 2015
@@ -120,6 +120,7 @@ clang_disposeOverriddenCursors
clang_disposeCXPlatformAvailability
clang_disposeSourceRangeList
clang_disposeString
+clang_disposeStringSet
clang_disposeTokens
clang_disposeTranslationUnit
clang_enableStackTraces
More information about the cfe-commits
mailing list