summaryrefslogtreecommitdiffstats
path: root/clang/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp
diff options
context:
space:
mode:
authorJoe Ranieri <jranieri@grammatech.com>2019-08-27 13:49:45 +0000
committerJoe Ranieri <jranieri@grammatech.com>2019-08-27 13:49:45 +0000
commit68a6a28ef835d121b9673e4ca08c38f221d3aee7 (patch)
tree7bea4d7967453eaf25299944b28261e856850cef /clang/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp
parent99178faf59dae4391b0e01289ccf610151628c2e (diff)
downloadbcm5719-llvm-68a6a28ef835d121b9673e4ca08c38f221d3aee7.tar.gz
bcm5719-llvm-68a6a28ef835d121b9673e4ca08c38f221d3aee7.zip
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 llvm-svn: 370060
Diffstat (limited to 'clang/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp')
-rw-r--r--clang/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp b/clang/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp
index f4e85b3fa8f..3b4667765c2 100644
--- a/clang/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp
+++ b/clang/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp
@@ -143,11 +143,17 @@ static json::Object createFileLocation(const FileEntry &FE,
}
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,
OpenPOWER on IntegriCloud