[clang] ae726fe - [SourceManager] Explicitly check for potential iterator underflow
Jan Korous via cfe-commits
cfe-commits at lists.llvm.org
Tue Sep 15 15:54:48 PDT 2020
Author: Jan Korous
Date: 2020-09-15T15:54:16-07:00
New Revision: ae726fecae9a1cc9c50de5a9f6e860056f82c556
URL: https://github.com/llvm/llvm-project/commit/ae726fecae9a1cc9c50de5a9f6e860056f82c556
DIFF: https://github.com/llvm/llvm-project/commit/ae726fecae9a1cc9c50de5a9f6e860056f82c556.diff
LOG: [SourceManager] Explicitly check for potential iterator underflow
Differential Revision: https://reviews.llvm.org/D86231
Added:
Modified:
clang/lib/Basic/SourceManager.cpp
Removed:
################################################################################
diff --git a/clang/lib/Basic/SourceManager.cpp b/clang/lib/Basic/SourceManager.cpp
index 0a76c78cd44f..0f194403bf04 100644
--- a/clang/lib/Basic/SourceManager.cpp
+++ b/clang/lib/Basic/SourceManager.cpp
@@ -1936,6 +1936,11 @@ SourceManager::getMacroArgExpandedLocation(SourceLocation Loc) const {
assert(!MacroArgsCache->empty());
MacroArgsMap::iterator I = MacroArgsCache->upper_bound(Offset);
+ // In case every element in MacroArgsCache is greater than Offset we can't
+ // decrement the iterator.
+ if (I == MacroArgsCache->begin())
+ return Loc;
+
--I;
unsigned MacroArgBeginOffs = I->first;
More information about the cfe-commits
mailing list