Changeset f980549 for src/Common


Ignore:
Timestamp:
Sep 20, 2017, 12:24:45 PM (8 years ago)
Author:
Thierry Delisle <tdelisle@…>
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, resolv-new, with_gc
Children:
b18830e
Parents:
764e009 (diff), 47b5b63 (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 plg.uwaterloo.ca:software/cfa/cfa-cc

Location:
src/Common
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • src/Common/CodeLocation.h

    r764e009 rf980549  
    1616#pragma once
    1717
     18#include <iostream>
    1819#include <string>
    1920
    2021struct CodeLocation {
    21         int linenumber;
    22         std::string filename;
     22        int first_line = -1, first_column = -1, last_line = -1, last_column = -1;
     23        std::string filename = "";
    2324
    2425        /// Create a new unset CodeLocation.
    25                 CodeLocation()
    26                 : linenumber( -1 )
    27                 , filename("")
    28         {}
     26        CodeLocation() = default;
    2927
    3028        /// Create a new CodeLocation with the given values.
    3129        CodeLocation( const char* filename, int lineno )
    32                 : linenumber( lineno )
     30                : first_line( lineno )
    3331                , filename(filename ? filename : "")
    3432        {}
     
    3735
    3836        bool isSet () const {
    39                 return -1 != linenumber;
     37                return -1 != first_line;
    4038        }
    4139
     
    4442        }
    4543
    46         void unset () {
    47                 linenumber = -1;
    48                 filename = "";
    49         }
    50 
    51         // Use field access for set.
    52 
    5344        bool followedBy( CodeLocation const & other, int seperation ) {
    54                 return (linenumber + seperation == other.linenumber &&
     45                return (first_line + seperation == other.first_line &&
    5546                        filename == other.filename);
    5647        }
     
    6556};
    6657
    67 inline std::string to_string( const CodeLocation& location ) {
    68     // Column number ":1" allows IDEs to parse the error message and position the cursor in the source text.
    69     return location.isSet() ? location.filename + ":" + std::to_string(location.linenumber) + ":1 " : "";
     58inline std::ostream & operator<<( std::ostream & out, const CodeLocation & location ) {
     59        // Column number ":1" allows IDEs to parse the error message and position the cursor in the source text.
     60        return location.isSet() ? out << location.filename << ":" << location.first_line << ":1 " : out;
    7061}
    71 
  • src/Common/PassVisitor.h

    r764e009 rf980549  
    133133        virtual void visit( OneType *oneType ) override final;
    134134
     135        virtual void visit( Designation *designation ) override final;
    135136        virtual void visit( SingleInit *singleInit ) override final;
    136137        virtual void visit( ListInit *listInit ) override final;
     
    221222        virtual Type* mutate( OneType *oneType ) override final;
    222223
     224        virtual Designation* mutate( Designation *designation ) override final;
    223225        virtual Initializer* mutate( SingleInit *singleInit ) override final;
    224226        virtual Initializer* mutate( ListInit *listInit ) override final;
  • src/Common/PassVisitor.impl.h

    r764e009 rf980549  
    19261926}
    19271927
     1928template< typename pass_type >
     1929void PassVisitor< pass_type >::visit( Designation * node ) {
     1930        VISIT_START( node );
     1931
     1932        maybeAccept( node->get_designators(), *this );
     1933
     1934        VISIT_END( node );
     1935}
     1936
     1937template< typename pass_type >
     1938Designation * PassVisitor< pass_type >::mutate( Designation * node ) {
     1939        MUTATE_START( node );
     1940
     1941        maybeMutateRef( node->get_designators(), *this );
     1942
     1943        MUTATE_END( Designation, node );
     1944}
     1945
    19281946//--------------------------------------------------------------------------
    19291947// SingleInit
  • src/Common/SemanticError.cc

    r764e009 rf980549  
    4545        using std::to_string;
    4646        for( auto err : errors ) {
    47                 os << to_string( err.location ) << err.description << std::endl;
     47                os << err.location << err.description << std::endl;
    4848        }
    4949}
  • src/Common/SemanticError.h

    r764e009 rf980549  
    3232
    3333        void maybeSet( const CodeLocation & location ) {
    34                 if( this->location.linenumber < 0 ) {
     34                if( this->location.isUnset() ) {
    3535                        this->location = location;
    3636                }
Note: See TracChangeset for help on using the changeset viewer.