diff options
author | Matt Beaumont-Gay <matthewbg@google.com> | 2011-10-03 16:26:56 +0000 |
---|---|---|
committer | Matt Beaumont-Gay <matthewbg@google.com> | 2011-10-03 16:26:56 +0000 |
commit | 7035f310f5cfedb35ee4422bcab98e9f18f4ce63 (patch) | |
tree | 6ac4ee14fa4c097714f89a55bd183fc26f926c04 /include/clang/Basic/PartialDiagnostic.h | |
parent | f87cced71a955dca5731e7b28bc182e4824c0355 (diff) |
Don't crash when trying to emit too many fixits. Also, keep some constants in
sync between DiagnosticsEngine and PartialDiagnostic.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@141006 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Basic/PartialDiagnostic.h')
-rw-r--r-- | include/clang/Basic/PartialDiagnostic.h | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/include/clang/Basic/PartialDiagnostic.h b/include/clang/Basic/PartialDiagnostic.h index 4eff3a188e..c6ca989765 100644 --- a/include/clang/Basic/PartialDiagnostic.h +++ b/include/clang/Basic/PartialDiagnostic.h @@ -33,7 +33,7 @@ public: /// currently only support up to 10 arguments (%0-%9). /// A single diagnostic with more than that almost certainly has to /// be simplified anyway. - MaxArguments = 10 + MaxArguments = DiagnosticsEngine::MaxArguments }; /// NumDiagArgs - This contains the number of entries in Arguments. @@ -65,7 +65,7 @@ public: /// only support 10 ranges, could easily be extended if needed. CharSourceRange DiagRanges[10]; - enum { MaxFixItHints = 3 }; + enum { MaxFixItHints = DiagnosticsEngine::MaxFixItHints }; /// FixItHints - If valid, provides a hint with some code /// to insert, remove, or modify at a particular position. @@ -165,6 +165,8 @@ private: assert(DiagStorage->NumFixItHints < Storage::MaxFixItHints && "Too many code modification hints!"); + if (DiagStorage->NumFixItHints >= Storage::MaxFixItHints) + return; // Don't crash in release builds DiagStorage->FixItHints[DiagStorage->NumFixItHints++] = Hint; } |