Changeset f57668a


Ignore:
Timestamp:
May 5, 2017, 3:41:47 PM (4 years ago)
Author:
Andrew Beach <ajbeach@…>
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:
c352893
Parents:
dba6db9
Message:

Foundation for adding line numbers to generated output.

Location:
src
Files:
2 added
1 edited

Legend:

Unmodified
Added
Removed
  • src/Common/utility.h

    rdba6db9 rf57668a  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Dec 14 21:25:25 2016
    13 // Update Count     : 31
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Fri May 5 11:03:00 2017
     13// Update Count     : 32
    1414//
    1515
     
    322322        std::string filename;
    323323
    324         CodeLocation()
     324    /// Create a new unset CodeLocation.
     325        CodeLocation()
    325326                : linenumber( -1 )
    326327                , filename("")
    327328        {}
    328329
     330    /// Create a new CodeLocation with the given values.
    329331        CodeLocation( const char* filename, int lineno )
    330332                : linenumber( lineno )
    331333                , filename(filename ? filename : "")
    332334        {}
     335
     336    bool isSet () const {
     337        return -1 != linenumber;
     338    }
     339
     340    bool isUnset () const {
     341        return !isSet();
     342    }
     343
     344        void unset () {
     345                linenumber = -1;
     346                filename = "";
     347        }
     348
     349        // Use field access for set.
    333350};
    334351
    335352inline std::string to_string( const CodeLocation& location ) {
    336         return location.linenumber >= 0 ? location.filename + ":" + std::to_string(location.linenumber) + " " : "";
     353        return location.isSet() ? location.filename + ":" + std::to_string(location.linenumber) + " " : "";
    337354}
    338355#endif // _UTILITY_H
Note: See TracChangeset for help on using the changeset viewer.