diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2018-10-15 13:46:58 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-10-15 13:46:58 -0400 |
| commit | 5b306c98bcb5767de461623cc367e7963adbf279 (patch) | |
| tree | 2470b77bc1821a741d5bac0ba0cf76ee1a00add8 /source/slang/source-loc.cpp | |
| parent | a7a87cec8c98872299e5dbe4c47a852a954b692b (diff) | |
Feature/source loc improvements (#673)
* Fix comment to better explain usage.
* For getting the type string use a temporary SourceManager.
Diffstat (limited to 'source/slang/source-loc.cpp')
| -rw-r--r-- | source/slang/source-loc.cpp | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/source/slang/source-loc.cpp b/source/slang/source-loc.cpp index 905cb46c6..d6b75b909 100644 --- a/source/slang/source-loc.cpp +++ b/source/slang/source-loc.cpp @@ -27,11 +27,9 @@ int SourceView::findEntryIndex(SourceLoc sourceLoc) const int lo = 0; while (lo + 1 < hi) { - int mid = (hi + lo) >> 1; - + const int mid = (hi + lo) >> 1; const Entry& midEntry = m_entries[mid]; SourceLoc::RawValue midValue = midEntry.m_startLoc.getRaw(); - if (midValue <= rawValue) { // The location we seek is at or after this entry @@ -67,8 +65,9 @@ void SourceView::addLineDirective(SourceLoc directiveLoc, StringSlicePool::Handl // We also need to make sure that any lookups for line numbers will // get corrected based on this files location. - // We assume the line number coming in is a line number, NOT an index so the correction needs + 1 - // There is an additional + 1 because we want the NEXT line to be 99 (ie +2 is correct 'fix') + // We assume the line number coming from the directive is a line number, NOT an index, so the correction needs + 1 + // There is an additional + 1 because we want the NEXT line - ie the line after the #line directive, to the specified value + // Taking both into account means +2 is correct 'fix' entry.m_lineAdjust = line - (lineIndex + 2); m_entries.Add(entry); @@ -452,5 +451,4 @@ String SourceManager::getPath(SourceLoc loc, SourceLocType type) } } - } // namespace Slang |
