mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
[SMTChecker] Fix ICE when reporting cex concerning state vars from different source files
This commit is contained in:
@@ -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).
|
||||
|
||||
Reference in New Issue
Block a user