c2c/Clang/SourceManager.cpp
/// getCharacterData - Return a pointer to the start of the specified location
/// in the appropriate MemoryBuffer.
Return a pointer to the start of the specified location
in the appropriate MemoryBuffer.
Return a pointer to the start of the specified location in the appropriate MemoryBuffer .
const char *SourceManager::getCharacterData(SourceLocation SL,
                                            bool *Invalid) const {
  std::pair<FileID, unsigned> LocInfo = getDecomposedSpellingLoc(SL);
  bool CharDataInvalid = false;
  const SLocEntry &Entry = getSLocEntry(LocInfo.first, &CharDataInvalid);
  if (CharDataInvalid || !Entry.isFile()) {
    if (Invalid)
      *Invalid = true;
    return "<<<<INVALID BUFFER>>>>";
  }
  llvm::MemoryBuffer *Buffer = Entry.getFile().getContentCache()->getBuffer(
      Diag, *this, SourceLocation(), &CharDataInvalid);
  if (Invalid)
    *Invalid = CharDataInvalid;
  return Buffer->getBufferStart() + (CharDataInvalid? 0 : LocInfo.second);
}
const char * SourceManager :: getCharacterData ( SourceLocation SL , bool * Invalid ) const { std :: pair < FileID , unsigned > LocInfo = getDecomposedSpellingLoc ( SL ) ; bool CharDataInvalid = false ; const SLocEntry & Entry = getSLocEntry ( LocInfo . first , & CharDataInvalid ) ; if ( CharDataInvalid || ! Entry . isFile ( ) ) { if ( Invalid ) * Invalid = true ; return " " ; } llvm :: MemoryBuffer * Buffer = Entry . getFile ( ) . getContentCache ( ) -> getBuffer ( Diag , * this , SourceLocation ( ) , & CharDataInvalid ) ; if ( Invalid ) * Invalid = CharDataInvalid ; return Buffer -> getBufferStart ( ) + ( CharDataInvalid ? 0 : LocInfo . second ) ; }
getCharacterData - Return a pointer to the start of the specified location
in the appropriate MemoryBuffer.
getCharacterData - Return a pointer to the start of the specified location in the appropriate MemoryBuffer .
// Note that this is a hot function in the getSpelling() path, which is // heavily used by -E mode. // Note that calling 'getBuffer()' may lazily page in a source file.