[SMTChecker] Fix ICE when reporting cex concerning state vars from different source files

This commit is contained in:
Leonardo Alt
2019-08-10 20:56:52 +02:00
parent 67c855e93e
commit 4214cd1354
11 changed files with 29 additions and 23 deletions
+12
View File
@@ -22,7 +22,9 @@
#pragma once
#include <libdevcore/Assertions.h>
#include <libdevcore/Common.h> // defines noexcept macro for MSVC
#include <libdevcore/Exceptions.h>
#include <liblangutil/CharStream.h>
#include <memory>
#include <string>
@@ -31,6 +33,7 @@
namespace langutil
{
struct SourceLocationError: virtual dev::Exception {};
/**
* Representation of an interval of source positions.
@@ -49,6 +52,15 @@ struct SourceLocation
bool isEmpty() const { return start == -1 && end == -1; }
std::string text() const
{
assertThrow(source, SourceLocationError, "Requested text from null source.");
assertThrow(!isEmpty(), SourceLocationError, "Requested text from empty source location.");
assertThrow(start <= end, SourceLocationError, "Invalid source location.");
assertThrow(end <= int(source->source().length()), SourceLocationError, "Invalid source location.");
return source->source().substr(start, end - start);
}
/// @returns the smallest SourceLocation that contains both @param _a and @param _b.
/// Assumes that @param _a and @param _b refer to the same source (exception: if the source of either one
/// is unset, the source of the other will be used for the result, even if that is unset as well).