diff options
author | Shafik Yaghmour <shafik.yaghmour@intel.com> | 2025-08-20 13:57:37 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-08-20 13:57:37 -0700 |
commit | 2a66ce5edb2511b248ca895b7d60c7a7b63c2c48 (patch) | |
tree | 00c96743585f3bb01039915ebff197de5dbcb400 /clang/lib/Basic/SourceManager.cpp | |
parent | e6b4a21849f0588b1c4fb39802a3999d7ac51dad (diff) | |
download | llvm-2a66ce5edb2511b248ca895b7d60c7a7b63c2c48.zip llvm-2a66ce5edb2511b248ca895b7d60c7a7b63c2c48.tar.gz llvm-2a66ce5edb2511b248ca895b7d60c7a7b63c2c48.tar.bz2 |
[Clang][NFC] Clarify some SourceManager related code (#153527)
Static analysis flagged the columns - 1 code, it was correct but the
assumption was not obvious. I document the assumption w/ assertions.
While digging through related code I found getColumnNumber that looks
wrong at first inspection and adding parentheses makes it clearer.
Diffstat (limited to 'clang/lib/Basic/SourceManager.cpp')
-rw-r--r-- | clang/lib/Basic/SourceManager.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/clang/lib/Basic/SourceManager.cpp b/clang/lib/Basic/SourceManager.cpp index 343c26e..d8ec837 100644 --- a/clang/lib/Basic/SourceManager.cpp +++ b/clang/lib/Basic/SourceManager.cpp @@ -1171,14 +1171,14 @@ unsigned SourceManager::getColumnNumber(FileID FID, unsigned FilePos, if (Buf[FilePos - 1] == '\r' || Buf[FilePos - 1] == '\n') --FilePos; } - return FilePos - LineStart + 1; + return (FilePos - LineStart) + 1; } } unsigned LineStart = FilePos; while (LineStart && Buf[LineStart-1] != '\n' && Buf[LineStart-1] != '\r') --LineStart; - return FilePos-LineStart+1; + return (FilePos - LineStart) + 1; } // isInvalid - Return the result of calling loc.isInvalid(), and |