Adding an assert to help catch possible buffer underruns.

llvm-svn: 195024
This commit is contained in:
Aaron Ballman 2013-11-18 18:29:00 +00:00
parent eedd3064de
commit ef1cf830e0
1 changed files with 4 additions and 0 deletions

View File

@ -1757,6 +1757,10 @@ FileID SourceManager::translateFile(const FileEntry *SourceFile) const {
SourceLocation SourceManager::translateLineCol(FileID FID,
unsigned Line,
unsigned Col) const {
// Lines are used as a one-based index into a zero-based array. This assert
// checks for possible buffer underruns.
assert(Line != 0 && "Passed a zero-based line");
if (FID.isInvalid())
return SourceLocation();