]> granicus.if.org Git - clang/commitdiff
[analyzer] Allow checker writes to specify that no region should be accosiated with...
authorAnna Zaks <ganna@apple.com>
Wed, 24 Aug 2011 20:31:06 +0000 (20:31 +0000)
committerAnna Zaks <ganna@apple.com>
Wed, 24 Aug 2011 20:31:06 +0000 (20:31 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138474 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
lib/StaticAnalyzer/Core/BugReporter.cpp

index 95b27e7861ce0d994e7106e7d2517b733858ba29..1c1b985c8f0dc5a0aae6ceee5ef9b11dc5475885 100644 (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);
   }
 
index fc28c587d212f394cbca38fafa5d818503ce35ac..70efacbd34f2a4de6cdda284355a4821285234c3 100644 (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());
 }