Changeset 80ac42d


Ignore:
Timestamp:
Sep 18, 2017, 4:56:22 PM (4 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, deferred_resn, demangler, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, resolv-new, with_gc
Children:
4e8949f
Parents:
698ec72
Message:

Begin to clean up CodeLocations?

Location:
src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/CodeTools/TrackLoc.cc

    r698ec72 r80ac42d  
    3333
    3434namespace CodeTools {
    35 
    36         std::ostream & operator<<(std::ostream & out, CodeLocation const & loc) {
    37                 return out << loc.filename << '[' << loc.linenumber << ']';
    38         }
    39 
    4035        class LocationPrinter {
    4136                size_t printLevel;
     
    9590                acceptAll( translationUnit, printer );
    9691        }
    97 
    9892} // namespace CodeTools
    9993
  • src/Common/CodeLocation.h

    r698ec72 r80ac42d  
    1616#pragma once
    1717
     18#include <iostream>
    1819#include <string>
    1920
     
    4445        }
    4546
    46         void unset () {
    47                 linenumber = -1;
    48                 filename = "";
    49         }
    50 
    51         // Use field access for set.
    52 
    5347        bool followedBy( CodeLocation const & other, int seperation ) {
    5448                return (linenumber + seperation == other.linenumber &&
     
    6559};
    6660
    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 " : "";
     61inline std::ostream & operator<<( std::ostream & out, const CodeLocation & location ) {
     62        // Column number ":1" allows IDEs to parse the error message and position the cursor in the source text.
     63        return location.isSet() ? out << location.filename << ":" << location.linenumber << ":1 " : out;
    7064}
    71 
  • src/Common/SemanticError.cc

    r698ec72 r80ac42d  
    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}
Note: See TracChangeset for help on using the changeset viewer.