zcov: / lib/Basic/SourceLocation.cpp


Files: 1 Branches Taken: 34.6% 9 / 26
Generated: 2010-02-10 01:31 Branches Executed: 61.5% 16 / 26
Line Coverage: 55.4% 31 / 56


Programs: 2 Runs 3018


       1                 : //==--- SourceLocation.cpp - Compact identifier for Source Files -*- C++ -*-==//
       2                 : //
       3                 : //                     The LLVM Compiler Infrastructure
       4                 : //
       5                 : // This file is distributed under the University of Illinois Open Source
       6                 : // License. See LICENSE.TXT for details.
       7                 : //
       8                 : //===----------------------------------------------------------------------===//
       9                 : //
      10                 : //  This file defines accessor methods for the FullSourceLoc class.
      11                 : //
      12                 : //===----------------------------------------------------------------------===//
      13                 : 
      14                 : #include "clang/Basic/SourceLocation.h"
      15                 : #include "clang/Basic/PrettyStackTrace.h"
      16                 : #include "clang/Basic/SourceManager.h"
      17                 : #include "llvm/Support/MemoryBuffer.h"
      18                 : #include "llvm/Support/raw_ostream.h"
      19                 : #include <cstdio>
      20                 : using namespace clang;
      21                 : 
      22                 : //===----------------------------------------------------------------------===//
      23                 : // PrettyStackTraceLoc
      24                 : //===----------------------------------------------------------------------===//
      25                 : 
      26                0: void PrettyStackTraceLoc::print(llvm::raw_ostream &OS) const {
                        0: branch 1 not taken
                        0: branch 2 not taken
      27                0:   if (Loc.isValid()) {
      28                0:     Loc.print(OS, SM);
      29                0:     OS << ": ";
      30                 :   }
      31                0:   OS << Message << '\n';
      32                0: }
      33                 : 
      34                 : //===----------------------------------------------------------------------===//
      35                 : // SourceLocation
      36                 : //===----------------------------------------------------------------------===//
      37                 : 
      38               39: void SourceLocation::print(llvm::raw_ostream &OS, const SourceManager &SM)const{
                        0: branch 1 not taken
                       39: branch 2 taken
      39               39:   if (!isValid()) {
      40                0:     OS << "<invalid loc>";
      41                0:     return;
      42                 :   }
      43                 : 
                       38: branch 1 taken
                        1: branch 2 taken
      44               39:   if (isFileID()) {
      45               38:     PresumedLoc PLoc = SM.getPresumedLoc(*this);
      46                 :     // The instantiation and spelling pos is identical for file locs.
      47                 :     OS << PLoc.getFilename() << ':' << PLoc.getLine()
      48               38:        << ':' << PLoc.getColumn();
      49               38:     return;
      50                 :   }
      51                 : 
      52                1:   SM.getInstantiationLoc(*this).print(OS, SM);
      53                 : 
      54                1:   OS << " <Spelling=";
      55                1:   SM.getSpellingLoc(*this).print(OS, SM);
      56                1:   OS << '>';
      57                 : }
      58                 : 
      59               37: void SourceLocation::dump(const SourceManager &SM) const {
      60               37:   print(llvm::errs(), SM);
      61               37: }
      62                 : 
      63                 : //===----------------------------------------------------------------------===//
      64                 : // FullSourceLoc
      65                 : //===----------------------------------------------------------------------===//
      66                 : 
      67                0: FileID FullSourceLoc::getFileID() const {
                        0: branch 1 not taken
                        0: branch 2 not taken
      68                0:   assert(isValid());
      69                0:   return SrcMgr->getFileID(*this);
      70                 : }
      71                 : 
      72                 : 
      73             2982: FullSourceLoc FullSourceLoc::getInstantiationLoc() const {
                        0: branch 1 not taken
                     2982: branch 2 taken
      74             2982:   assert(isValid());
      75             2982:   return FullSourceLoc(SrcMgr->getInstantiationLoc(*this), *SrcMgr);
      76                 : }
      77                 : 
      78             4015: FullSourceLoc FullSourceLoc::getSpellingLoc() const {
                        0: branch 1 not taken
                     4015: branch 2 taken
      79             4015:   assert(isValid());
      80             4015:   return FullSourceLoc(SrcMgr->getSpellingLoc(*this), *SrcMgr);
      81                 : }
      82                 : 
      83               89: unsigned FullSourceLoc::getInstantiationLineNumber() const {
                        0: branch 1 not taken
                       89: branch 2 taken
      84               89:   assert(isValid());
      85               89:   return SrcMgr->getInstantiationLineNumber(*this);
      86                 : }
      87                 : 
      88               88: unsigned FullSourceLoc::getInstantiationColumnNumber() const {
                        0: branch 1 not taken
                       88: branch 2 taken
      89               88:   assert(isValid());
      90               88:   return SrcMgr->getInstantiationColumnNumber(*this);
      91                 : }
      92                 : 
      93                0: unsigned FullSourceLoc::getSpellingLineNumber() const {
                        0: branch 1 not taken
                        0: branch 2 not taken
      94                0:   assert(isValid());
      95                0:   return SrcMgr->getSpellingLineNumber(*this);
      96                 : }
      97                 : 
      98                0: unsigned FullSourceLoc::getSpellingColumnNumber() const {
                        0: branch 1 not taken
                        0: branch 2 not taken
      99                0:   assert(isValid());
     100                0:   return SrcMgr->getSpellingColumnNumber(*this);
     101                 : }
     102                 : 
     103             4015: bool FullSourceLoc::isInSystemHeader() const {
                        0: branch 1 not taken
                     4015: branch 2 taken
     104             4015:   assert(isValid());
     105             4015:   return SrcMgr->isInSystemHeader(*this);
     106                 : }
     107                 : 
     108                4: const char *FullSourceLoc::getCharacterData() const {
                        0: branch 1 not taken
                        4: branch 2 taken
     109                4:   assert(isValid());
     110                4:   return SrcMgr->getCharacterData(*this);
     111                 : }
     112                 : 
     113                0: const llvm::MemoryBuffer* FullSourceLoc::getBuffer() const {
                        0: branch 1 not taken
                        0: branch 2 not taken
     114                0:   assert(isValid());
     115                0:   return SrcMgr->getBuffer(SrcMgr->getFileID(*this));
     116                 : }
     117                 : 
     118                0: std::pair<const char*, const char*> FullSourceLoc::getBufferData() const {
     119                0:   const llvm::MemoryBuffer *Buf = getBuffer();
     120                0:   return std::make_pair(Buf->getBufferStart(), Buf->getBufferEnd());
     121                 : }
     122                 : 
     123                0: std::pair<FileID, unsigned> FullSourceLoc::getDecomposedLoc() const {
     124                0:   return SrcMgr->getDecomposedLoc(*this);
     125                 : }

Generated: 2010-02-10 01:31 by zcov