[AST] Replace asserts with a condition

As was done for other locations in commit 54272e5b (NFC:
Replace asserts with if() in SourceLocation accessors, 2019-01-07).

Extracted from  https://reviews.llvm.org/D99231

GitOrigin-RevId: 6559ebd91b70f8d2ed82e19539ee09c5220159c2
2 files changed