[cfe-commits] r96145 - in /cfe/trunk/tools/CIndex: CIndex.cpp CXSourceLocation.h

Daniel Dunbar daniel at zuster.org
Sat Feb 13 17:47:37 PST 2010


Author: ddunbar
Date: Sat Feb 13 19:47:36 2010
New Revision: 96145

URL: http://llvm.org/viewvc/llvm-project?rev=96145&view=rev
Log:
CIndex: Kill off CXSourceLocationPtr, and AtEnd arguments.

Modified:
    cfe/trunk/tools/CIndex/CIndex.cpp
    cfe/trunk/tools/CIndex/CXSourceLocation.h

Modified: cfe/trunk/tools/CIndex/CIndex.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/CIndex/CIndex.cpp?rev=96145&r1=96144&r2=96145&view=diff

==============================================================================
--- cfe/trunk/tools/CIndex/CIndex.cpp (original)
+++ cfe/trunk/tools/CIndex/CIndex.cpp Sat Feb 13 19:47:36 2010
@@ -1201,7 +1201,7 @@
                                         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 @@
                                     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 @@
     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_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;
 }

Modified: cfe/trunk/tools/CIndex/CXSourceLocation.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/CIndex/CXSourceLocation.h?rev=96145&r1=96144&r2=96145&view=diff

==============================================================================
--- cfe/trunk/tools/CIndex/CXSourceLocation.h (original)
+++ cfe/trunk/tools/CIndex/CXSourceLocation.h Sat Feb 13 19:47:36 2010
@@ -25,27 +25,22 @@
 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.





More information about the cfe-commits mailing list