Support SARIF JSON diagnostic output with --diagnostics-sarif. (#6017)

This commit is contained in:
Wilson Snyder
2025-05-17 15:46:15 -04:00
committed by GitHub
parent 7a5c223ccf
commit 66667b6172
29 changed files with 797 additions and 84 deletions
+26
View File
@@ -230,6 +230,32 @@ string VString::removeWhitespace(const string& str) {
return result;
}
string VString::trimWhitespace(const string& str) {
string result;
result.reserve(str.size());
string add;
bool newline = false;
for (const char c : str) {
if (newline && std::isspace(c)) continue;
if (c == '\n') {
add = "\n";
newline = true;
continue;
}
if (std::isspace(c)) {
add += c;
continue;
}
if (!add.empty()) {
result += add;
newline = false;
add.clear();
}
result += c;
}
return result;
}
bool VString::isIdentifier(const string& str) {
for (const char c : str) {
if (!isIdentifierChar(c)) return false;