r370060 - Fix text range end columns in SARIF to be exclusive
Joe Ranieri via cfe-commits
cfe-commits at lists.llvm.org
Tue Aug 27 06:49:45 PDT 2019
Author: jranieri
Date: Tue Aug 27 06:49:45 2019
New Revision: 370060
URL: http://llvm.org/viewvc/llvm-project?rev=370060&view=rev
Log:
Fix text range end columns in SARIF to be exclusive
According to the SARIF specification, "a text region does not include the character specified by endColumn".
Differential Revision: https://reviews.llvm.org/D65206
Modified:
cfe/trunk/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp
cfe/trunk/test/Analysis/diagnostics/Inputs/expected-sarif/sarif-diagnostics-taint-test.c.sarif
cfe/trunk/test/Analysis/diagnostics/Inputs/expected-sarif/sarif-multi-diagnostic-test.c.sarif
Modified: cfe/trunk/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp?rev=370060&r1=370059&r2=370060&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp Tue Aug 27 06:49:45 2019
@@ -143,11 +143,17 @@ static json::Object createFileLocation(c
}
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,
Modified: cfe/trunk/test/Analysis/diagnostics/Inputs/expected-sarif/sarif-diagnostics-taint-test.c.sarif
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/diagnostics/Inputs/expected-sarif/sarif-diagnostics-taint-test.c.sarif?rev=370060&r1=370059&r2=370060&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/diagnostics/Inputs/expected-sarif/sarif-diagnostics-taint-test.c.sarif (original)
+++ cfe/trunk/test/Analysis/diagnostics/Inputs/expected-sarif/sarif-diagnostics-taint-test.c.sarif Tue Aug 27 06:49:45 2019
@@ -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
Modified: cfe/trunk/test/Analysis/diagnostics/Inputs/expected-sarif/sarif-multi-diagnostic-test.c.sarif
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/diagnostics/Inputs/expected-sarif/sarif-multi-diagnostic-test.c.sarif?rev=370060&r1=370059&r2=370060&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/diagnostics/Inputs/expected-sarif/sarif-multi-diagnostic-test.c.sarif (original)
+++ cfe/trunk/test/Analysis/diagnostics/Inputs/expected-sarif/sarif-multi-diagnostic-test.c.sarif Tue Aug 27 06:49:45 2019
@@ -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
}
More information about the cfe-commits
mailing list