summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorAnna Zaks <ganna@apple.com>2011-08-24 20:31:06 +0000
committerAnna Zaks <ganna@apple.com>2011-08-24 20:31:06 +0000
commit45aa2085548898a76d99df6a1c78be247d232c3f (patch)
treec8a3e890f078902ef92e713293b9c8999a9ce673 /clang
parent0902a68f69d141a9877246c027d232f323e5b74e (diff)
downloadbcm5719-llvm-45aa2085548898a76d99df6a1c78be247d232c3f.tar.gz
bcm5719-llvm-45aa2085548898a76d99df6a1c78be247d232c3f.zip
[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
Diffstat (limited to 'clang')
-rw-r--r--clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h6
-rw-r--r--clang/lib/StaticAnalyzer/Core/BugReporter.cpp4
2 files changed, 9 insertions, 1 deletions
diff --git a/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h b/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
index 95b27e7861c..1c1b985c8f0 100644
--- a/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
+++ b/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
@@ -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);
}
diff --git a/clang/lib/StaticAnalyzer/Core/BugReporter.cpp b/clang/lib/StaticAnalyzer/Core/BugReporter.cpp
index fc28c587d21..70efacbd34f 100644
--- a/clang/lib/StaticAnalyzer/Core/BugReporter.cpp
+++ b/clang/lib/StaticAnalyzer/Core/BugReporter.cpp
@@ -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());
}
OpenPOWER on IntegriCloud