Changeset f980549 for src/Common
- Timestamp:
- Sep 20, 2017, 12:24:45 PM (8 years ago)
- 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. - Location:
- src/Common
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Common/CodeLocation.h
r764e009 rf980549 16 16 #pragma once 17 17 18 #include <iostream> 18 19 #include <string> 19 20 20 21 struct 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 = ""; 23 24 24 25 /// Create a new unset CodeLocation. 25 CodeLocation() 26 : linenumber( -1 ) 27 , filename("") 28 {} 26 CodeLocation() = default; 29 27 30 28 /// Create a new CodeLocation with the given values. 31 29 CodeLocation( const char* filename, int lineno ) 32 : linenumber( lineno )30 : first_line( lineno ) 33 31 , filename(filename ? filename : "") 34 32 {} … … 37 35 38 36 bool isSet () const { 39 return -1 != linenumber;37 return -1 != first_line; 40 38 } 41 39 … … 44 42 } 45 43 46 void unset () {47 linenumber = -1;48 filename = "";49 }50 51 // Use field access for set.52 53 44 bool followedBy( CodeLocation const & other, int seperation ) { 54 return ( linenumber + seperation == other.linenumber&&45 return (first_line + seperation == other.first_line && 55 46 filename == other.filename); 56 47 } … … 65 56 }; 66 57 67 inline std:: string to_string( const CodeLocation& location ) {68 69 return location.isSet() ? location.filename + ":" + std::to_string(location.linenumber) + ":1 " : "";58 inline 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; 70 61 } 71 -
src/Common/PassVisitor.h
r764e009 rf980549 133 133 virtual void visit( OneType *oneType ) override final; 134 134 135 virtual void visit( Designation *designation ) override final; 135 136 virtual void visit( SingleInit *singleInit ) override final; 136 137 virtual void visit( ListInit *listInit ) override final; … … 221 222 virtual Type* mutate( OneType *oneType ) override final; 222 223 224 virtual Designation* mutate( Designation *designation ) override final; 223 225 virtual Initializer* mutate( SingleInit *singleInit ) override final; 224 226 virtual Initializer* mutate( ListInit *listInit ) override final; -
src/Common/PassVisitor.impl.h
r764e009 rf980549 1926 1926 } 1927 1927 1928 template< typename pass_type > 1929 void PassVisitor< pass_type >::visit( Designation * node ) { 1930 VISIT_START( node ); 1931 1932 maybeAccept( node->get_designators(), *this ); 1933 1934 VISIT_END( node ); 1935 } 1936 1937 template< typename pass_type > 1938 Designation * 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 1928 1946 //-------------------------------------------------------------------------- 1929 1947 // SingleInit -
src/Common/SemanticError.cc
r764e009 rf980549 45 45 using std::to_string; 46 46 for( auto err : errors ) { 47 os << to_string( err.location )<< err.description << std::endl;47 os << err.location << err.description << std::endl; 48 48 } 49 49 } -
src/Common/SemanticError.h
r764e009 rf980549 32 32 33 33 void maybeSet( const CodeLocation & location ) { 34 if( this->location. linenumber < 0) {34 if( this->location.isUnset() ) { 35 35 this->location = location; 36 36 }
Note:
See TracChangeset
for help on using the changeset viewer.