[cfe-commits] r62493 - /cfe/trunk/include/clang/Basic/SourceLocation.h

Chris Lattner sabre at nondot.org
Sun Jan 18 23:00:35 PST 2009


Author: lattner
Date: Mon Jan 19 01:00:35 2009
New Revision: 62493

URL: http://llvm.org/viewvc/llvm-project?rev=62493&view=rev
Log:
privatize getChunkID/getMacroID, and move operator< out of the class.


Modified:
    cfe/trunk/include/clang/Basic/SourceLocation.h

Modified: cfe/trunk/include/clang/Basic/SourceLocation.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/SourceLocation.h?rev=62493&r1=62492&r2=62493&view=diff

==============================================================================
--- cfe/trunk/include/clang/Basic/SourceLocation.h (original)
+++ cfe/trunk/include/clang/Basic/SourceLocation.h Mon Jan 19 01:00:35 2009
@@ -101,6 +101,7 @@
   bool isValid() const { return ID != 0; }
   bool isInvalid() const { return ID == 0; }
   
+private:
   /// getChunkID - Return the chunk identifier for this SourceLocation.  This
   /// ChunkID can be used with the SourceManager object to obtain an entire
   /// include stack for a file position reference.
@@ -108,13 +109,12 @@
     assert(isFileID() && "can't get the file id of a non-file sloc!");
     return ID >> FilePosBits;
   }
-  
+
   unsigned getMacroID() const {
     assert(isMacroID() && "Is not a macro id!");
     return (ID >> MacroSpellingOffsBits) & ((1 << MacroIDBits)-1);
   }
   
-private:
   static SourceLocation getFileLoc(unsigned ChunkID, unsigned FilePos) {
     SourceLocation L;
     // If a FilePos is larger than (1<<FilePosBits), the SourceManager makes
@@ -191,10 +191,6 @@
   unsigned getRawEncoding() const { return ID; }
   
   
-  bool operator<(const SourceLocation &RHS) const {
-    return ID < RHS.ID;
-  }
-  
   /// getFromRawEncoding - Turn a raw encoding of a SourceLocation object into
   /// a real SourceLocation.
   static SourceLocation getFromRawEncoding(unsigned Encoding) {
@@ -217,6 +213,10 @@
 inline bool operator!=(const SourceLocation &LHS, const SourceLocation &RHS) {
   return !(LHS == RHS);
 }
+  
+inline bool operator<(const SourceLocation &LHS, const SourceLocation &RHS) {
+  return LHS.getRawEncoding() < RHS.getRawEncoding();
+}
 
 /// SourceRange - a trival tuple used to represent a source range.
 class SourceRange {





More information about the cfe-commits mailing list