Changeset da7fe39 for src/Common


Ignore:
Timestamp:
Apr 23, 2018, 12:57:46 PM (8 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, with_gc
Children:
57acae0
Parents:
ba89e9b7 (diff), c8ad5d9 (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 references

Location:
src/Common
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • src/Common/Debug.h

    rba89e9b7 rda7fe39  
    3737
    3838                std::cerr << "======" << label << "======" << std::endl;
    39                 CodeGen::generate( decls, std::cerr, true, true );
     39                CodeGen::generate(
     40                        decls,
     41                        std::cerr,
     42                        true /* doIntrinsics */,
     43                        true /* pretty */,
     44                        false /* generateC */,
     45                        false /* lineMarks */,
     46                        true /* printTypeExpr */
     47                );
    4048        #endif
    4149        } // dump
  • src/Common/PassVisitor.h

    rba89e9b7 rda7fe39  
    9292        virtual void visit( NameExpr * nameExpr ) override final;
    9393        virtual void visit( CastExpr * castExpr ) override final;
     94        virtual void visit( KeywordCastExpr * castExpr ) override final;
    9495        virtual void visit( VirtualCastExpr * castExpr ) override final;
    9596        virtual void visit( AddressExpr * addressExpr ) override final;
     
    187188        virtual Expression * mutate( UntypedExpr * untypedExpr ) override final;
    188189        virtual Expression * mutate( NameExpr * nameExpr ) override final;
    189         virtual Expression * mutate( AddressExpr * castExpr ) override final;
     190        virtual Expression * mutate( AddressExpr * addrExpr ) override final;
    190191        virtual Expression * mutate( LabelAddressExpr * labAddressExpr ) override final;
    191192        virtual Expression * mutate( CastExpr * castExpr ) override final;
     193        virtual Expression * mutate( KeywordCastExpr * castExpr ) override final;
    192194        virtual Expression * mutate( VirtualCastExpr * castExpr ) override final;
    193195        virtual Expression * mutate( UntypedMemberExpr * memberExpr ) override final;
  • src/Common/PassVisitor.impl.h

    rba89e9b7 rda7fe39  
    12591259
    12601260//--------------------------------------------------------------------------
     1261// KeywordCastExpr
     1262template< typename pass_type >
     1263void PassVisitor< pass_type >::visit( KeywordCastExpr * node ) {
     1264        VISIT_START( node );
     1265
     1266        indexerScopedAccept( node->result, *this );
     1267        maybeAccept_impl        ( node->arg   , *this );
     1268
     1269        VISIT_END( node );
     1270}
     1271
     1272template< typename pass_type >
     1273Expression * PassVisitor< pass_type >::mutate( KeywordCastExpr * node ) {
     1274        MUTATE_START( node );
     1275
     1276        indexerScopedMutate( node->env   , *this );
     1277        indexerScopedMutate( node->result, *this );
     1278        maybeMutate_impl   ( node->arg   , *this );
     1279
     1280        MUTATE_END( Expression, node );
     1281}
     1282
     1283//--------------------------------------------------------------------------
    12611284// VirtualCastExpr
    12621285template< typename pass_type >
  • src/Common/SemanticError.cc

    rba89e9b7 rda7fe39  
    6868}
    6969
    70 void SemanticWarningImpl( CodeLocation location, Warning, const char * const fmt, ... ) {
    71         va_list args;
    72         va_start(args, fmt);
    73         std::string msg = fmtToString( fmt, args );
    74         va_end(args);
    75         std::cerr << ErrorHelpers::bold() << location << ErrorHelpers::warning_str() << ErrorHelpers::reset_font() << msg << std::endl;
     70void SemanticWarningImpl( CodeLocation location, Warning warning, const char * const fmt, ... ) {
     71        Severity severity = WarningFormats[(int)warning].severity;
     72        switch(severity) {
     73        case Severity::Suppress :
     74                break;
     75        case Severity::Warn :
     76                {
     77                        va_list args;
     78                        va_start(args, fmt);
     79                        std::string msg = fmtToString( fmt, args );
     80                        va_end(args);
     81                        std::cerr << ErrorHelpers::bold() << location << ErrorHelpers::warning_str() << ErrorHelpers::reset_font() << msg << std::endl;
     82                }
     83                break;
     84        case Severity::Error :
     85                {
     86                        va_list args;
     87                        va_start(args, fmt);
     88                        std::string msg = fmtToString( fmt, args );
     89                        va_end(args);
     90                        SemanticError(location, msg);
     91                }
     92                break;
     93        case Severity::Critical :
     94                assertf(false, "Critical errors not implemented yet");
     95                break;
     96        }
    7697}
    7798
  • src/Common/SemanticError.h

    rba89e9b7 rda7fe39  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Aug 29 22:03:36 2017
    13 // Update Count     : 17
     12// Last Modified On : Thu Apr 19 17:52:03 2018
     13// Update Count     : 19
    1414//
    1515
     
    3636// Warnings
    3737
    38 constexpr const char * const WarningFormats[] = {
    39         "self assignment of expression: %s",
    40         "rvalue to reference conversion of rvalue: %s",
     38enum class Severity {
     39        Suppress,
     40        Warn,
     41        Error,
     42        Critical
     43};
     44
     45struct WarningData {
     46        const char * const name;
     47        const char * const message;
     48        mutable Severity severity;
     49};
     50
     51constexpr const WarningData WarningFormats[] = {
     52        {"self-assign"         , "self assignment of expression: %s"           , Severity::Warn},
     53        {"reference-conversion", "rvalue to reference conversion of rvalue: %s", Severity::Warn},
     54        {"qualifiers-zero_t-one_t", "questionable use of type qualifier %s with %s", Severity::Warn},
    4155};
    4256
     
    4458        SelfAssignment,
    4559        RvalueToReferenceConversion,
     60        BadQualifiersZeroOne,
    4661        NUMBER_OF_WARNINGS, //This MUST be the last warning
    4762};
     
    5267);
    5368
    54 // ## used here to allow empty __VA_ARGS__
    55 #define SemanticWarning(loc, id, ...) SemanticWarningImpl(loc, id, WarningFormats[(int)id], ## __VA_ARGS__)
     69#define SemanticWarning(loc, id, ...) SemanticWarningImpl(loc, id, WarningFormats[(int)id].message, __VA_ARGS__)
    5670
    5771void SemanticWarningImpl (CodeLocation loc, Warning warn, const char * const fmt, ...) __attribute__((format(printf, 3, 4)));
  • src/Common/utility.h

    rba89e9b7 rda7fe39  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Thr Aug 17 11:38:00 2017
    13 // Update Count     : 34
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Fri Apr 20 22:35:33 2018
     13// Update Count     : 38
    1414//
    1515
     
    436436}
    437437
     438// -----------------------------------------------------------------------------
     439// O(1) polymorphic integer ilog2, using clz, which returns the number of leading 0-bits, starting at the most
     440// significant bit (single instruction on x86)
     441
     442template<typename T>
     443inline constexpr T ilog2(const T & t) {
     444        if ( std::is_integral<T>::value ) {
     445                const constexpr int r = sizeof(t) * __CHAR_BIT__ - 1;
     446                if ( sizeof(T) == sizeof(unsigned int ) ) return r - __builtin_clz( t );
     447                if ( sizeof(T) == sizeof(unsigned long) ) return r - __builtin_clzl( t );
     448                if ( sizeof(T) == sizeof(unsigned long long) ) return r - __builtin_clzll( t );
     449        } // if
     450        return -1;
     451} // ilong2
    438452
    439453
Note: See TracChangeset for help on using the changeset viewer.