@@ -250,44 +250,6 @@ struct multiline_raw_string
250
250
source_position end = {0 , 0 };
251
251
};
252
252
253
- // -----------------------------------------------------------------------
254
- //
255
- // error: represents a user-readable error message
256
- //
257
- // -----------------------------------------------------------------------
258
- //
259
- struct error_entry
260
- {
261
- source_position where;
262
- std::string msg;
263
- bool internal = false ;
264
- bool fallback = false ; // only emit this message if there was nothing better
265
-
266
- error_entry (
267
- source_position w,
268
- std::string_view m,
269
- bool i = false ,
270
- bool f = false
271
- )
272
- : where{w}
273
- , msg{m}
274
- , internal{i}
275
- , fallback{f}
276
- { }
277
-
278
- auto operator ==(error_entry const & that)
279
- -> bool
280
- {
281
- return
282
- where == that.where
283
- && msg == that.msg
284
- ;
285
- }
286
-
287
- auto print (auto & o, std::string const & file) const
288
- -> void;
289
- };
290
-
291
253
292
254
// -----------------------------------------------------------------------
293
255
//
@@ -639,13 +601,18 @@ class cmdline_processor
639
601
std::unordered_map<int , std::string> labels = {
640
602
{ 2 , " Additional dynamic safety checks and contract information" },
641
603
{ 4 , " Support for constrained target environments" },
642
- { 9 , " Other options" }
604
+ { 8 , " Cpp1 file emission options" },
605
+ { 9 , " Cppfront output options" }
643
606
};
644
607
645
- // Define this in the main .cpp to avoid bringing <iostream> into the headers,
646
- // so that we can't accidentally start depending on iostreams in the compiler body
647
- static auto print (std::string_view, int width = 0 )
648
- -> void;
608
+ static auto print (std::string_view s, int width = 0 )
609
+ -> void
610
+ {
611
+ if (width > 0 ) {
612
+ std::cout << std::setw (width) << std::left;
613
+ }
614
+ std::cout << s;
615
+ }
649
616
650
617
public:
651
618
auto process_flags ()
@@ -925,6 +892,77 @@ static cmdline_processor::register_flag cmd_internal_debug(
925
892
[]{ flag_internal_debug = true ; }
926
893
);
927
894
895
+ static auto flag_print_colon_errors = false ;
896
+ static cmdline_processor::register_flag cmd_print_colon_errors (
897
+ 9 ,
898
+ " format-colon-errors" ,
899
+ " Emit ':line:col:' format for messages - lights up some tools" ,
900
+ []{ flag_print_colon_errors = true ; }
901
+ );
902
+
903
+
904
+ // -----------------------------------------------------------------------
905
+ //
906
+ // error: represents a user-readable error message
907
+ //
908
+ // -----------------------------------------------------------------------
909
+ //
910
+ struct error_entry
911
+ {
912
+ source_position where;
913
+ std::string msg;
914
+ bool internal = false ;
915
+ bool fallback = false ; // only emit this message if there was nothing better
916
+
917
+ error_entry (
918
+ source_position w,
919
+ std::string_view m,
920
+ bool i = false ,
921
+ bool f = false
922
+ )
923
+ : where{w}
924
+ , msg{m}
925
+ , internal{i}
926
+ , fallback{f}
927
+ { }
928
+
929
+ auto operator ==(error_entry const & that)
930
+ -> bool
931
+ {
932
+ return
933
+ where == that.where
934
+ && msg == that.msg
935
+ ;
936
+ }
937
+
938
+ auto print (auto & o, std::string const & file) const
939
+ -> void
940
+ {
941
+ o << file ;
942
+ if (where.lineno > 0 ) {
943
+ if (flag_print_colon_errors) {
944
+ o << " :" << (where.lineno );
945
+ if (where.colno >= 0 ) {
946
+ o << " :" << where.colno ;
947
+ }
948
+ }
949
+ else {
950
+ o << " (" << (where.lineno );
951
+ if (where.colno >= 0 ) {
952
+ o << " ," << where.colno ;
953
+ }
954
+ o << " )" ;
955
+ }
956
+ }
957
+ o << " :" ;
958
+ if (internal) {
959
+ o << " internal compiler" ;
960
+ }
961
+ o << " error: " << msg << " \n " ;
962
+ }
963
+
964
+ };
965
+
928
966
929
967
// -----------------------------------------------------------------------
930
968
//
0 commit comments