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 {
|
typedef struct {
|
||||||
const char *Spelling;
|
const char *Spelling;
|
||||||
/* A 1 value indicates the clang_ indexing API needed to allocate the string
|
unsigned private_flags;
|
||||||
(and it must be freed by clang_disposeString()). */
|
|
||||||
int MustFreeString;
|
|
||||||
} CXString;
|
} CXString;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1306,7 +1306,7 @@ int print_usrs(const char **I, const char **E) {
|
||||||
else {
|
else {
|
||||||
CXString x;
|
CXString x;
|
||||||
x.Spelling = I[2];
|
x.Spelling = I[2];
|
||||||
x.MustFreeString = 0;
|
x.private_flags = 0;
|
||||||
print_usr(clang_constructUSR_ObjCIvar(I[1], x));
|
print_usr(clang_constructUSR_ObjCIvar(I[1], x));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1333,7 +1333,7 @@ int print_usrs(const char **I, const char **E) {
|
||||||
else {
|
else {
|
||||||
CXString x;
|
CXString x;
|
||||||
x.Spelling = I[3];
|
x.Spelling = I[3];
|
||||||
x.MustFreeString = 0;
|
x.private_flags = 0;
|
||||||
print_usr(clang_constructUSR_ObjCMethod(I[1], atoi(I[2]), x));
|
print_usr(clang_constructUSR_ObjCMethod(I[1], atoi(I[2]), x));
|
||||||
}
|
}
|
||||||
I += 4;
|
I += 4;
|
||||||
|
@ -1363,7 +1363,7 @@ int print_usrs(const char **I, const char **E) {
|
||||||
else {
|
else {
|
||||||
CXString x;
|
CXString x;
|
||||||
x.Spelling = I[2];
|
x.Spelling = I[2];
|
||||||
x.MustFreeString = 0;
|
x.private_flags = 0;
|
||||||
print_usr(clang_constructUSR_ObjCProperty(I[1], x));
|
print_usr(clang_constructUSR_ObjCProperty(I[1], x));
|
||||||
}
|
}
|
||||||
I += 3;
|
I += 3;
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
|
|
||||||
#include "CIndexer.h"
|
#include "CIndexer.h"
|
||||||
#include "CXCursor.h"
|
#include "CXCursor.h"
|
||||||
|
#include "CXString.h"
|
||||||
#include "CXType.h"
|
#include "CXType.h"
|
||||||
#include "CXSourceLocation.h"
|
#include "CXSourceLocation.h"
|
||||||
#include "CIndexDiagnostic.h"
|
#include "CIndexDiagnostic.h"
|
||||||
|
@ -4574,51 +4575,6 @@ CXType clang_getIBOutletCollectionType(CXCursor C) {
|
||||||
}
|
}
|
||||||
} // end: extern "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.
|
// Misc. utility functions.
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
|
@ -18,7 +18,6 @@
|
||||||
#include "clang/AST/DeclTemplate.h"
|
#include "clang/AST/DeclTemplate.h"
|
||||||
|
|
||||||
using namespace clang;
|
using namespace clang;
|
||||||
using namespace clang::cxstring;
|
|
||||||
using namespace clang::cxcursor;
|
using namespace clang::cxcursor;
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
#include "CIndexer.h"
|
#include "CIndexer.h"
|
||||||
|
#include "CXString.h"
|
||||||
#include "CIndexDiagnostic.h"
|
#include "CIndexDiagnostic.h"
|
||||||
#include "clang/Basic/SourceManager.h"
|
#include "clang/Basic/SourceManager.h"
|
||||||
#include "clang/Basic/FileManager.h"
|
#include "clang/Basic/FileManager.h"
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
#include "CIndexDiagnostic.h"
|
#include "CIndexDiagnostic.h"
|
||||||
#include "CIndexer.h"
|
#include "CIndexer.h"
|
||||||
#include "CXSourceLocation.h"
|
#include "CXSourceLocation.h"
|
||||||
|
#include "CXString.h"
|
||||||
|
|
||||||
#include "clang/Frontend/ASTUnit.h"
|
#include "clang/Frontend/ASTUnit.h"
|
||||||
#include "clang/Frontend/FrontendDiagnostic.h"
|
#include "clang/Frontend/FrontendDiagnostic.h"
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
|
|
||||||
#include "CIndexer.h"
|
#include "CIndexer.h"
|
||||||
#include "CXCursor.h"
|
#include "CXCursor.h"
|
||||||
|
#include "CXString.h"
|
||||||
#include "clang/AST/DeclTemplate.h"
|
#include "clang/AST/DeclTemplate.h"
|
||||||
#include "clang/AST/DeclVisitor.h"
|
#include "clang/AST/DeclVisitor.h"
|
||||||
#include "clang/Frontend/ASTUnit.h"
|
#include "clang/Frontend/ASTUnit.h"
|
||||||
|
|
|
@ -24,13 +24,6 @@ namespace llvm {
|
||||||
class CrashRecoveryContext;
|
class CrashRecoveryContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace clang {
|
|
||||||
namespace cxstring {
|
|
||||||
CXString createCXString(const char *String, bool DupString = false);
|
|
||||||
CXString createCXString(llvm::StringRef String, bool DupString = true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class CIndexer {
|
class CIndexer {
|
||||||
bool OnlyLocalDecls;
|
bool OnlyLocalDecls;
|
||||||
bool DisplayDiagnostics;
|
bool DisplayDiagnostics;
|
||||||
|
|
|
@ -27,6 +27,7 @@ add_clang_library(libclang
|
||||||
CIndexUSRs.cpp
|
CIndexUSRs.cpp
|
||||||
CIndexer.cpp
|
CIndexer.cpp
|
||||||
CXCursor.cpp
|
CXCursor.cpp
|
||||||
|
CXString.cpp
|
||||||
CXType.cpp
|
CXType.cpp
|
||||||
../../include/clang-c/Index.h
|
../../include/clang-c/Index.h
|
||||||
)
|
)
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
#include "CXCursor.h"
|
#include "CXCursor.h"
|
||||||
|
#include "CXString.h"
|
||||||
#include "clang/Frontend/ASTUnit.h"
|
#include "clang/Frontend/ASTUnit.h"
|
||||||
#include "clang/AST/Decl.h"
|
#include "clang/AST/Decl.h"
|
||||||
#include "clang/AST/DeclCXX.h"
|
#include "clang/AST/DeclCXX.h"
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
|
|
||||||
#include "CIndexer.h"
|
#include "CIndexer.h"
|
||||||
#include "CXCursor.h"
|
#include "CXCursor.h"
|
||||||
|
#include "CXString.h"
|
||||||
#include "CXType.h"
|
#include "CXType.h"
|
||||||
#include "clang/AST/Expr.h"
|
#include "clang/AST/Expr.h"
|
||||||
#include "clang/AST/Type.h"
|
#include "clang/AST/Type.h"
|
||||||
|
|
Loading…
Reference in New Issue