Changeset 7030dab for src/Common


Ignore:
Timestamp:
Apr 6, 2020, 4:46:28 PM (4 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
e3bc51c
Parents:
71d6bd8 (diff), 057298e (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' into new-ast

Location:
src/Common
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • src/Common/Debug.h

    r71d6bd8 r7030dab  
    99// Author           : Rob Schluntz
    1010// Created On       : Fri Sep 1 11:09:14 2017
    11 // Last Modified By : Rob Schluntz
    12 // Last Modified On : Fri Sep 1 11:09:36 2017
    13 // Update Count     : 2
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Fri Dec 13 23:39:42 2019
     13// Update Count     : 3
    1414//
    1515
     
    2121
    2222#include "CodeGen/Generate.h"
    23 #include "Parser/LinkageSpec.h"
     23#include "SynTree/LinkageSpec.h"
    2424#include "SynTree/Declaration.h"
    2525
  • src/Common/PassVisitor.h

    r71d6bd8 r7030dab  
    110110        virtual void visit( FinallyStmt * finallyStmt ) override final;
    111111        virtual void visit( const FinallyStmt * finallyStmt ) override final;
     112        virtual void visit( SuspendStmt * suspendStmt ) override final;
     113        virtual void visit( const SuspendStmt * suspendStmt ) override final;
    112114        virtual void visit( WaitForStmt * waitforStmt ) override final;
    113115        virtual void visit( const WaitForStmt * waitforStmt ) override final;
     
    276278        virtual Statement * mutate( CatchStmt * catchStmt ) override final;
    277279        virtual Statement * mutate( FinallyStmt * finallyStmt ) override final;
     280        virtual Statement * mutate( SuspendStmt * suspendStmt ) override final;
    278281        virtual Statement * mutate( WaitForStmt * waitforStmt ) override final;
    279282        virtual Declaration * mutate( WithStmt * withStmt ) override final;
  • src/Common/PassVisitor.impl.h

    r71d6bd8 r7030dab  
    15221522
    15231523//--------------------------------------------------------------------------
     1524// SuspendStmt
     1525template< typename pass_type >
     1526void PassVisitor< pass_type >::visit( SuspendStmt * node ) {
     1527        VISIT_START( node );
     1528
     1529        maybeAccept_impl( node->then  , *this );
     1530
     1531        VISIT_END( node );
     1532}
     1533
     1534template< typename pass_type >
     1535void PassVisitor< pass_type >::visit( const SuspendStmt * node ) {
     1536        VISIT_START( node );
     1537
     1538        maybeAccept_impl( node->then  , *this );
     1539
     1540        VISIT_END( node );
     1541}
     1542
     1543template< typename pass_type >
     1544Statement * PassVisitor< pass_type >::mutate( SuspendStmt * node ) {
     1545        MUTATE_START( node );
     1546
     1547        maybeMutate_impl( node->then  , *this );
     1548
     1549        MUTATE_END( Statement, node );
     1550}
     1551
     1552//--------------------------------------------------------------------------
    15241553// WaitForStmt
    15251554template< typename pass_type >
     
    33023331        VISIT_START( node );
    33033332
    3304         indexerAddStruct( node->name );
     3333        indexerAddUnion( node->name );
    33053334
    33063335        {
     
    33173346        VISIT_START( node );
    33183347
    3319         indexerAddStruct( node->name );
     3348        indexerAddUnion( node->name );
    33203349
    33213350        {
     
    33323361        MUTATE_START( node );
    33333362
    3334         indexerAddStruct( node->name );
     3363        indexerAddUnion( node->name );
    33353364
    33363365        {
  • src/Common/SemanticError.cc

    r71d6bd8 r7030dab  
    149149// Helpers
    150150namespace ErrorHelpers {
     151        Colors colors = Colors::Auto;
     152
     153        static inline bool with_colors() {
     154                return colors == Colors::Auto ? isatty( STDERR_FILENO ) : bool(colors);
     155        }
     156
    151157        const std::string & error_str() {
    152                 static std::string str = isatty( STDERR_FILENO ) ? "\e[31merror:\e[39m " : "error: ";
     158                static std::string str = with_colors() ? "\e[31merror:\e[39m " : "error: ";
    153159                return str;
    154160        }
    155161
    156162        const std::string & warning_str() {
    157                 static std::string str = isatty( STDERR_FILENO ) ? "\e[95mwarning:\e[39m " : "warning: ";
     163                static std::string str = with_colors() ? "\e[95mwarning:\e[39m " : "warning: ";
    158164                return str;
    159165        }
    160166
    161167        const std::string & bold_ttycode() {
    162                 static std::string str = isatty( STDERR_FILENO ) ? "\e[1m" : "";
     168                static std::string str = with_colors() ? "\e[1m" : "";
    163169                return str;
    164170        }
    165171
    166172        const std::string & reset_font_ttycode() {
    167                 static std::string str = isatty( STDERR_FILENO ) ? "\e[0m" : "";
     173                static std::string str = with_colors() ? "\e[0m" : "";
    168174                return str;
    169175        }
  • src/Common/SemanticError.h

    r71d6bd8 r7030dab  
    4949struct WarningData {
    5050        const char * const name;
     51        const Severity default_severity;
    5152        const char * const message;
    52         const Severity default_severity;
    5353};
    5454
    5555constexpr WarningData WarningFormats[] = {
    56         {"self-assign"            , "self assignment of expression: %s"            , Severity::Warn},
    57         {"reference-conversion"   , "rvalue to reference conversion of rvalue: %s" , Severity::Warn},
    58         {"qualifiers-zero_t-one_t", "questionable use of type qualifier %s with %s", Severity::Warn},
    59         {"aggregate-forward-decl" , "forward declaration of nested aggregate: %s"  , Severity::Warn},
    60         {"superfluous-decl"       , "declaration does not allocate storage: %s"    , Severity::Warn},
    61         {"gcc-attributes"         , "invalid attribute: %s"                        , Severity::Warn},
     56        {"self-assign"            , Severity::Warn    , "self assignment of expression: %s"                          },
     57        {"reference-conversion"   , Severity::Warn    , "rvalue to reference conversion of rvalue: %s"               },
     58        {"qualifiers-zero_t-one_t", Severity::Warn    , "questionable use of type qualifier %s with %s"              },
     59        {"aggregate-forward-decl" , Severity::Warn    , "forward declaration of nested aggregate: %s"                },
     60        {"superfluous-decl"       , Severity::Warn    , "declaration does not allocate storage: %s"                  },
     61        {"gcc-attributes"         , Severity::Warn    , "invalid attribute: %s"                                      },
     62        {"c++-like-copy"          , Severity::Warn    , "Constructor from reference is not a valid copy constructor" },
    6263};
    6364
     
    6970        SuperfluousDecl,
    7071        GccAttributes,
     72        CppCopy,
    7173        NUMBER_OF_WARNINGS, // This MUST be the last warning
    7274};
     
    9799// Helpers
    98100namespace ErrorHelpers {
     101        enum class Colors {
     102                Never = false,
     103                Always = true,
     104                Auto,
     105        };
     106
     107        extern Colors colors;
     108
    99109        const std::string & error_str();
    100110        const std::string & warning_str();
  • src/Common/Stats/Time.h

    r71d6bd8 r7030dab  
    99// Author           : Thierry Delisle
    1010// Created On       : Fri Mar 01 15:14:11 2019
    11 // Last Modified By :
     11// Last Modified By : Andrew Beach
    1212// Last Modified On :
    1313// Update Count     :
     
    4141                                f();
    4242                        }
     43
     44                        template<typename ret_t = void, typename func_t, typename... arg_t>
     45                        inline ret_t TimeCall(
     46                                        const char *, func_t func, arg_t&&... arg) {
     47                                return func(std::forward<arg_t>(arg)...);
     48                        }
    4349#               else
    4450                        void StartGlobal();
     
    5965                                func();
    6066                        }
     67
     68                        template<typename ret_t = void, typename func_t, typename... arg_t>
     69                        inline ret_t TimeCall(
     70                                        const char * name, func_t func, arg_t&&... arg) {
     71                                BlockGuard guard(name);
     72                                return func(std::forward<arg_t>(arg)...);
     73                        }
    6174#               endif
    6275        }
  • src/Common/utility.h

    r71d6bd8 r7030dab  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Jul 24 14:28:19 2019
    13 // Update Count     : 41
     12// Last Modified On : Tue Feb 11 13:00:36 2020
     13// Update Count     : 50
    1414//
    1515
     
    2929#include <utility>
    3030#include <vector>
     31#include <cstring>                                                                              // memcmp
    3132
    3233#include "Common/Indenter.h"
     
    264265}
    265266
    266 /// determines if `pref` is a prefix of `str`
    267 static inline bool isPrefix( const std::string & str, const std::string & pref ) {
     267// determines if pref is a prefix of str
     268static inline bool isPrefix( const std::string & str, const std::string & pref, unsigned int start = 0 ) {
    268269        if ( pref.size() > str.size() ) return false;
    269         auto its = std::mismatch( pref.begin(), pref.end(), str.begin() );
    270         return its.first == pref.end();
     270    return 0 == memcmp( str.c_str() + start, pref.c_str(), pref.size() );
     271        // return prefix == full.substr(0, prefix.size()); // for future, requires c++17
    271272}
    272273
Note: See TracChangeset for help on using the changeset viewer.