зеркало из https://github.com/microsoft/clang-1.git
CIndex: Kill off CXSourceLocationPtr, and AtEnd arguments.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96145 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
76dd3c2ff2
Коммит
bb4a61a121
|
@ -1201,7 +1201,7 @@ CXSourceLocation clang_getLocation(CXTranslationUnit tu,
|
|||
static_cast<const FileEntry *>(file),
|
||||
line, column);
|
||||
|
||||
return cxloc::translateSourceLocation(CXXUnit->getASTContext(), SLoc, false);
|
||||
return cxloc::translateSourceLocation(CXXUnit->getASTContext(), SLoc);
|
||||
}
|
||||
|
||||
CXSourceRange clang_getNullRange() {
|
||||
|
@ -1224,11 +1224,9 @@ void clang_getInstantiationLocation(CXSourceLocation location,
|
|||
unsigned *line,
|
||||
unsigned *column,
|
||||
unsigned *offset) {
|
||||
cxloc::CXSourceLocationPtr Ptr
|
||||
= cxloc::CXSourceLocationPtr::getFromOpaqueValue(location.ptr_data[0]);
|
||||
SourceLocation Loc = SourceLocation::getFromRawEncoding(location.int_data);
|
||||
|
||||
if (!Ptr.getPointer() || Loc.isInvalid()) {
|
||||
if (!location.ptr_data[0] || Loc.isInvalid()) {
|
||||
if (file)
|
||||
*file = 0;
|
||||
if (line)
|
||||
|
@ -1240,7 +1238,8 @@ void clang_getInstantiationLocation(CXSourceLocation location,
|
|||
return;
|
||||
}
|
||||
|
||||
const SourceManager &SM = *Ptr.getPointer();
|
||||
const SourceManager &SM =
|
||||
*static_cast<const SourceManager*>(location.ptr_data[0]);
|
||||
SourceLocation InstLoc = SM.getInstantiationLoc(Loc);
|
||||
|
||||
if (file)
|
||||
|
@ -1260,10 +1259,7 @@ CXSourceLocation clang_getRangeStart(CXSourceRange range) {
|
|||
}
|
||||
|
||||
CXSourceLocation clang_getRangeEnd(CXSourceRange range) {
|
||||
cxloc::CXSourceLocationPtr Ptr;
|
||||
Ptr.setPointer(static_cast<SourceManager *>(range.ptr_data[0]));
|
||||
Ptr.setInt(true);
|
||||
CXSourceLocation Result = { { Ptr.getOpaqueValue(), range.ptr_data[1] },
|
||||
CXSourceLocation Result = { { range.ptr_data[0], range.ptr_data[1] },
|
||||
range.end_int_data };
|
||||
return Result;
|
||||
}
|
||||
|
|
|
@ -25,27 +25,22 @@ namespace clang {
|
|||
class ASTContext;
|
||||
|
||||
namespace cxloc {
|
||||
|
||||
typedef llvm::PointerIntPair<const SourceManager *, 1, bool>
|
||||
CXSourceLocationPtr;
|
||||
|
||||
/// \brief Translate a Clang source location into a CIndex source location.
|
||||
static inline CXSourceLocation
|
||||
translateSourceLocation(const SourceManager &SM, const LangOptions &LangOpts,
|
||||
SourceLocation Loc, bool AtEnd = false) {
|
||||
CXSourceLocationPtr Ptr(&SM, AtEnd);
|
||||
CXSourceLocation Result = { { Ptr.getOpaqueValue(), (void *)&LangOpts, },
|
||||
SourceLocation Loc) {
|
||||
CXSourceLocation Result = { { (void*) &SM, (void*) &LangOpts, },
|
||||
Loc.getRawEncoding() };
|
||||
return Result;
|
||||
}
|
||||
|
||||
/// \brief Translate a Clang source location into a CIndex source location.
|
||||
static inline CXSourceLocation translateSourceLocation(ASTContext &Context,
|
||||
SourceLocation Loc,
|
||||
bool AtEnd = false) {
|
||||
return translateSourceLocation(Context.getSourceManager(),
|
||||
SourceLocation Loc) {
|
||||
return translateSourceLocation(Context.getSourceManager(),
|
||||
Context.getLangOptions(),
|
||||
Loc, AtEnd);
|
||||
Loc);
|
||||
}
|
||||
|
||||
/// \brief Translate a Clang source range into a CIndex source range.
|
||||
|
|
Загрузка…
Ссылка в новой задаче