зеркало из https://github.com/microsoft/clang-1.git
libclang: some type safety for CXTranslationUnitImpl's internals
There is no reason to store pointers as 'void*' in CXTranslationUnitImpl, since it does not affect libclang ABI. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173588 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
e3fac338e0
Коммит
e42e578ad8
|
@ -60,12 +60,12 @@ using namespace clang::cxstring;
|
|||
using namespace clang::cxtu;
|
||||
using namespace clang::cxindex;
|
||||
|
||||
CXTranslationUnit cxtu::MakeCXTranslationUnit(CIndexer *CIdx, ASTUnit *TU) {
|
||||
if (!TU)
|
||||
CXTranslationUnit cxtu::MakeCXTranslationUnit(CIndexer *CIdx, ASTUnit *AU) {
|
||||
if (!AU)
|
||||
return 0;
|
||||
CXTranslationUnit D = new CXTranslationUnitImpl();
|
||||
D->CIdx = CIdx;
|
||||
D->TUData = TU;
|
||||
D->TheASTUnit = AU;
|
||||
D->StringPool = createCXStringPool();
|
||||
D->Diagnostics = 0;
|
||||
D->OverridenCursorsPool = createOverridenCXCursorsPool();
|
||||
|
|
|
@ -209,7 +209,7 @@ CXDiagnosticSetImpl *cxdiag::lazyCreateDiags(CXTranslationUnit TU,
|
|||
extern "C" {
|
||||
|
||||
unsigned clang_getNumDiagnostics(CXTranslationUnit Unit) {
|
||||
if (!Unit->TUData)
|
||||
if (!cxtu::getASTUnit(Unit))
|
||||
return 0;
|
||||
return lazyCreateDiags(Unit, /*checkIfChanged=*/true)->getNumDiagnostics();
|
||||
}
|
||||
|
@ -227,7 +227,7 @@ CXDiagnostic clang_getDiagnostic(CXTranslationUnit Unit, unsigned Index) {
|
|||
}
|
||||
|
||||
CXDiagnosticSet clang_getDiagnosticSetFromTU(CXTranslationUnit Unit) {
|
||||
if (!Unit->TUData)
|
||||
if (!cxtu::getASTUnit(Unit))
|
||||
return 0;
|
||||
return static_cast<CXDiagnostic>(lazyCreateDiags(Unit));
|
||||
}
|
||||
|
|
|
@ -16,17 +16,20 @@
|
|||
|
||||
#include "clang-c/Index.h"
|
||||
|
||||
extern "C" {
|
||||
namespace clang {
|
||||
class ASTUnit;
|
||||
class CIndexer;
|
||||
} // namespace clang
|
||||
|
||||
struct CXTranslationUnitImpl {
|
||||
void *CIdx;
|
||||
void *TUData;
|
||||
clang::ASTUnit *TheASTUnit;
|
||||
void *StringPool;
|
||||
void *Diagnostics;
|
||||
void *OverridenCursorsPool;
|
||||
void *FormatContext;
|
||||
unsigned FormatInMemoryUniqueId;
|
||||
};
|
||||
}
|
||||
|
||||
namespace clang {
|
||||
class ASTUnit;
|
||||
|
@ -34,10 +37,10 @@ namespace clang {
|
|||
|
||||
namespace cxtu {
|
||||
|
||||
CXTranslationUnitImpl *MakeCXTranslationUnit(CIndexer *CIdx, ASTUnit *TU);
|
||||
CXTranslationUnitImpl *MakeCXTranslationUnit(CIndexer *CIdx, ASTUnit *AU);
|
||||
|
||||
static inline ASTUnit *getASTUnit(CXTranslationUnit TU) {
|
||||
return static_cast<ASTUnit *>(TU->TUData);
|
||||
return TU->TheASTUnit;
|
||||
}
|
||||
|
||||
class CXTUOwner {
|
||||
|
|
Загрузка…
Ссылка в новой задаче