LCOV - code coverage report
Current view: top level - gcc/rust/expand - rust-macro-invoc-lexer.h (source / functions) Coverage Total Hit
Test: gcc.info Lines: 76.9 % 13 10
Test Date: 2024-04-13 14:00:49 Functions: 100.0 % 1 1
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: - 0 0

             Branch data     Line data    Source code
       1                 :             : // Copyright (C) 2020-2024 Free Software Foundation, Inc.
       2                 :             : 
       3                 :             : // This file is part of GCC.
       4                 :             : 
       5                 :             : // GCC is free software; you can redistribute it and/or modify it under
       6                 :             : // the terms of the GNU General Public License as published by the Free
       7                 :             : // Software Foundation; either version 3, or (at your option) any later
       8                 :             : // version.
       9                 :             : 
      10                 :             : // GCC is distributed in the hope that it will be useful, but WITHOUT ANY
      11                 :             : // WARRANTY; without even the implied warranty of MERCHANTABILITY or
      12                 :             : // FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
      13                 :             : // for more details.
      14                 :             : 
      15                 :             : // You should have received a copy of the GNU General Public License
      16                 :             : // along with GCC; see the file COPYING3.  If not see
      17                 :             : // <http://www.gnu.org/licenses/>.
      18                 :             : 
      19                 :             : #ifndef RUST_MACRO_INVOC_LEXER_H
      20                 :             : #define RUST_MACRO_INVOC_LEXER_H
      21                 :             : 
      22                 :             : #include "rust-ast.h"
      23                 :             : 
      24                 :             : namespace Rust {
      25                 :         125 : template <class T> class MacroInvocLexerBase
      26                 :             : {
      27                 :             : public:
      28                 :        5535 :   MacroInvocLexerBase (std::vector<T> stream)
      29                 :        5535 :     : offs (0), token_stream (std::move (stream))
      30                 :             :   {}
      31                 :             : 
      32                 :             :   // Advances current token to n + 1 tokens ahead of current position.
      33                 :           0 :   void skip_token (int n) { offs += (n + 1); }
      34                 :             : 
      35                 :             :   // Skips the current token.
      36                 :       89527 :   void skip_token () { skip_token (0); }
      37                 :             : 
      38                 :           0 :   std::string get_filename () const
      39                 :             :   {
      40                 :             :     // FIXME
      41                 :           0 :     rust_unreachable ();
      42                 :             :     return "FIXME";
      43                 :             :   }
      44                 :             : 
      45                 :       20931 :   size_t get_offs () const { return offs; }
      46                 :             : 
      47                 :             : protected:
      48                 :             :   size_t offs;
      49                 :             :   std::vector<T> token_stream;
      50                 :             : };
      51                 :             : 
      52                 :        5535 : class MacroInvocLexer : public MacroInvocLexerBase<std::unique_ptr<AST::Token>>
      53                 :             : {
      54                 :             : public:
      55                 :        5535 :   MacroInvocLexer (std::vector<std::unique_ptr<AST::Token>> stream)
      56                 :        5535 :     : MacroInvocLexerBase (std::move (stream))
      57                 :        5535 :   {}
      58                 :             : 
      59                 :             :   // Returns token n tokens ahead of current position.
      60                 :             :   const_TokenPtr peek_token (int n);
      61                 :             : 
      62                 :             :   // Peeks the current token.
      63                 :      326105 :   const_TokenPtr peek_token () { return peek_token (0); }
      64                 :             : 
      65                 :             :   // Splits the current token into two. Intended for use with nested generics
      66                 :             :   // closes (i.e. T<U<X>> where >> is wrongly lexed as one token). Note that
      67                 :             :   // this will only work with "simple" tokens like punctuation.
      68                 :             :   void split_current_token (TokenId new_left, TokenId new_right);
      69                 :             : 
      70                 :             :   void split_current_token (std::vector<TokenPtr> new_tokens);
      71                 :             : 
      72                 :             :   std::vector<std::unique_ptr<AST::Token>>
      73                 :             :   get_token_slice (size_t start_idx, size_t end_idx) const;
      74                 :             : };
      75                 :             : } // namespace Rust
      76                 :             : 
      77                 :             : #endif // RUST_MACRO_INVOC_LEXER_H
        

Generated by: LCOV version 2.1-beta

LCOV profile is generated on x86_64 machine using following configure options: configure --disable-bootstrap --enable-coverage=opt --enable-languages=c,c++,fortran,go,jit,lto,rust,m2 --enable-host-shared. GCC test suite is run with the built compiler.