This revision was automatically updated to reflect the committed changes.
Closed by commit rG68a6a28ef835: Fix text range end columns in SARIF to be 
exclusive (authored by jranieri-grammatech).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D65206/new/

https://reviews.llvm.org/D65206

Files:
  clang/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp
  
clang/test/Analysis/diagnostics/Inputs/expected-sarif/sarif-diagnostics-taint-test.c.sarif
  
clang/test/Analysis/diagnostics/Inputs/expected-sarif/sarif-multi-diagnostic-test.c.sarif

Index: clang/test/Analysis/diagnostics/Inputs/expected-sarif/sarif-multi-diagnostic-test.c.sarif
===================================================================
--- clang/test/Analysis/diagnostics/Inputs/expected-sarif/sarif-multi-diagnostic-test.c.sarif
+++ clang/test/Analysis/diagnostics/Inputs/expected-sarif/sarif-multi-diagnostic-test.c.sarif
@@ -64,7 +64,7 @@
                             "fileIndex": 0,
                           },
                           "region": {
-                            "endColumn": 5,
+                            "endColumn": 6,
                             "endLine": 24,
                             "startColumn": 3,
                             "startLine": 24
@@ -83,7 +83,7 @@
                             "fileIndex": 0,
                           },
                           "region": {
-                            "endColumn": 17,
+                            "endColumn": 18,
                             "endLine": 9,
                             "startColumn": 11,
                             "startLine": 9
@@ -103,7 +103,7 @@
                   "fileIndex": 0,
                 },
                 "region": {
-                  "endColumn": 17,
+                  "endColumn": 18,
                   "endLine": 9,
                   "startColumn": 11,
                   "startLine": 9
@@ -134,7 +134,7 @@
                             "fileIndex": 0,
                           },
                           "region": {
-                            "endColumn": 5,
+                            "endColumn": 6,
                             "endLine": 25,
                             "startColumn": 3,
                             "startLine": 25
@@ -153,7 +153,7 @@
                             "fileIndex": 0,
                           },
                           "region": {
-                            "endColumn": 10,
+                            "endColumn": 11,
                             "endLine": 13,
                             "startColumn": 3,
                             "startLine": 13
@@ -172,7 +172,7 @@
                             "fileIndex": 0,
                           },
                           "region": {
-                            "endColumn": 8,
+                            "endColumn": 9,
                             "endLine": 14,
                             "startColumn": 3,
                             "startLine": 14
@@ -192,7 +192,7 @@
                   "fileIndex": 0,
                 },
                 "region": {
-                  "endColumn": 8,
+                  "endColumn": 9,
                   "endLine": 14,
                   "startColumn": 3,
                   "startLine": 14
@@ -223,7 +223,7 @@
                             "fileIndex": 0,
                           },
                           "region": {
-                            "endColumn": 12,
+                            "endColumn": 13,
                             "endLine": 18,
                             "startColumn": 7,
                             "startLine": 18
@@ -243,7 +243,6 @@
                           },
                           "region": {
                             "endColumn": 3,
-                            "endLine": 18,
                             "startColumn": 3,
                             "startLine": 18
                           }
@@ -262,7 +261,6 @@
                           },
                           "region": {
                             "endColumn": 14,
-                            "endLine": 19,
                             "startColumn": 14,
                             "startLine": 19
                           }
@@ -282,7 +280,6 @@
                 },
                 "region": {
                   "endColumn": 14,
-                  "endLine": 19,
                   "startColumn": 14,
                   "startLine": 19
                 }
Index: clang/test/Analysis/diagnostics/Inputs/expected-sarif/sarif-diagnostics-taint-test.c.sarif
===================================================================
--- clang/test/Analysis/diagnostics/Inputs/expected-sarif/sarif-diagnostics-taint-test.c.sarif
+++ clang/test/Analysis/diagnostics/Inputs/expected-sarif/sarif-diagnostics-taint-test.c.sarif
@@ -44,7 +44,7 @@
                             "fileIndex": 0,
                           },
                           "region": {
-                            "endColumn": 5,
+                            "endColumn": 6,
                             "endLine": 13,
                             "startColumn": 3,
                             "startLine": 13
@@ -63,7 +63,7 @@
                             "fileIndex": 0,
                           },
                           "region": {
-                            "endColumn": 17,
+                            "endColumn": 18,
                             "endLine": 9,
                             "startColumn": 11,
                             "startLine": 9
@@ -83,7 +83,7 @@
                   "fileIndex": 0,
                 },
                 "region": {
-                  "endColumn": 17,
+                  "endColumn": 18,
                   "endLine": 9,
                   "startColumn": 11,
                   "startLine": 9
Index: clang/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp
===================================================================
--- clang/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp
+++ clang/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp
@@ -143,11 +143,17 @@
 }
 
 static json::Object createTextRegion(SourceRange R, const SourceManager &SM) {
-  return json::Object{
+  json::Object Region{
       {"startLine", SM.getExpansionLineNumber(R.getBegin())},
-      {"endLine", SM.getExpansionLineNumber(R.getEnd())},
       {"startColumn", SM.getExpansionColumnNumber(R.getBegin())},
-      {"endColumn", SM.getExpansionColumnNumber(R.getEnd())}};
+  };
+  if (R.getBegin() == R.getEnd()) {
+    Region["endColumn"] = SM.getExpansionColumnNumber(R.getBegin());
+  } else {
+    Region["endLine"] = SM.getExpansionLineNumber(R.getEnd());
+    Region["endColumn"] = SM.getExpansionColumnNumber(R.getEnd()) + 1;
+  }
+  return Region;
 }
 
 static json::Object createPhysicalLocation(SourceRange R, const FileEntry &FE,
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to