LCOV - code coverage report
Current view: top level - gcc/rust/util - rust-attributes.h (source / functions) Coverage Total Hit
Test: gcc.info Lines: 100.0 % 7 7
Test Date: 2026-04-20 14:57:17 Functions: 100.0 % 1 1
Legend: Lines:     hit not hit

            Line data    Source code
       1              : // Copyright (C) 2020-2026 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              : #ifndef RUST_ATTRIBUTES_H
      19              : #define RUST_ATTRIBUTES_H
      20              : 
      21              : #include "rust-ast.h"
      22              : #include "optional.h"
      23              : 
      24              : namespace Rust {
      25              : namespace Analysis {
      26              : 
      27              : class Attributes
      28              : {
      29              : public:
      30              :   static bool is_known (const std::string &attribute_path);
      31              :   static bool valid_outer_attribute (const std::string &attribute_path);
      32              :   static tl::optional<std::string>
      33              :   extract_string_literal (const AST::Attribute &attr);
      34              : };
      35              : 
      36              : enum CompilerPass
      37              : {
      38              :   UNKNOWN,
      39              : 
      40              :   EXPANSION,
      41              :   NAME_RESOLUTION,
      42              :   HIR_LOWERING,
      43              :   TYPE_CHECK,
      44              :   STATIC_ANALYSIS,
      45              :   CODE_GENERATION,
      46              : 
      47              :   // External Rust tooling attributes, like #[rustfmt::skip]
      48              :   EXTERNAL,
      49              : 
      50              :   // Do we need to add something here for const fns?
      51              : };
      52              : 
      53       344919 : struct BuiltinAttrDefinition
      54              : {
      55              :   std::string name;
      56              :   CompilerPass handler;
      57              : 
      58            1 :   static BuiltinAttrDefinition get_error ()
      59              :   {
      60            1 :     return BuiltinAttrDefinition{"", UNKNOWN};
      61              :   }
      62              : 
      63            2 :   static BuiltinAttrDefinition &error_node ()
      64              :   {
      65            3 :     static BuiltinAttrDefinition error_node = get_error ();
      66            2 :     return error_node;
      67              :   }
      68              : 
      69       116284 :   bool is_error () const { return name.empty (); }
      70              : };
      71              : 
      72              : class BuiltinAttributeMappings
      73              : {
      74              : public:
      75              :   static BuiltinAttributeMappings *get ();
      76              : 
      77              :   const BuiltinAttrDefinition &
      78              :   lookup_builtin (const std::string &attr_name) const;
      79              : 
      80              : private:
      81              :   BuiltinAttributeMappings ();
      82              : 
      83              :   std::map<std::string, const BuiltinAttrDefinition> mappings;
      84              : };
      85              : 
      86              : tl::optional<BuiltinAttrDefinition>
      87              : lookup_builtin (const AST::Attribute &attribute);
      88              : 
      89              : } // namespace Analysis
      90              : } // namespace Rust
      91              : 
      92              : #endif /* ! RUST_ATTRIBUTES_H */
        

Generated by: LCOV version 2.4-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.