zcov: / include/clang/Lex/PTHLexer.h


Files: 1 Branches Taken: 20.0% 1 / 5
Generated: 2010-02-10 01:31 Branches Executed: 40.0% 2 / 5
Line Coverage: 40.0% 2 / 5


Programs: 4 Runs 6036


       1                 : //===--- PTHLexer.h - Lexer based on Pre-tokenized input --------*- 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 the PTHLexer interface.
      11                 : //
      12                 : //===----------------------------------------------------------------------===//
      13                 : 
      14                 : #ifndef LLVM_CLANG_PTHLEXER_H
      15                 : #define LLVM_CLANG_PTHLEXER_H
      16                 : 
      17                 : #include "clang/Lex/PreprocessorLexer.h"
      18                 : #include <vector>
      19                 : 
      20                 : namespace clang {
      21                 : 
      22                 : class PTHManager;
      23                 : class PTHSpellingSearch;
      24                 : 
      25                 : class PTHLexer : public PreprocessorLexer {
      26                 :   SourceLocation FileStartLoc;
      27                 : 
      28                 :   /// TokBuf - Buffer from PTH file containing raw token data.
      29                 :   const unsigned char* TokBuf;
      30                 : 
      31                 :   /// CurPtr - Pointer into current offset of the token buffer where
      32                 :   ///  the next token will be read.
      33                 :   const unsigned char* CurPtr;
      34                 : 
      35                 :   /// LastHashTokPtr - Pointer into TokBuf of the last processed '#'
      36                 :   ///  token that appears at the start of a line.
      37                 :   const unsigned char* LastHashTokPtr;
      38                 : 
      39                 :   /// PPCond - Pointer to a side table in the PTH file that provides a
      40                 :   ///  a consise summary of the preproccessor conditional block structure.
      41                 :   ///  This is used to perform quick skipping of conditional blocks.
      42                 :   const unsigned char* PPCond;
      43                 : 
      44                 :   /// CurPPCondPtr - Pointer inside PPCond that refers to the next entry
      45                 :   ///  to process when doing quick skipping of preprocessor blocks.
      46                 :   const unsigned char* CurPPCondPtr;
      47                 : 
      48                 :   PTHLexer(const PTHLexer&);  // DO NOT IMPLEMENT
      49                 :   void operator=(const PTHLexer&); // DO NOT IMPLEMENT
      50                 : 
      51                 :   /// ReadToken - Used by PTHLexer to read tokens TokBuf.
      52                 :   void ReadToken(Token& T);
      53                 : 
      54                 :   /// PTHMgr - The PTHManager object that created this PTHLexer.
      55                 :   PTHManager& PTHMgr;
      56                 : 
      57                 :   Token EofToken;
      58                 : 
      59                 : protected:
      60                 :   friend class PTHManager;
      61                 : 
      62                 :   /// Create a PTHLexer for the specified token stream.
      63                 :   PTHLexer(Preprocessor& pp, FileID FID, const unsigned char *D,
      64                 :            const unsigned char* ppcond, PTHManager &PM);
      65                 : public:
      66                 : 
                        4: branch 1 taken
                        0: branch 2 not taken
                        0: branch 5 not taken
                        0: branch 6 not taken
      67                4:   ~PTHLexer() {}
      68                 : 
      69                 :   /// Lex - Return the next token.
      70                 :   void Lex(Token &Tok);
      71                 : 
      72                 :   void getEOF(Token &Tok);
      73                 : 
      74                 :   /// DiscardToEndOfLine - Read the rest of the current preprocessor line as an
      75                 :   /// uninterpreted string.  This switches the lexer out of directive mode.
      76                 :   void DiscardToEndOfLine();
      77                 : 
      78                 :   /// isNextPPTokenLParen - Return 1 if the next unexpanded token will return a
      79                 :   /// tok::l_paren token, 0 if it is something else and 2 if there are no more
      80                 :   /// tokens controlled by this lexer.
      81                0:   unsigned isNextPPTokenLParen() {
      82                 :     // isNextPPTokenLParen is not on the hot path, and all we care about is
      83                 :     // whether or not we are at a token with kind tok::eof or tok::l_paren.
      84                 :     // Just read the first byte from the current token pointer to determine
      85                 :     // its kind.
      86                0:     tok::TokenKind x = (tok::TokenKind)*CurPtr;
                        0: branch 0 not taken
      87                0:     return x == tok::eof ? 2 : x == tok::l_paren;
      88                 :   }
      89                 : 
      90                 :   /// IndirectLex - An indirect call to 'Lex' that can be invoked via
      91                 :   ///  the PreprocessorLexer interface.
      92                2:   void IndirectLex(Token &Result) { Lex(Result); }
      93                 : 
      94                 :   /// getSourceLocation - Return a source location for the token in
      95                 :   /// the current file.
      96                 :   SourceLocation getSourceLocation();
      97                 : 
      98                 :   /// SkipBlock - Used by Preprocessor to skip the current conditional block.
      99                 :   bool SkipBlock();
     100                 : };
     101                 : 
     102                 : }  // end namespace clang
     103                 : 
     104                 : #endif

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