Change SMRange to be half-open (exclusive end) instead of closed (inclusive)

This is necessary not only for representing empty ranges, but for handling
multibyte characters in the input. (If the end pointer in a range refers to
a multibyte character, should it point to the beginning or the end of the
character in a char array?) Some of the code in the asm parsers was already
assuming this anyway.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171765 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Jordan Rose
2013-01-07 19:00:49 +00:00
parent 7aa1c321f0
commit 3ebe59c892
9 changed files with 185 additions and 174 deletions

View File

@@ -19,7 +19,7 @@
namespace llvm {
/// SMLoc - Represents a location in source code.
/// Represents a location in source code.
class SMLoc {
const char *Ptr;
public:
@@ -39,9 +39,11 @@ public:
}
};
/// SMRange - Represents a range in source code. Note that unlike standard STL
/// ranges, the locations specified are considered to be *inclusive*. For
/// example, [X,X] *does* include X, it isn't an empty range.
/// Represents a range in source code.
///
/// SMRange is implemented using a half-open range, as is the convention in C++.
/// In the string "abc", the range (1,3] represents the substring "bc", and the
/// range (2,2] represents an empty range between the characters "b" and "c".
class SMRange {
public:
SMLoc Start, End;