From bb4a61a121ba1ee91eb5725881d98249704bb0aa Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Sun, 14 Feb 2010 01:47:36 +0000 Subject: [PATCH] CIndex: Kill off CXSourceLocationPtr, and AtEnd arguments. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96145 91177308-0d34-0410-b5e6-96231b3b80d8 --- tools/CIndex/CIndex.cpp | 14 +++++--------- tools/CIndex/CXSourceLocation.h | 15 +++++---------- 2 files changed, 10 insertions(+), 19 deletions(-) diff --git a/tools/CIndex/CIndex.cpp b/tools/CIndex/CIndex.cpp index a8f9caec85..b7f028d8ae 100644 --- a/tools/CIndex/CIndex.cpp +++ b/tools/CIndex/CIndex.cpp @@ -1201,7 +1201,7 @@ CXSourceLocation clang_getLocation(CXTranslationUnit tu, static_cast(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(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(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; } diff --git a/tools/CIndex/CXSourceLocation.h b/tools/CIndex/CXSourceLocation.h index 95b774b24c..1efe4c6ee6 100644 --- a/tools/CIndex/CXSourceLocation.h +++ b/tools/CIndex/CXSourceLocation.h @@ -25,27 +25,22 @@ namespace clang { class ASTContext; namespace cxloc { - -typedef llvm::PointerIntPair - 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. -- 2.40.0