diff options
author | Jordan Rose <jordan_rose@apple.com> | 2013-01-07 19:00:49 +0000 |
---|---|---|
committer | Jordan Rose <jordan_rose@apple.com> | 2013-01-07 19:00:49 +0000 |
commit | 3ebe59c892051375623fea55e977ff559fdb3323 (patch) | |
tree | 57c29e90762855b6aacd9a7341a1db0bcf526be1 /include/llvm/Support | |
parent | 7aa1c321f00d29fdc84e9a03080853aa25dd06fc (diff) |
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
Diffstat (limited to 'include/llvm/Support')
-rw-r--r-- | include/llvm/Support/SMLoc.h | 10 | ||||
-rw-r--r-- | include/llvm/Support/YAMLParser.h | 2 |
2 files changed, 7 insertions, 5 deletions
diff --git a/include/llvm/Support/SMLoc.h b/include/llvm/Support/SMLoc.h index 1bf810b4aa..2b0e9dfff7 100644 --- a/include/llvm/Support/SMLoc.h +++ b/include/llvm/Support/SMLoc.h @@ -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; diff --git a/include/llvm/Support/YAMLParser.h b/include/llvm/Support/YAMLParser.h index 03cbe33882..5b728bc2b8 100644 --- a/include/llvm/Support/YAMLParser.h +++ b/include/llvm/Support/YAMLParser.h @@ -184,7 +184,7 @@ public: : Node(NK_Scalar, D, Anchor) , Value(Val) { SMLoc Start = SMLoc::getFromPointer(Val.begin()); - SMLoc End = SMLoc::getFromPointer(Val.end() - 1); + SMLoc End = SMLoc::getFromPointer(Val.end()); SourceRange = SMRange(Start, End); } |