[analyzer] Allow checker writes to specify that no region should be accosiated with the report. (Useful when we report an error on endOfPath or deadSymbols, when the range of the last expression might have nothing to do with the error.)

llvm-svn: 138474
This commit is contained in:
Anna Zaks 2011-08-24 20:31:06 +00:00
parent 0902a68f69
commit 45aa208554
2 changed files with 9 additions and 1 deletions

View File

@ -138,8 +138,12 @@ public:
///
/// Ranges are used to highlight regions of interest in the source code.
/// They should be at the same source code line as the BugReport location.
/// By default, the source range of the statement corresponding to the error
/// node will be used; add a single invalid range to specify absence of
/// ranges.
void addRange(SourceRange R) {
assert(R.isValid());
assert((R.isValid() || Ranges.empty()) && "Invalid range can only be used "
"to specify that the report does not have a range.");
Ranges.push_back(R);
}

View File

@ -1273,6 +1273,10 @@ BugReport::getRanges() {
return std::make_pair(ranges_iterator(), ranges_iterator());
}
// User-specified absence of range info.
if (Ranges.size() == 1 && !Ranges.begin()->isValid())
return std::make_pair(ranges_iterator(), ranges_iterator());
return std::make_pair(Ranges.begin(), Ranges.end());
}