]> granicus.if.org Git - clang/commitdiff
rearrange SourceManager methods to group them by kind. Remove the
authorChris Lattner <sabre@nondot.org>
Mon, 19 Jan 2009 08:02:45 +0000 (08:02 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 19 Jan 2009 08:02:45 +0000 (08:02 +0000)
SourceManager::getFileCharacteristic(FileID) method: we need a
full location to know if it is a system header etc in the future.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62503 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/SourceManager.h

index 202a7c55aaca75562e29e0aba2cce85c3c5e5a92..c8362d890e5709a97990c937885a7626ef701806 100644 (file)
@@ -47,7 +47,7 @@ namespace SrcMgr {
   };
   
   /// ContentCache - Once instance of this struct is kept for every file
-  ///  loaded or used.  This object owns the MemoryBuffer object.
+  /// loaded or used.  This object owns the MemoryBuffer object.
   class ContentCache {
     /// Buffer - The actual buffer containing the characters from the input
     /// file.  This is owned by the ContentCache object.
@@ -278,10 +278,26 @@ public:
     LastLineNoFileIDQuery = FileID();
     LastLineNoContentCache = 0;
   }
-  
+
+  //===--------------------------------------------------------------------===//
+  // MainFileID creation and querying methods.
+  //===--------------------------------------------------------------------===//
+
   /// getMainFileID - Returns the FileID of the main source file.
   FileID getMainFileID() const { return MainFileID; }
   
+  /// createMainFileID - Create the FileID for the main source file.
+  FileID createMainFileID(const FileEntry *SourceFile,
+                          SourceLocation IncludePos) {
+    assert(MainFileID.isInvalid() && "MainFileID already set!");
+    MainFileID = createFileID(SourceFile, IncludePos, SrcMgr::C_User);
+    return MainFileID;
+  }
+  
+  //===--------------------------------------------------------------------===//
+  // Methods to create new FileID's.
+  //===--------------------------------------------------------------------===//
+  
   /// createFileID - Create a new FileID that represents the specified file
   /// being #included from the specified IncludePosition.  This returns 0 on
   /// error and translates NULL into standard input.
@@ -292,14 +308,6 @@ public:
     return createFileID(IR, IncludePos, FileCharacter);
   }
   
-  /// createMainFileID - Create the FileID for the main source file.
-  FileID createMainFileID(const FileEntry *SourceFile,
-                          SourceLocation IncludePos) {
-    assert(MainFileID.isInvalid() && "MainFileID already set!");
-    MainFileID = createFileID(SourceFile, IncludePos, SrcMgr::C_User);
-    return MainFileID;
-  }
-  
   /// createFileIDForMemBuffer - Create a new FileID that represents the
   /// specified memory buffer.  This does no caching of the buffer and takes
   /// ownership of the MemoryBuffer, so only pass a MemoryBuffer to this once.
@@ -316,6 +324,30 @@ public:
     MainFileID = createFileIDForMemBuffer(Buffer);
     return MainFileID;
   }
+
+  //===--------------------------------------------------------------------===//
+  // FileID manipulation methods.
+  //===--------------------------------------------------------------------===//
+  
+  /// getBuffer - Return the buffer for the specified FileID.
+  ///
+  const llvm::MemoryBuffer *getBuffer(FileID FID) const {
+    return getContentCache(FID)->getBuffer();
+  }
+  
+  /// getFileEntryForID - Returns the FileEntry record for the provided FileID.
+  const FileEntry *getFileEntryForID(FileID FID) const {
+    return getContentCache(FID)->Entry;
+  }
+  
+  /// getBufferData - Return a pointer to the start and end of the source buffer
+  /// data for the specified FileID.
+  std::pair<const char*, const char*> getBufferData(FileID FID) const;
+  
+  
+  //===--------------------------------------------------------------------===//
+  // SourceLocation manipulation methods.
+  //===--------------------------------------------------------------------===//
   
   /// getLocForStartOfFile - Return the source location corresponding to the
   /// first byte of the specified file.
@@ -328,17 +360,7 @@ public:
   SourceLocation getInstantiationLoc(SourceLocation Loc,
                                      SourceLocation InstantiationLoc);
   
-  /// getBuffer - Return the buffer for the specified FileID.
-  ///
-  const llvm::MemoryBuffer *getBuffer(FileID FID) const {
-    return getContentCache(FID)->getBuffer();
-  }
-  
-  /// getBufferData - Return a pointer to the start and end of the source buffer
-  /// data for the specified FileID.
-  std::pair<const char*, const char*> getBufferData(FileID FID) const;
-  
-  /// getIncludeLoc - Return the location of the #include for the specified
+   /// getIncludeLoc - Return the location of the #include for the specified
   /// SourceLocation.  If this is a macro expansion, this transparently figures
   /// out which file includes the file being expanded into.
   SourceLocation getIncludeLoc(SourceLocation ID) const {
@@ -403,12 +425,6 @@ public:
     return PLoc.getFileLocWithOffset(Loc.getMacroSpellingOffs());
   }
 
-  
-  /// getFileEntryForID - Returns the FileEntry record for the provided FileID.
-  const FileEntry *getFileEntryForID(FileID FID) const {
-    return getContentCache(FID)->Entry;
-  }
-  
   /// getDecomposedFileLoc - Decompose the specified file location into a raw
   /// FileID + Offset pair.  The first element is the FileID, the second is the
   /// offset from the start of the buffer of the location.
@@ -463,9 +479,10 @@ public:
     return getFIDInfo(getSpellingLoc(Loc).getChunkID())
                   ->getFileCharacteristic();
   }
-  SrcMgr::CharacteristicKind getFileCharacteristic(FileID FID) const {
-    return getFIDInfo(FID)->getFileCharacteristic();
-  }
+  
+  //===--------------------------------------------------------------------===//
+  // Other miscellaneous methods.
+  //===--------------------------------------------------------------------===//
   
   // Iterators over FileInfos.
   typedef std::set<SrcMgr::ContentCache>::const_iterator fileinfo_iterator;