Add column to location logs

This option can be enabled using the new --error-column option to the command line utility.
It can also be enabled programatically.
This commit is contained in:
Antoine 2024-07-20 00:37:58 +02:00 committed by GitHub
parent 52f68dc6b2
commit dc9f6f61ad
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 77 additions and 11 deletions

View file

@ -95,10 +95,14 @@ public:
default: append("UNKNOWN ERROR: "); break;
}
}
void location(const TSourceLoc& loc, bool absolute = false) {
void location(const TSourceLoc& loc, bool absolute = false, bool displayColumn = false) {
const int maxSize = 24;
char locText[maxSize];
snprintf(locText, maxSize, ":%d", loc.line);
if (displayColumn) {
snprintf(locText, maxSize, ":%d:%d", loc.line, loc.column);
} else {
snprintf(locText, maxSize, ":%d", loc.line);
}
if(loc.getFilename() == nullptr && shaderFileName != nullptr && absolute) {
append(std::filesystem::absolute(shaderFileName).string());
@ -119,9 +123,11 @@ public:
append(s);
append("\n");
}
void message(TPrefixType message, const char* s, const TSourceLoc& loc) {
void message(TPrefixType message, const char* s, const TSourceLoc& loc, bool absolute = false,
bool displayColumn = false)
{
prefix(message);
location(loc);
location(loc, absolute, displayColumn);
append(s);
append("\n");
}