Fixed undefined behavior in pushMappings when the stack has to resize.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84924 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Basic/Diagnostic.cpp b/lib/Basic/Diagnostic.cpp
index d665e49..fbc7313 100644
--- a/lib/Basic/Diagnostic.cpp
+++ b/lib/Basic/Diagnostic.cpp
@@ -230,6 +230,8 @@
void Diagnostic::pushMappings() {
+ // Avoids undefined behavior when the stack has to resize.
+ DiagMappingsStack.reserve(DiagMappingsStack.size() + 1);
DiagMappingsStack.push_back(DiagMappingsStack.back());
}