in search of squiggles
Compiler diagnostic location information explained with references to libcpp header and example file.
Responding to a question about how the GCC diagnostic system highlights errors, a participant pointed to documentation within libcpp/include/line-map.h and libcpp/location-example.txt. These resources explain how location_t values encode range information, either directly in their lower bits for simple ranges or via an external lookup table for more complex ones, determining the extent of compiler-generated squiggles.
- proposer
Provided pointers to existing documentation for understanding diagnostic location information and squiggle generation.
“There's a good amount of explanation in the comments at the top of libcpp/include/line-map.h and also in the example file libcpp/location-example.txt.”
In Details
This exchange clarifies the mechanism for generating source code squiggles in GCC diagnostics. The core data structure is location_t, which stores positional information. The discussion focuses on how location_t encodes both line/column details and, for simple cases, the end of the highlighted range. More complex ranges use external tables, indicated by a flag in location_t.
- libcpp
- The C preprocessor library used by GCC. It handles preprocessor directives, macro expansion, and source file inclusion.
- location_t
- A data type used by GCC to represent source code locations, including file, line, column, and potentially range information for diagnostics.