forked from OSchip/llvm-project
Move CXString creation/management routines into
their own .cpp file and make the interpretation of its flags private. llvm-svn: 119319
This commit is contained in:
parent
4490e1015f
commit
4b4f36990d
|
@ -134,9 +134,7 @@ enum CXAvailabilityKind {
|
|||
*/
|
||||
typedef struct {
|
||||
const char *Spelling;
|
||||
/* A 1 value indicates the clang_ indexing API needed to allocate the string
|
||||
(and it must be freed by clang_disposeString()). */
|
||||
int MustFreeString;
|
||||
unsigned private_flags;
|
||||
} CXString;
|
||||
|
||||
/**
|
||||
|
|
|
@ -1306,7 +1306,7 @@ int print_usrs(const char **I, const char **E) {
|
|||
else {
|
||||
CXString x;
|
||||
x.Spelling = I[2];
|
||||
x.MustFreeString = 0;
|
||||
x.private_flags = 0;
|
||||
print_usr(clang_constructUSR_ObjCIvar(I[1], x));
|
||||
}
|
||||
|
||||
|
@ -1333,7 +1333,7 @@ int print_usrs(const char **I, const char **E) {
|
|||
else {
|
||||
CXString x;
|
||||
x.Spelling = I[3];
|
||||
x.MustFreeString = 0;
|
||||
x.private_flags = 0;
|
||||
print_usr(clang_constructUSR_ObjCMethod(I[1], atoi(I[2]), x));
|
||||
}
|
||||
I += 4;
|
||||
|
@ -1363,7 +1363,7 @@ int print_usrs(const char **I, const char **E) {
|
|||
else {
|
||||
CXString x;
|
||||
x.Spelling = I[2];
|
||||
x.MustFreeString = 0;
|
||||
x.private_flags = 0;
|
||||
print_usr(clang_constructUSR_ObjCProperty(I[1], x));
|
||||
}
|
||||
I += 3;
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
#include "CIndexer.h"
|
||||
#include "CXCursor.h"
|
||||
#include "CXString.h"
|
||||
#include "CXType.h"
|
||||
#include "CXSourceLocation.h"
|
||||
#include "CIndexDiagnostic.h"
|
||||
|
@ -4574,51 +4575,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.
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
#include "clang/AST/DeclTemplate.h"
|
||||
|
||||
using namespace clang;
|
||||
using namespace clang::cxstring;
|
||||
using namespace clang::cxcursor;
|
||||
|
||||
extern "C" {
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "CIndexer.h"
|
||||
#include "CXString.h"
|
||||
#include "CIndexDiagnostic.h"
|
||||
#include "clang/Basic/SourceManager.h"
|
||||
#include "clang/Basic/FileManager.h"
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include "CIndexDiagnostic.h"
|
||||
#include "CIndexer.h"
|
||||
#include "CXSourceLocation.h"
|
||||
#include "CXString.h"
|
||||
|
||||
#include "clang/Frontend/ASTUnit.h"
|
||||
#include "clang/Frontend/FrontendDiagnostic.h"
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
|
||||
#include "CIndexer.h"
|
||||
#include "CXCursor.h"
|
||||
#include "CXString.h"
|
||||
#include "clang/AST/DeclTemplate.h"
|
||||
#include "clang/AST/DeclVisitor.h"
|
||||
#include "clang/Frontend/ASTUnit.h"
|
||||
|
|
|
@ -24,13 +24,6 @@ namespace llvm {
|
|||
class CrashRecoveryContext;
|
||||
}
|
||||
|
||||
namespace clang {
|
||||
namespace cxstring {
|
||||
CXString createCXString(const char *String, bool DupString = false);
|
||||
CXString createCXString(llvm::StringRef String, bool DupString = true);
|
||||
}
|
||||
}
|
||||
|
||||
class CIndexer {
|
||||
bool OnlyLocalDecls;
|
||||
bool DisplayDiagnostics;
|
||||
|
|
|
@ -27,6 +27,7 @@ add_clang_library(libclang
|
|||
CIndexUSRs.cpp
|
||||
CIndexer.cpp
|
||||
CXCursor.cpp
|
||||
CXString.cpp
|
||||
CXType.cpp
|
||||
../../include/clang-c/Index.h
|
||||
)
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "CXCursor.h"
|
||||
#include "CXString.h"
|
||||
#include "clang/Frontend/ASTUnit.h"
|
||||
#include "clang/AST/Decl.h"
|
||||
#include "clang/AST/DeclCXX.h"
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
|
||||
#include "CIndexer.h"
|
||||
#include "CXCursor.h"
|
||||
#include "CXString.h"
|
||||
#include "CXType.h"
|
||||
#include "clang/AST/Expr.h"
|
||||
#include "clang/AST/Type.h"
|
||||
|
|
Loading…
Reference in New Issue