Changeset 3403534 for src/Common


Ignore:
Timestamp:
Sep 4, 2016, 10:34:35 PM (9 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, 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, resolv-new, stuck-waitfor-destruct, with_gc
Children:
f04a8b81
Parents:
28307be (diff), b16898e (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' of plg2:software/cfa/cfa-cc

Location:
src/Common
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/Common/SemanticError.cc

    r28307be r3403534  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // SemanticError.cc -- 
     7// SemanticError.cc --
    88//
    99// Author           : Richard C. Bilson
     
    2626
    2727SemanticError::SemanticError( std::string error ) {
    28         errors.push_back( std::string( "Error: " ) + error );
     28  append( error );
    2929}
    3030
    3131void SemanticError::append( SemanticError &other ) {
    32         errors.splice( errors.end(), other.errors );
     32  errors.splice( errors.end(), other.errors );
     33}
     34
     35void SemanticError::append( const std::string & msg ) {
     36  errors.push_back( std::string( "Error: ") + msg );
    3337}
    3438
  • src/Common/SemanticError.h

    r28307be r3403534  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // SemanticError.h -- 
     7// SemanticError.h --
    88//
    99// Author           : Richard C. Bilson
     
    3131
    3232        void append( SemanticError &other );
     33        void append( const std::string & );
    3334        bool isEmpty() const;
    3435        void print( std::ostream &os );
     
    4243template< typename T >
    4344SemanticError::SemanticError( const std::string &error, const T *obj ) {
    44         std::ostringstream os;
    45         os << "Error: " << error;
    46         obj->print( os );
    47         errors.push_back( os.str() );
     45        append( toString( error, obj ) );
    4846}
     47
    4948
    5049#endif // SEMANTICERROR_H
  • src/Common/utility.h

    r28307be r3403534  
    246246}
    247247
     248// RAII object to regulate "save and restore" behaviour, e.g.
     249// void Foo::bar() {
     250//   ValueGuard<int> guard(var); // var is a member of type Foo
     251//   var = ...;
     252// } // var's original value is restored
     253template< typename T >
     254struct ValueGuard {
     255        T old;
     256        T& ref;
     257
     258        ValueGuard(T& inRef) : old(inRef), ref(inRef) {}
     259        ~ValueGuard() { ref = old; }
     260};
     261
     262template< typename T >
     263struct reverseIterate_t {
     264        T& ref;
     265
     266        reverseIterate_t( T & ref ) : ref(ref) {}
     267
     268        typedef typename T::reverse_iterator iterator;
     269        iterator begin() { return ref.rbegin(); }
     270        iterator end() { return ref.rend(); }
     271};
     272
     273template< typename T >
     274reverseIterate_t< T > reverseIterate( T & ref ) {
     275        return reverseIterate_t< T >( ref );
     276}
     277
    248278#endif // _UTILITY_H
    249279
Note: See TracChangeset for help on using the changeset viewer.